You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Handle the CSI driver in VolumeSnapshotContent does not match case
In VolumeSnapshotContent, if the CSI driver does not match the plugin's,
the controller should skip this content instead of always processing it.
This PR also add a few tests related to snapshot and content static
binding.
During binding, if content specify its bound snapshot uid and it
does not match the snapshot's uid, the content object and also the
physical snapshot will be deleted. In this case, the controller will
treat the content as an orphan content because its snapshot object does
not exist (deleted) any more.
// VolumeSnapshotContent is not bound to any VolumeSnapshot, this case rare and we just return err
88
+
// VolumeSnapshotContent is not bound to any VolumeSnapshot, in this case we just return err
89
89
ifcontent.Spec.VolumeSnapshotRef==nil {
90
90
// content is not bound
91
91
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: VolumeSnapshotContent is not bound to any VolumeSnapshot", content.Name)
92
92
ctrl.eventRecorder.Event(content, v1.EventTypeWarning, "SnapshotContentNotBound", "VolumeSnapshotContent is not bound to any VolumeSnapshot")
93
93
returnfmt.Errorf("volumeSnapshotContent %s is not bound to any VolumeSnapshot", content.Name)
94
+
}
95
+
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: content is bound to snapshot %s", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
96
+
// The VolumeSnapshotContent is reserved for a VolumeSnapshot;
97
+
// that VolumeSnapshot has not yet been bound to this VolumeSnapshotContent; the VolumeSnapshot sync will handle it.
98
+
ifcontent.Spec.VolumeSnapshotRef.UID=="" {
99
+
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: VolumeSnapshotContent is pre-bound to VolumeSnapshot %s", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: snapshot %s not found", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
111
+
// Fall through with snapshot = nil
94
112
} else {
95
-
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: content is bound to snapshot %s", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
96
-
// The VolumeSnapshotContent is reserved for a VolumeSnapshot;
97
-
// that VolumeSnapshot has not yet been bound to this VolumeSnapshotContent; the VolumeSnapshot sync will handle it.
98
-
ifcontent.Spec.VolumeSnapshotRef.UID=="" {
99
-
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: VolumeSnapshotContent is pre-bound to VolumeSnapshot %s", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
// The snapshot that the content was pointing to was deleted, and another
122
-
// with the same name created.
123
-
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: content %s has different UID, the old one must have been deleted", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
124
-
// Treat the volume as bound to a missing claim.
125
-
snapshot=nil
126
-
}
127
-
ifsnapshot==nil {
128
-
ctrl.deleteSnapshotContent(content)
113
+
varokbool
114
+
snapshot, ok=obj.(*crdv1.VolumeSnapshot)
115
+
if!ok {
116
+
returnfmt.Errorf("cannot convert object from snapshot cache to snapshot %q!?: %#v", content.Name, obj)
// The snapshot that the content was pointing to was deleted, and another
122
+
// with the same name created.
123
+
glog.V(4).Infof("synchronizing VolumeSnapshotContent[%s]: content %s has different UID, the old one must have been deleted", content.Name, snapshotRefKey(content.Spec.VolumeSnapshotRef))
124
+
// Treat the content as bound to a missing snapshot.
name: "2-1 - content with empty snapshot class will not be deleted if it is bound to a non-exist snapshot but it does not have a snapshot uid specified",
0 commit comments