revamp find content logic to fix 290 291 292
add snapshot source validation in syncSnapshot add content source validation in syncContent
This commit is contained in:
@@ -173,15 +173,9 @@ func StoreObjectUpdate(store cache.Store, obj interface{}, className string) (bo
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// 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 snapshot.Spec.Source.VolumeSnapshotContentName != nil {
|
||||
return *snapshot.Spec.Source.VolumeSnapshotContentName
|
||||
}
|
||||
// Construct SnapshotContentName for dynamic provisioning.
|
||||
// GetDynamicSnapshotContentNameForSnapshot returns a unique content name for the
|
||||
// passed in VolumeSnapshot to dynamically provision a snapshot.
|
||||
func GetDynamicSnapshotContentNameForSnapshot(snapshot *crdv1.VolumeSnapshot) string {
|
||||
return "snapcontent-" + string(snapshot.UID)
|
||||
}
|
||||
|
||||
@@ -408,14 +402,6 @@ func GetSnapshotStatusForLogging(snapshot *crdv1.VolumeSnapshot) string {
|
||||
return fmt.Sprintf("bound to: %q, Completed: %v", snapshotContentName, ready)
|
||||
}
|
||||
|
||||
// IsSnapshotBound returns true/false if snapshot is bound
|
||||
func IsSnapshotBound(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) bool {
|
||||
if IsVolumeSnapshotRefSet(snapshot, content) && IsBoundVolumeSnapshotContentNameSet(snapshot) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func IsVolumeSnapshotRefSet(snapshot *crdv1.VolumeSnapshot, content *crdv1.VolumeSnapshotContent) bool {
|
||||
if content.Spec.VolumeSnapshotRef.Name == snapshot.Name &&
|
||||
content.Spec.VolumeSnapshotRef.Namespace == snapshot.Namespace &&
|
||||
|
Reference in New Issue
Block a user