Skip to content

Commit fe4a04d

Browse files
committed
Avoid group snapshot provisioning with mismatching CSI Drivers
1 parent a50e4b8 commit fe4a04d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pkg/common-controller/groupsnapshot_controller_helper.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,23 @@ func (ctrl *csiSnapshotCommonController) createGroupSnapshotContent(groupSnapsho
838838
)
839839
return nil, err
840840
}
841+
842+
volumeCSIDriver := pv.Spec.CSI.Driver
843+
classCSIDriver := groupSnapshotClass.Driver
844+
if volumeCSIDriver != classCSIDriver {
845+
strErr := fmt.Sprintf(
846+
"Volume CSI driver (%s) mismatch with VolumeGroupSnapshotClass (%s) %s: %s",
847+
volumeCSIDriver, classCSIDriver, utils.GroupSnapshotKey(groupSnapshot), pv.Name)
848+
klog.Error(strErr)
849+
ctrl.eventRecorder.Event(
850+
groupSnapshot,
851+
v1.EventTypeWarning,
852+
"CreateGroupSnapshotContentFailed",
853+
strErr,
854+
)
855+
return nil, newControllerUpdateError(utils.GroupSnapshotKey(groupSnapshot), strErr)
856+
857+
}
841858
volumeHandles = append(volumeHandles, pv.Spec.CSI.VolumeHandle)
842859
}
843860

0 commit comments

Comments
 (0)