Skip to content

Commit 3da5e35

Browse files
jentingroboquat
authored andcommitted
[ws-manager] enable the volume snapshot controller when the VolumeSnapshot CRD exists
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 20aca36 commit 3da5e35

File tree

1 file changed

+12
-8
lines changed
  • components/ws-manager/cmd

1 file changed

+12
-8
lines changed

components/ws-manager/cmd/run.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,18 @@ var runCmd = &cobra.Command{
200200
log.WithError(err).Fatal(err, "unable to create controller", "controller", "Pod")
201201
}
202202

203-
err = (&manager.VolumeSnapshotReconciler{
204-
Monitor: monitor,
205-
Client: mgr.GetClient(),
206-
Log: ctrl.Log.WithName("controllers").WithName("VolumeSnapshot"),
207-
Scheme: mgr.GetScheme(),
208-
}).SetupWithManager(mgr)
209-
if err != nil {
210-
log.WithError(err).Fatal(err, "unable to create controller", "controller", "VolumeSnapshot")
203+
// enable the volume snapshot controller when the VolumeSnapshot CRD exists
204+
_, err = clientset.DiscoveryClient.ServerResourcesForGroupVersion(volumesnapshotv1.SchemeGroupVersion.String())
205+
if err == nil {
206+
err = (&manager.VolumeSnapshotReconciler{
207+
Monitor: monitor,
208+
Client: mgr.GetClient(),
209+
Log: ctrl.Log.WithName("controllers").WithName("VolumeSnapshot"),
210+
Scheme: mgr.GetScheme(),
211+
}).SetupWithManager(mgr)
212+
if err != nil {
213+
log.WithError(err).Fatal(err, "unable to create controller", "controller", "VolumeSnapshot")
214+
}
211215
}
212216

213217
if cfg.PProf.Addr != "" {

0 commit comments

Comments
 (0)