From ec84e6543c7e29214109c63612164c336ce77a2f Mon Sep 17 00:00:00 2001 From: Dennis Chen Date: Fri, 3 Aug 2018 14:51:54 +0800 Subject: [PATCH] Return immediately when no valid node to run osd We don't need to handle other osd(s) related tasks if there's no valid nodes available in the cluster to run osd(s), log a warning message to help user identify the cause of the issue. Signed-off-by: Dennis Chen --- pkg/operator/ceph/cluster/osd/osd.go | 5 +++++ pkg/operator/ceph/cluster/osd/status_test.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/pkg/operator/ceph/cluster/osd/osd.go b/pkg/operator/ceph/cluster/osd/osd.go index 7460057cb..845d55f79 100644 --- a/pkg/operator/ceph/cluster/osd/osd.go +++ b/pkg/operator/ceph/cluster/osd/osd.go @@ -160,6 +160,11 @@ func (c *Cluster) Start() error { logger.Debugf("storage nodes: %+v", c.Storage.Nodes) } validNodes := k8sutil.GetValidNodes(c.Storage.Nodes, c.context.Clientset, c.placement) + // no valid node is ready to run an osd + if len(validNodes) == 0 { + logger.Warningf("no valid node available to run an osd in namespace %s", c.Namespace) + return nil + } logger.Infof("%d of the %d storage nodes are valid", len(validNodes), len(c.Storage.Nodes)) c.Storage.Nodes = validNodes // orchestrate individual nodes, starting with any that are still ongoing (in the case that we diff --git a/pkg/operator/ceph/cluster/osd/status_test.go b/pkg/operator/ceph/cluster/osd/status_test.go index 39b237f01..6d8033046 100644 --- a/pkg/operator/ceph/cluster/osd/status_test.go +++ b/pkg/operator/ceph/cluster/osd/status_test.go @@ -60,6 +60,10 @@ func TestOrchestrationStatus(t *testing.T) { } func mockNodeOrchestrationCompletion(c *Cluster, nodeName string, statusMapWatcher *watch.FakeWatcher) { + // if no valid osd node, don't need to check its status, return immediately + if len(c.Storage.Nodes) == 0 { + return + } for { // wait for the node's orchestration status to change to "starting" cmName := fmt.Sprintf(orchestrationStatusMapName, nodeName)