Skip to content

Commit eebef4f

Browse files
iPraveenPariharmergify[bot]
authored andcommitted
reclaimspace: fix schedule handling
This commit addresses a bug in `determineScheduleAndRequeue` where the check for schedule from the StorageClass annotations is never reached. Signed-off-by: Praveen M <m.praveen@ibm.com>
1 parent e75a8fd commit eebef4f

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

controllers/csiaddons/persistentvolumeclaim_controller.go

+23-13
Original file line numberDiff line numberDiff line change
@@ -278,29 +278,39 @@ func (r *PersistentVolumeClaimReconciler) determineScheduleAndRequeue(
278278
return "", err
279279
}
280280
schedule, scheduleFound = getScheduleFromAnnotation(logger, ns.Annotations)
281-
if !scheduleFound {
282-
return "", ErrScheduleNotFound
283-
}
281+
284282
// If the schedule is found, check whether driver supports the
285283
// space reclamation using annotation on namespace and registered driver
286284
// capability for decision on requeue.
287-
288-
requeue, supportReclaimspace := r.checkDriverSupportReclaimsSpace(logger, ns.Annotations, driverName)
289-
if supportReclaimspace {
290-
// if driver supports space reclamation,
291-
// return schedule from ns annotation.
292-
return schedule, nil
285+
if scheduleFound {
286+
requeue, supportReclaimspace := r.checkDriverSupportReclaimsSpace(logger, ns.Annotations, driverName)
287+
if supportReclaimspace {
288+
// if driver supports space reclamation,
289+
// return schedule from ns annotation.
290+
return schedule, nil
291+
}
292+
if requeue {
293+
// The request needs to be requeued for checking
294+
// driver support again.
295+
return "", ErrConnNotFoundRequeueNeeded
296+
}
293297
}
294-
if requeue {
295-
// The request needs to be requeued for checking
296-
// driver support again.
297-
return "", ErrConnNotFoundRequeueNeeded
298+
299+
// For static provisioned PVs, StorageClassName is empty.
300+
if len(*pvc.Spec.StorageClassName) == 0 {
301+
logger.Info("StorageClassName is empty")
302+
return "", ErrScheduleNotFound
298303
}
299304

300305
// check for storageclass schedule annotation.
301306
sc := &storagev1.StorageClass{}
302307
err = r.Client.Get(ctx, types.NamespacedName{Name: *pvc.Spec.StorageClassName}, sc)
303308
if err != nil {
309+
if apierrors.IsNotFound(err) {
310+
logger.Error(err, "StorageClass not found", "StorageClass", *pvc.Spec.StorageClassName)
311+
return "", ErrScheduleNotFound
312+
}
313+
304314
logger.Error(err, "Failed to get StorageClass", "StorageClass", *pvc.Spec.StorageClassName)
305315
return "", err
306316
}

0 commit comments

Comments
 (0)