From 90b4e744570ddec748a40e47df299bc2fd155b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 12 Dec 2019 11:07:18 +0100 Subject: [PATCH] rook: add owner reference to the discover daemon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Attach owner reference to the discover daemon set so that when the opetator goes away, the discover pod gets removed too. Signed-off-by: Sébastien Han --- pkg/operator/discover/discover.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/operator/discover/discover.go b/pkg/operator/discover/discover.go index 357a9e7de..a3dedbda0 100644 --- a/pkg/operator/discover/discover.go +++ b/pkg/operator/discover/discover.go @@ -25,6 +25,8 @@ import ( "strings" "time" + "github.com/pkg/errors" + "github.com/coreos/pkg/capnslog" rookalpha "github.com/rook/rook/pkg/apis/rook.io/v1alpha2" "github.com/rook/rook/pkg/clusterd" @@ -85,9 +87,17 @@ func (d *Discover) createDiscoverDaemonSet(namespace, discoverImage, securityAcc discovery_parameters = append(discovery_parameters, "--use-ceph-volume") } + // Get the operator pod details + // So that we can attach the owner reference to the discover daemon set + operatorPod, err := k8sutil.GetRunningPod(d.clientset) + if err != nil { + return errors.Wrapf(err, "failed to get operator pod") + } + ds := &apps.DaemonSet{ ObjectMeta: metav1.ObjectMeta{ - Name: discoverDaemonsetName, + Name: discoverDaemonsetName, + OwnerReferences: operatorPod.OwnerReferences, }, Spec: apps.DaemonSetSpec{ Selector: &metav1.LabelSelector{