Skip to content

Commit d42a346

Browse files
authored
Merge pull request #1486 from michaelbeaumont/patch-1
fix: improve errors when trying to load VolumeSnapshotContent
2 parents 0840599 + 52adfde commit d42a346

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pkg/controller/controller.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ const (
156156
annModifyControllerSecretRefName = "volume.kubernetes.io/controller-modify-secret-name"
157157
annModifyControllerSecretRefNamespace = "volume.kubernetes.io/controller-modify-secret-namespace"
158158

159-
snapshotNotBound = "snapshot %s not bound"
159+
snapshotNotBound = "snapshot %s not bound"
160+
errorGettingSnapshotContent = "error getting snapshotcontent %s for snapshot %s"
161+
snapshotContentNotBoundToSnapshot = "snapshotcontent %s for snapshot %s is bound to a different snapshot"
162+
snapshotDifferentDriver = "snapshotcontent %s for snapshot %s is not handled by CSI driver of StorageClass %s"
160163

161164
pvcCloneFinalizer = "provisioner.storage.kubernetes.io/cloning-protection"
162165
// snapshotSourceProtectionFinalizer is managed by the external-provisioner to track
@@ -1309,17 +1312,17 @@ func (p *csiProvisioner) getSnapshotSource(ctx context.Context, claim *v1.Persis
13091312
snapContentObj, err := p.snapshotClient.SnapshotV1().VolumeSnapshotContents().Get(ctx, *snapshotObj.Status.BoundVolumeSnapshotContentName, metav1.GetOptions{})
13101313
if err != nil {
13111314
klog.Warningf("error getting snapshotcontent %s for snapshot %s/%s from api server: %s", *snapshotObj.Status.BoundVolumeSnapshotContentName, snapshotObj.Namespace, snapshotObj.Name, err)
1312-
return nil, fmt.Errorf(snapshotNotBound, dataSource.Name)
1315+
return nil, fmt.Errorf(errorGettingSnapshotContent, *snapshotObj.Status.BoundVolumeSnapshotContentName, dataSource.Name)
13131316
}
13141317

13151318
if snapContentObj.Spec.VolumeSnapshotRef.UID != snapshotObj.UID || snapContentObj.Spec.VolumeSnapshotRef.Namespace != snapshotObj.Namespace || snapContentObj.Spec.VolumeSnapshotRef.Name != snapshotObj.Name {
13161319
klog.Warningf("snapshotcontent %s for snapshot %s/%s is bound to a different snapshot", *snapshotObj.Status.BoundVolumeSnapshotContentName, snapshotObj.Namespace, snapshotObj.Name)
1317-
return nil, fmt.Errorf(snapshotNotBound, dataSource.Name)
1320+
return nil, fmt.Errorf(snapshotContentNotBoundToSnapshot, *snapshotObj.Status.BoundVolumeSnapshotContentName, dataSource.Name)
13181321
}
13191322

13201323
if snapContentObj.Spec.Driver != sc.Provisioner {
13211324
klog.Warningf("snapshotcontent %s for snapshot %s/%s is handled by a different CSI driver than requested by StorageClass %s", *snapshotObj.Status.BoundVolumeSnapshotContentName, snapshotObj.Namespace, snapshotObj.Name, sc.Name)
1322-
return nil, fmt.Errorf(snapshotNotBound, dataSource.Name)
1325+
return nil, fmt.Errorf(snapshotDifferentDriver, *snapshotObj.Status.BoundVolumeSnapshotContentName, dataSource.Name, sc.Name)
13231326
}
13241327

13251328
if snapshotObj.Status.ReadyToUse == nil || !*snapshotObj.Status.ReadyToUse {

0 commit comments

Comments
 (0)