From f6bd25ae01c2f295d602fc16c9d1eba11b9edfc0 Mon Sep 17 00:00:00 2001 From: parth-gr Date: Wed, 14 Apr 2021 10:49:55 +0530 Subject: [PATCH] ceph: update OSDs reconcile OSDs not automatically started when adding nodes to existing cluster. Call the helper NormalizeCrushName(name) to make sure the node name can match the name in the crush map before querying for the node in the crush map, and reconcile when new nodes get added. Closes: https://github.com/rook/rook/issues/7462 Signed-off-by: parth-gr --- pkg/daemon/ceph/client/crush.go | 1 + pkg/operator/ceph/cluster/watcher.go | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/daemon/ceph/client/crush.go b/pkg/daemon/ceph/client/crush.go index 0db1e0bbc..08b733811 100644 --- a/pkg/daemon/ceph/client/crush.go +++ b/pkg/daemon/ceph/client/crush.go @@ -199,6 +199,7 @@ func formatProperty(name, value string) string { // GetOSDOnHost returns the list of osds running on a given host func GetOSDOnHost(context *clusterd.Context, clusterInfo *ClusterInfo, node string) (string, error) { + node = NormalizeCrushName(node) args := []string{"osd", "crush", "ls", node} buf, err := NewCephCommand(context, clusterInfo, args).Run() if err != nil { diff --git a/pkg/operator/ceph/cluster/watcher.go b/pkg/operator/ceph/cluster/watcher.go index d7c986a04..466890f73 100644 --- a/pkg/operator/ceph/cluster/watcher.go +++ b/pkg/operator/ceph/cluster/watcher.go @@ -94,17 +94,14 @@ func (c *clientCluster) onK8sNode(object runtime.Object) bool { osds, err := cephclient.GetOSDOnHost(c.context, clusterInfo, nodeName) if err != nil { // If it fails, this might be due to the the operator just starting and catching an add event for that node - logger.Debugf("failed to get osds on node %q", nodeName) - return false + logger.Debugf("failed to get osds on node %q, assume reconcile is necessary", nodeName) + return true } // If they are OSDs in the CRUSH map and if the host exists in the CRUSH map, don't reconcile if osds != "" { // This is Debug level because the node receives frequent updates and this will pollute the logs logger.Debugf("node watcher: node %q is already an OSD node with %q", nodeName, osds) - } else { - logger.Infof("node watcher: adding node %q to cluster %q", node.Labels[v1.LabelHostname], cluster.Namespace) - return true } }