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.
This commit is contained in:
Xing Yang
2018-11-19 15:20:57 -08:00
parent 799fb952e1
commit fddc5547f3

View File

@@ -106,6 +106,12 @@ func storeObjectUpdate(store cache.Store, obj interface{}, className string) (bo
// GetSnapshotContentNameForSnapshot returns SnapshotContent.Name for the create VolumeSnapshotContent. // GetSnapshotContentNameForSnapshot returns SnapshotContent.Name for the create VolumeSnapshotContent.
// The name must be unique. // The name must be unique.
func GetSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) string { 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) return "snapcontent-" + string(snapshot.UID)
} }