File orchestrator-cli-rename.patch of Package rook

commit 3632e52e8f2dcfa156760dde80bd387bd2fab54c
Author: Sébastien Han <seb@redhat.com>
Date:   Fri Mar 6 17:00:37 2020 +0100

    ceph: orchestrator cli name change
    
    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 <seb@redhat.com>

diff --git a/pkg/operator/ceph/cluster/mgr/orchestrator.go b/pkg/operator/ceph/cluster/mgr/orchestrator.go
index 70420ee5..d3a606e7 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/
@@ -53,13 +56,12 @@ func (c *Cluster) configureOrchestratorModules() error {
 }
 
 func (c *Cluster) setRookOrchestratorBackend() error {
-	if !c.clusterInfo.CephVersion.IsAtLeastNautilus() {
-		return nil
+	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 0d6c1be2..17aa26c4 100644
--- a/pkg/operator/ceph/cluster/mgr/orchestrator_test.go
+++ b/pkg/operator/ceph/cluster/mgr/orchestrator_test.go
@@ -102,4 +102,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)
 }
openSUSE Build Service is sponsored by