Disabling reclaim space for a specific PersistentVolumeClaim

To disable reclaim space for a specific PersistentVolumeClaim (PVC), modify the associated ReclaimSpaceCronJob custom resource (CR).

Procedure

  1. Identify the ReclaimSpaceCronJob CR for the PVC you want to disable reclaim space.

    For example:

    oc get reclaimspacecronjobs -o jsonpath='{range .items[?(@.spec.jobTemplate.spec.target.persistentVolumeClaim=="<PVC_NAME>")]}{.metadata.name}{"\n"}{end}'

    Replace "<PVC_NAME>" with the name of the PVC.

  2. Disable the reclaim space from the ReclaimSpaceCronJob CR as follows:
    1. Update the csiaddons.openshift.io/state annotation from "managed" to "unmanaged".

      For example:

      oc annotate reclaimspacecronjobs <RECLAIMSPACECRONJOB_NAME> "csiaddons.openshift.io/state=unmanaged" --overwrite=true

      Replace <RECLAIMSPACECRONJOB_NAME> with the ReclaimSpaceCronJob CR.

    2. Add suspend: true under the spec field.

      For example:

      oc patch reclaimspacecronjobs <RECLAIMSPACECRONJOB_NAME> -p '{"spec": {"suspend": true}}' --type=merge