Skip to content

Commit 31bf725

Browse files
hellivanmergify[bot]
authored andcommitted
fix: reclaim jobs are created for pvs in deletion phase
The PersistentVolumeClaimReconciler invoked processReclaimSpace even when PVCs were already in the deletion phase. This behavior triggered the creation of reclaim jobs that prevented the underlying volume from being deleted. Similarly, the ReclaimSpaceCronJobReconciler created ReclaimSpaceJobs for ReclaimSpaceCronJobs in the deletion phase. When managed by a GitOps operator, this resulted in an infinite loop of job creation and deletion. The same behavior was also observed for EncryptionKeyRotationCronJobs. This was also fixed as part of this commit. Signed-off-by: Ivan Hell <ivan.hell@solunio.com>
1 parent 46527df commit 31bf725

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

internal/controller/csiaddons/encryptionkeyrotationcronjob_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func (r *EncryptionKeyRotationCronJobReconciler) Reconcile(ctx context.Context,
6464
return ctrl.Result{}, err
6565
}
6666

67+
// Check if resource is being deleted
68+
if !krcJob.DeletionTimestamp.IsZero() {
69+
logger.Info("EncryptionKeyRotationCronJob is being deleted, exiting reconcile", "namespace", krcJob.Namespace, "name", krcJob.Name)
70+
return ctrl.Result{}, nil
71+
}
72+
6773
// Set default values for the optionals
6874
if krcJob.Spec.FailedJobsHistoryLimit == nil {
6975
*krcJob.Spec.FailedJobsHistoryLimit = defaultFailedJobsHistoryLimit

internal/controller/csiaddons/persistentvolumeclaim_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ func (r *PersistentVolumeClaimReconciler) Reconcile(ctx context.Context, req ctr
118118
return ctrl.Result{}, err
119119
}
120120

121+
// Check if the PVC is being deleted
122+
if !pvc.DeletionTimestamp.IsZero() {
123+
logger.Info("PVC is being deleted, exiting reconcile", "namespace", pvc.Namespace, "name", pvc.Name)
124+
// requeue the request
125+
return ctrl.Result{}, nil
126+
}
127+
121128
// Validate PVC in bound state
122129
if pvc.Status.Phase != corev1.ClaimBound {
123130
logger.Info("PVC is not in bound state", "PVCPhase", pvc.Status.Phase)

internal/controller/csiaddons/reclaimspacecronjob_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ func (r *ReclaimSpaceCronJobReconciler) Reconcile(ctx context.Context, req ctrl.
8080
return ctrl.Result{}, err
8181
}
8282

83+
// Check if resource is being deleted
84+
if !rsCronJob.DeletionTimestamp.IsZero() {
85+
logger.Info("ReclaimSpaceCronJob is being deleted, exiting reconcile", "namespace", rsCronJob.Namespace, "name", rsCronJob.Name)
86+
return ctrl.Result{}, nil
87+
}
88+
8389
// set history limit defaults, if not specified.
8490
if rsCronJob.Spec.FailedJobsHistoryLimit == nil {
8591
*rsCronJob.Spec.FailedJobsHistoryLimit = defaultFailedJobsHistoryLimit

0 commit comments

Comments
 (0)