Skip to content

Commit e5ba689

Browse files
authored
Merge pull request #146 from amacaskill/add-logging
Add debugging logs to shouldDelete function to help debug why sometimes the PV is not deleted properly
2 parents cabcbb0 + 48c18bd commit e5ba689

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controller/controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ func (ctrl *ProvisionController) syncVolume(ctx context.Context, obj interface{}
11101110
}
11111111

11121112
if ctrl.shouldDelete(ctx, volume) {
1113+
klog.V(5).Infof("shouldDelete Volume: %q", volume.Name)
11131114
startTime := time.Now()
11141115
err = ctrl.deleteVolumeOperation(ctx, volume)
11151116
ctrl.updateDeleteStats(volume, err, startTime)
@@ -1235,6 +1236,7 @@ func (ctrl *ProvisionController) shouldProvision(ctx context.Context, claim *v1.
12351236
// shouldDelete returns whether a volume should have its backing volume
12361237
// deleted, i.e. whether a Delete is "desired"
12371238
func (ctrl *ProvisionController) shouldDelete(ctx context.Context, volume *v1.PersistentVolume) bool {
1239+
klog.V(5).Infof("shouldDelete volume %q", volume.Name)
12381240
if deletionGuard, ok := ctrl.provisioner.(DeletionGuard); ok {
12391241
if !deletionGuard.ShouldDelete(ctx, volume) {
12401242
return false
@@ -1244,22 +1246,27 @@ func (ctrl *ProvisionController) shouldDelete(ctx context.Context, volume *v1.Pe
12441246
if ctrl.addFinalizer {
12451247
if !ctrl.checkFinalizer(volume, finalizerPV) && volume.ObjectMeta.DeletionTimestamp != nil {
12461248
// The finalizer was removed, i.e. the volume has been already deleted.
1249+
klog.V(5).Infof("shouldDelete volume %q is false: finalizer already removed from volume", volume.Name)
12471250
return false
12481251
}
12491252
} else {
12501253
if volume.ObjectMeta.DeletionTimestamp != nil {
1254+
klog.V(5).Infof("shouldDelete volume %q is false: DeletionTimestamp != nil", volume.Name)
12511255
return false
12521256
}
12531257
}
12541258

12551259
if volume.Status.Phase != v1.VolumeReleased {
1260+
klog.V(5).Infof("shouldDelete volume %q is false: PersistentVolumePhase is not Released", volume.Name)
12561261
return false
12571262
}
12581263

12591264
if volume.Spec.PersistentVolumeReclaimPolicy != v1.PersistentVolumeReclaimDelete {
1265+
klog.V(5).Infof("shouldDelete volume %q is false: volume does not have Delete reclaim policy", volume.Name)
12601266
return false
12611267
}
12621268

1269+
klog.V(5).Infof("shouldDelete volume %q is true", volume.Name)
12631270
return true
12641271
}
12651272

0 commit comments

Comments
 (0)