From 8b0fdf31a90ef33a45ddd9bacffb045e0544f8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 6 Mar 2020 17:00:37 +0100 Subject: [PATCH] ceph: orchestrator cli name change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With https://github.com/ceph/ceph/pull/33131, the CLI has been rename 'orch' instead of 'orchestrator'. Octopus only. Signed-off-by: Sébastien Han --- pkg/operator/ceph/cluster/mgr/orchestrator.go | 8 +++++++- .../ceph/cluster/mgr/orchestrator_test.go | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/operator/ceph/cluster/mgr/orchestrator.go b/pkg/operator/ceph/cluster/mgr/orchestrator.go index 01b1c4a45..1069a52a6 100644 --- a/pkg/operator/ceph/cluster/mgr/orchestrator.go +++ b/pkg/operator/ceph/cluster/mgr/orchestrator.go @@ -27,10 +27,13 @@ import ( const ( orchestratorModuleName = "orchestrator_cli" rookModuleName = "rook" + orchestratorOldCLIName = "orchestrator" + orchestratorNewCLIName = "orch" ) var ( orchestratorInitWaitTime = 5 * time.Second + orchestratorCLIName = orchestratorOldCLIName ) // Ceph docs about the orchestrator modules: http://docs.ceph.com/docs/master/mgr/orchestrator_cli/ @@ -48,9 +51,12 @@ func (c *Cluster) configureOrchestratorModules() error { } func (c *Cluster) setRookOrchestratorBackend() error { + if c.clusterInfo.CephVersion.IsAtLeastOctopus() { + orchestratorCLIName = orchestratorNewCLIName + } // retry a few times in the case that the mgr module is not ready to accept commands _, err := client.ExecuteCephCommandWithRetry(func() ([]byte, error) { - args := []string{"orchestrator", "set", "backend", "rook"} + args := []string{orchestratorCLIName, "set", "backend", "rook"} return client.NewCephCommand(c.context, c.Namespace, args).RunWithTimeout(client.CmdExecuteTimeout) }, c.exitCode, 5, invalidArgErrorCode, orchestratorInitWaitTime) if err != nil { diff --git a/pkg/operator/ceph/cluster/mgr/orchestrator_test.go b/pkg/operator/ceph/cluster/mgr/orchestrator_test.go index 3ed19bcc9..1cd66387e 100644 --- a/pkg/operator/ceph/cluster/mgr/orchestrator_test.go +++ b/pkg/operator/ceph/cluster/mgr/orchestrator_test.go @@ -88,4 +88,23 @@ func TestOrchestratorModules(t *testing.T) { assert.True(t, orchestratorModuleEnabled) assert.True(t, rookModuleEnabled) assert.True(t, rookBackendSet) + + // Simulate the error because of the CLI name change + c.clusterInfo.CephVersion = cephver.Octopus + err = c.setRookOrchestratorBackend() + assert.Error(t, err) + executor.MockExecuteCommandWithOutputFileTimeout = func(debug bool, timeout time.Duration, actionName, command, outputFile string, args ...string) (string, error) { + logger.Infof("Command: %s %v", command, args) + if args[0] == "orch" && args[1] == "set" && args[2] == "backend" && args[3] == "rook" { + if backendErrorCount < 5 { + backendErrorCount++ + return "", errors.New("test simulation failure") + } + rookBackendSet = true + return "", nil + } + return "", errors.Errorf("unexpected ceph command %q", args) + } + err = c.setRookOrchestratorBackend() + assert.NoError(t, err) }