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

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

发生了什么?

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

你期望会发生什么?

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

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

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

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

  • 无响应*

Kubernetes版本

$ kubectl version
verison: v1.22.15

云提供商

裸金属

OS版本

# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

安装工具

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

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

wvyml7n5

wvyml7n51#

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

vptzau2j

vptzau2j3#

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

os8fio9y

os8fio9y4#

以下是清单和错误日志:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
    volume.beta.kubernetes.io/storage-provisioner: rook-ceph.rbd.csi.ceph.com
  creationTimestamp: "2024-02-22T07:35:00Z"
  deletionGracePeriodSeconds: 0
  deletionTimestamp: "2024-02-22T07:38:58Z"
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    app.kubernetes.io/created-by: volsync
    volsync.backube/cleanup: df38a2c4-45d0-47f0-a3d0-ec05f259173f
  name: volsync-my-source-src
  namespace: source
  ownerReferences:
  - apiVersion: volsync.backube/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: ReplicationSource
    name: my-source
    uid: df38a2c4-45d0-47f0-a3d0-ec05f259173f
  resourceVersion: "40154511"
  uid: 5e22a621-d12c-4ae9-855a-c33b0355be15
spec:
  accessModes:
  - ReadWriteOnce
  dataSource:
    apiGroup: null
    kind: PersistentVolumeClaim
    name: busybox-pvc
  dataSourceRef:
    apiGroup: null
    kind: PersistentVolumeClaim
    name: busybox-pvc
  resources:
    requests:
      storage: 5Gi
  storageClassName: rook-ceph-block
  volumeMode: Filesystem
  volumeName: pvc-5e22a621-d12c-4ae9-855a-c33b0355be15
status:
  phase: Lost

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

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"}
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

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?

相关问题