ceph: delete discovery daemon if it is disabled
discovery-daemon still exists even if it's disabled. Closes: https://github.com/rook/rook/issues/6936 Signed-off-by: Satoru Takeuchi <satoru.takeuchi@gmail.com>
This commit is contained in:
1 parent
83fee8adfb
commit
1be47ea0b8
2 files changed
+21
-7
No files matched your search
@@ -114,16 +114,21 @@ func (o *Operator) Run() error {
|
||||
return errors.Errorf("rook operator namespace is not provided. expose it via downward API in the rook operator manifest file using environment variable %q", k8sutil.PodNamespaceEnvVar)
|
||||
}
|
||||
|
||||
if EnableDiscoveryDaemon {
|
||||
rookDiscover := discover.New(o.context.Clientset)
|
||||
if err := rookDiscover.Start(o.operatorNamespace, o.rookImage, o.securityAccount, true); err != nil {
|
||||
return errors.Wrap(err, "failed to start device discovery daemonset")
|
||||
}
|
||||
}
|
||||
|
||||
// creating a context
|
||||
stopContext, stopFunc := context.WithCancel(context.Background())
|
||||
defer stopFunc()
|
||||
|
||||
rookDiscover := discover.New(o.context.Clientset)
|
||||
if EnableDiscoveryDaemon {
|
||||
if err := rookDiscover.Start(o.operatorNamespace, o.rookImage, o.securityAccount, true); err != nil {
|
||||
return errors.Wrap(err, "failed to start device discovery daemonset")
|
||||
}
|
||||
} else {
|
||||
if err := rookDiscover.Stop(stopContext, o.operatorNamespace); err != nil {
|
||||
return errors.Wrap(err, "failed to stop device discovery daemonset")
|
||||
}
|
||||
}
|
||||
|
||||
logger.Debug("checking for admission controller secrets")
|
||||
err := StartControllerIfSecretPresent(stopContext, o.context, o.rookImage)
|
||||
if err != nil {
|
||||
|
||||
@@ -472,3 +472,12 @@ func GetAvailableDevices(clusterdContext *clusterd.Context, nodeName, clusterNam
|
||||
}
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// Stop the discover
|
||||
func (d *Discover) Stop(ctx context.Context, namespace string) error {
|
||||
err := d.clientset.AppsV1().DaemonSets(namespace).Delete(ctx, discoverDaemonsetName, metav1.DeleteOptions{})
|
||||
if err != nil && !k8serrors.IsNotFound(err) {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in new issue
Block a user