kubernetes 无法删除处于终止状态的PVC,

tktrz96b  于 10个月前  发布在  Kubernetes
关注(0)|答案(9)|浏览(96)

发生了什么?

在删除pod后,PVC陷入了Terminating状态。尝试强制删除但没有成功,甚至尝试移除finaliser时也遇到了错误,提示该字段是不可变的,不允许更改spec字段,即使我没有更改spec字段。

你期望会发生什么?

我期望通过移除finaliser,PVC会被删除。

我们如何尽可能精确地重现它?

不确定如何重现这些步骤。

我们需要了解其他信息吗?

  • 无响应*

Kubernetes版本

  1. $ kubectl version
  2. verison: v1.22.15

云提供商

裸金属

OS版本

  1. # On Linux:
  2. $ cat /etc/os-release
  3. # paste output here
  4. $ uname -a
  5. # paste output here
  6. # On Windows:
  7. C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
  8. # paste output here

安装工具

容器运行时(CRI)和版本(如适用)

相关插件(CNI,CSI,...)和版本(如适用)

wvyml7n5

wvyml7n51#

这个问题目前正在等待分类。
如果SIG或子项目确定这是一个相关的问题,他们将通过应用triage/accepted标签并提供进一步的指导来接受它。
组织成员可以通过在评论中写入/triage accepted来添加triage/accepted标签。
有关使用PR评论与我互动的说明,请查看here。如果您对我的行为有任何问题或建议,请针对kubernetes/test-infra仓库提出一个问题。

kqlmhetl

kqlmhetl2#

/sig storage

vptzau2j

vptzau2j3#

你能粘贴PVC清单、事件和日志文件吗?@winkrs

os8fio9y

os8fio9y4#

以下是清单和错误日志:

  1. apiVersion: v1
  2. kind: PersistentVolumeClaim
  3. metadata:
  4. annotations:
  5. pv.kubernetes.io/bind-completed: "yes"
  6. pv.kubernetes.io/bound-by-controller: "yes"
  7. volume.beta.kubernetes.io/storage-provisioner: rook-ceph.rbd.csi.ceph.com
  8. creationTimestamp: "2024-02-22T07:35:00Z"
  9. deletionGracePeriodSeconds: 0
  10. deletionTimestamp: "2024-02-22T07:38:58Z"
  11. finalizers:
  12. - kubernetes.io/pvc-protection
  13. labels:
  14. app.kubernetes.io/created-by: volsync
  15. volsync.backube/cleanup: df38a2c4-45d0-47f0-a3d0-ec05f259173f
  16. name: volsync-my-source-src
  17. namespace: source
  18. ownerReferences:
  19. - apiVersion: volsync.backube/v1alpha1
  20. blockOwnerDeletion: true
  21. controller: true
  22. kind: ReplicationSource
  23. name: my-source
  24. uid: df38a2c4-45d0-47f0-a3d0-ec05f259173f
  25. resourceVersion: "40154511"
  26. uid: 5e22a621-d12c-4ae9-855a-c33b0355be15
  27. spec:
  28. accessModes:
  29. - ReadWriteOnce
  30. dataSource:
  31. apiGroup: null
  32. kind: PersistentVolumeClaim
  33. name: busybox-pvc
  34. dataSourceRef:
  35. apiGroup: null
  36. kind: PersistentVolumeClaim
  37. name: busybox-pvc
  38. resources:
  39. requests:
  40. storage: 5Gi
  41. storageClassName: rook-ceph-block
  42. volumeMode: Filesystem
  43. volumeName: pvc-5e22a621-d12c-4ae9-855a-c33b0355be15
  44. status:
  45. phase: Lost

当我尝试从PVC中删除finalizers字段时,这是从日志中得到的:

  1. 2024-04-24T04:28:57.237Z DEBUG controllers.ReplicationSource temporary snapshot reconciled {"replicationsource": {"name":"my-source","namespace":"source"}, "method": "RsyncTLS", "snapshot": {"name":"volsync-my-source-src","namespace":"source"}, "operation": "unchanged"}
  2. 2024-04-24T04:28:57.247Z ERROR controllers.ReplicationSource reconcile failed {"replicationsource": {"name":"my-source","namespace":"source"}, "method": "RsyncTLS", "pvc": {"name":"volsync-my-source-src","namespace":"source"}, "error": "PersistentVolumeClaim \"volsync-my-source-src\" is invalid: spec: Forbidden: spec is immutable after creation except resources.requests for bound claims\n core.PersistentVolumeClaimSpec{\n \t... // 5 identical fields\n \tVolumeMode: &\"Filesystem\",\n \tDataSource: &{Kind: \"PersistentVolumeClaim\", Name: \"busybox-pvc\"},\n- \tDataSourceRef: &core.TypedLocalObjectReference{Kind: \"PersistentVolumeClaim\", Name: \"busybox-pvc\"},\n+ \tDataSourceRef: nil,\n }\n"}

如您所见,当我没有权限更改spec字段时,我得到了错误。

展开查看全部
hc8w905p

hc8w905p5#

你是否尝试过通过指定所属的命名空间来删除pvc?@winkrs

62o28rlo

62o28rlo6#

是的@kays002

ss2ws0br

ss2ws0br7#

@winkrs 我不知道你是否尝试过这个方法,但当我遇到同样的问题时,我通过打补丁删除了终结器,然后强制删除了PVC。如果你仍然遇到这样的错误,请确保没有其他资源引用PVC。

xriantvc

xriantvc8#

@winkrs as the PVC manifest provided by you. I am giving you the patch PVC for finalizer deletion command
kubectl patch pvc volsync-my-source-src -n source -p '{"metadata":{"finalizers":null}}' --type=merge
Forcefully delete the PVC
kubectl delete pvc volsync-my-source-src -n source --grace-period=0 --force

ecfdbz9o

ecfdbz9o9#

如果它对你来说运行正常,那么请检查PVC是否已被删除?如果你仍然遇到这样的问题,那么请查看其他资源是否引用了PVC?

相关问题