From e33eb980470be4ef157f511f75e00c7b1c6543ff Mon Sep 17 00:00:00 2001 From: Noah Watkins Date: Thu, 2 May 2019 13:50:21 -0700 Subject: [PATCH] ceph: run self-signed cert creation with timeout fixes: #2784 Signed-off-by: Noah Watkins --- pkg/daemon/ceph/client/command.go | 4 ++-- pkg/operator/ceph/cluster/mgr/dashboard.go | 7 ++++++- pkg/operator/ceph/cluster/mgr/dashboard_test.go | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/daemon/ceph/client/command.go b/pkg/daemon/ceph/client/command.go index a6b233851..902b16373 100644 --- a/pkg/daemon/ceph/client/command.go +++ b/pkg/daemon/ceph/client/command.go @@ -39,7 +39,7 @@ const ( Kubectl = "kubectl" // CrushTool is the name of the CLI tool for 'crushtool' CrushTool = "crushtool" - cmdExecuteTimeout = 1 * time.Minute + CmdExecuteTimeout = 1 * time.Minute cephConnectionTimeout = "15" // in seconds ) @@ -169,7 +169,7 @@ func (c *CephToolCommand) RunWithTimeout(timeout time.Duration) ([]byte, error) // configured its arguments. It is future work to integrate this case into the // generalization. func ExecuteRBDCommandWithTimeout(context *clusterd.Context, clusterName string, args []string) (string, error) { - output, err := context.Executor.ExecuteCommandWithTimeout(false, cmdExecuteTimeout, "", RBDTool, args...) + output, err := context.Executor.ExecuteCommandWithTimeout(false, CmdExecuteTimeout, "", RBDTool, args...) return output, err } diff --git a/pkg/operator/ceph/cluster/mgr/dashboard.go b/pkg/operator/ceph/cluster/mgr/dashboard.go index c581a8eb2..46164cc90 100755 --- a/pkg/operator/ceph/cluster/mgr/dashboard.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard.go @@ -18,6 +18,7 @@ limitations under the License. package mgr import ( + "context" "fmt" "math/rand" "os/exec" @@ -185,7 +186,11 @@ func (c *Cluster) createSelfSignedCert() (bool, error) { // 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.NewCephCommand(c.context, c.Namespace, args).Run() + _, err := client.NewCephCommand(c.context, c.Namespace, args).RunWithTimeout(client.CmdExecuteTimeout) + if err == context.DeadlineExceeded { + logger.Infof("cert creation timed out. trying again..") + continue + } if err != nil { exitCode, parsed := c.exitCode(err) if parsed { diff --git a/pkg/operator/ceph/cluster/mgr/dashboard_test.go b/pkg/operator/ceph/cluster/mgr/dashboard_test.go index a8bc0534b..365305355 100644 --- a/pkg/operator/ceph/cluster/mgr/dashboard_test.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard_test.go @@ -18,6 +18,7 @@ package mgr import ( "fmt" "testing" + "time" cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/rook/rook/pkg/clusterd" @@ -93,6 +94,10 @@ func TestStartSecureDashboard(t *testing.T) { return "", nil }, } + executor.MockExecuteCommandWithOutputFileTimeout = func(debug bool, timeout time.Duration, actionName string, command, outfileArg string, arg ...string) (string, error) { + return executor.MockExecuteCommandWithOutputFile(debug, actionName, command, outfileArg, arg...) + } + clusterInfo := &cephconfig.ClusterInfo{ CephVersion: cephver.Mimic, }