Merge pull request #679 from RaunakShah/snapcontroller_sourcemode
Changes to snapshot controller to add sourceVolumeMode
This commit is contained in:
@@ -70,6 +70,7 @@ var (
|
||||
retryIntervalStart = flag.Duration("retry-interval-start", time.Second, "Initial retry interval of failed volume snapshot creation or deletion. It doubles with each failure, up to retry-interval-max. Default is 1 second.")
|
||||
retryIntervalMax = flag.Duration("retry-interval-max", 5*time.Minute, "Maximum retry interval of failed volume snapshot creation or deletion. Default is 5 minutes.")
|
||||
enableDistributedSnapshotting = flag.Bool("enable-distributed-snapshotting", false, "Enables each node to handle snapshotting for the local volumes created on that node")
|
||||
preventVolumeModeConversion = flag.Bool("prevent-volume-mode-conversion", false, "Prevents an unauthorised user from modifying the volume mode when creating a PVC from an existing VolumeSnapshot.")
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -187,6 +188,7 @@ func main() {
|
||||
workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax),
|
||||
workqueue.NewItemExponentialFailureRateLimiter(*retryIntervalStart, *retryIntervalMax),
|
||||
*enableDistributedSnapshotting,
|
||||
*preventVolumeModeConversion,
|
||||
)
|
||||
|
||||
if err := ensureCustomResourceDefinitionsExist(snapClient); err != nil {
|
||||
|
@@ -844,6 +844,7 @@ func newTestController(kubeClient kubernetes.Interface, clientset clientset.Inte
|
||||
workqueue.NewItemExponentialFailureRateLimiter(1*time.Millisecond, 1*time.Minute),
|
||||
workqueue.NewItemExponentialFailureRateLimiter(1*time.Millisecond, 1*time.Minute),
|
||||
false,
|
||||
false,
|
||||
)
|
||||
|
||||
ctrl.eventRecorder = record.NewFakeRecorder(1000)
|
||||
|
@@ -684,6 +684,13 @@ func (ctrl *csiSnapshotCommonController) createSnapshotContent(snapshot *crdv1.V
|
||||
}
|
||||
}
|
||||
|
||||
if ctrl.preventVolumeModeConversion {
|
||||
if volume.Spec.VolumeMode != nil {
|
||||
snapshotContent.Spec.SourceVolumeMode = volume.Spec.VolumeMode
|
||||
klog.V(5).Infof("snapcontent %s has volume mode %s", snapshotContent.Name, *snapshotContent.Spec.SourceVolumeMode)
|
||||
}
|
||||
}
|
||||
|
||||
// Set AnnDeletionSecretRefName and AnnDeletionSecretRefNamespace
|
||||
if snapshotterSecretRef != nil {
|
||||
klog.V(5).Infof("createSnapshotContent: set annotation [%s] on content [%s].", utils.AnnDeletionSecretRefName, snapshotContent.Name)
|
||||
|
@@ -68,6 +68,7 @@ type csiSnapshotCommonController struct {
|
||||
resyncPeriod time.Duration
|
||||
|
||||
enableDistributedSnapshotting bool
|
||||
preventVolumeModeConversion bool
|
||||
}
|
||||
|
||||
// NewCSISnapshotController returns a new *csiSnapshotCommonController
|
||||
@@ -84,6 +85,7 @@ func NewCSISnapshotCommonController(
|
||||
snapshotRateLimiter workqueue.RateLimiter,
|
||||
contentRateLimiter workqueue.RateLimiter,
|
||||
enableDistributedSnapshotting bool,
|
||||
preventVolumeModeConversion bool,
|
||||
) *csiSnapshotCommonController {
|
||||
broadcaster := record.NewBroadcaster()
|
||||
broadcaster.StartLogging(klog.Infof)
|
||||
@@ -138,6 +140,8 @@ func NewCSISnapshotCommonController(
|
||||
ctrl.nodeListerSynced = nodeInformer.Informer().HasSynced
|
||||
}
|
||||
|
||||
ctrl.preventVolumeModeConversion = preventVolumeModeConversion
|
||||
|
||||
return ctrl
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user