Skip to content

Commit

Permalink
Merge pull request rook#2728 from jtlayton/wip-orch-init
Browse files Browse the repository at this point in the history
Retry orchestrator initialization if command is unrecognized
  • Loading branch information
travisn authored Feb 27, 2019
2 parents 7b87202 + c0910da commit e4d42ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/operator/ceph/cluster/mgr/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
passwordLength = 10
passwordKeyName = "password"
certAlreadyConfiguredErrorCode = 5
invalidArgErrorCode = 22
invalidArgErrorCode = int(syscall.EINVAL)
)

var (
Expand Down
22 changes: 20 additions & 2 deletions pkg/operator/ceph/cluster/mgr/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mgr

import (
"fmt"
"time"

cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"github.com/rook/rook/pkg/daemon/ceph/client"
Expand All @@ -29,6 +30,10 @@ const (
rookModuleName = "rook"
)

var (
orchestratorInitWaitTime = 5 * time.Second
)

// Ceph docs about the orchestrator modules: http://docs.ceph.com/docs/master/mgr/orchestrator_cli/
func (c *Cluster) configureOrchestratorModules() error {
if !cephv1.VersionAtLeast(c.cephVersion.Name, cephv1.Nautilus) {
Expand All @@ -42,8 +47,21 @@ func (c *Cluster) configureOrchestratorModules() error {
if err := client.MgrEnableModule(c.context, c.Namespace, rookModuleName, true); err != nil {
return fmt.Errorf("failed to enable mgr rook module. %+v", err)
}
if _, err := client.ExecuteCephCommand(c.context, c.Namespace, []string{"orchestrator", "set", "backend", "rook"}); err != nil {
return fmt.Errorf("failed to set rook as the orchestrator backend. %+v", err)
// retry a few times in the case that the mgr module is not ready to accept commands
for i := 0; i < 5; i++ {
_, err := client.ExecuteCephCommand(c.context, c.Namespace, []string{"orchestrator", "set", "backend", "rook"})
if err != nil {
exitCode, parsed := c.exitCode(err)
if parsed {
if exitCode == invalidArgErrorCode {
logger.Infof("orchestrator module is not ready yet. trying again...")
time.Sleep(orchestratorInitWaitTime)
continue
}
}
return fmt.Errorf("failed to set rook as the orchestrator backend. %+v", err)
}
break
}

return nil
Expand Down

0 comments on commit e4d42ee

Please sign in to comment.