From fddc5547f34a42ea9f5b541f492082bd756d0baa Mon Sep 17 00:00:00 2001 From: Xing Yang Date: Mon, 19 Nov 2018 15:20:57 -0800 Subject: [PATCH] Use existing content name If content name is already in snapshot object, just use it. This may be the case for static provisioning. Otherwise construct new name for content for dynamic provisioning. --- pkg/controller/util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/controller/util.go b/pkg/controller/util.go index 3b99324b..8c64de83 100644 --- a/pkg/controller/util.go +++ b/pkg/controller/util.go @@ -106,6 +106,12 @@ func storeObjectUpdate(store cache.Store, obj interface{}, className string) (bo // GetSnapshotContentNameForSnapshot returns SnapshotContent.Name for the create VolumeSnapshotContent. // The name must be unique. func GetSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) string { + // If VolumeSnapshot object has SnapshotContentName, use it directly. + // This might be the case for static provisioning. + if len(snapshot.Spec.SnapshotContentName) > 0 { + return snapshot.Spec.SnapshotContentName + } + // Construct SnapshotContentName for dynamic provisioning. return "snapcontent-" + string(snapshot.UID) }