From 4505a4f8e4da23c949f0236aa542a9447b82ec76 Mon Sep 17 00:00:00 2001 From: Satoru Takeuchi Date: Thu, 28 Dec 2023 02:18:31 +0000 Subject: [PATCH] core: core: fix error handling on setting watcher If `cmClient.Watch()` failed, `watcher.Stop()` causes null pointer dereference. Signed-off-by: Satoru Takeuchi (cherry picked from commit b1a81509a5e90de8d4f7cf9fbcc2214d55a68d8b) --- pkg/operator/ceph/cluster/osd/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/operator/ceph/cluster/osd/status.go b/pkg/operator/ceph/cluster/osd/status.go index 564e5ce84..999e8b3a1 100644 --- a/pkg/operator/ceph/cluster/osd/status.go +++ b/pkg/operator/ceph/cluster/osd/status.go @@ -218,10 +218,10 @@ func (c *Cluster) updateAndCreateOSDsLoop( ResourceVersion: configMapList.ResourceVersion, } watcher, err := cmClient.Watch(c.clusterInfo.Context, watchOptions) - defer watcher.Stop() if err != nil { return false, errors.Wrapf(err, "failed to start watching OSD provisioning status ConfigMaps") } + defer watcher.Stop() // tick after a short time of waiting for new OSD provision status configmaps to change state // in order to allow opportunistic deployment updates while we wait