diff --git a/pkg/operator/ceph/cluster/mgr/dashboard.go b/pkg/operator/ceph/cluster/mgr/dashboard.go index 4d8441c43..7f0d68977 100644 --- a/pkg/operator/ceph/cluster/mgr/dashboard.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard.go @@ -88,11 +88,12 @@ func (c *Cluster) configureDashboardModules() error { return nil } - hasChanged, err := c.initializeSecureDashboard() + err := c.initializeSecureDashboard() if err != nil { return errors.Wrap(err, "failed to initialize dashboard") } + var hasChanged bool for _, daemonID := range c.getDaemonIDs() { changed, err := c.configureDashboardModuleSettings(daemonID) if err != nil { @@ -148,30 +149,33 @@ func (c *Cluster) configureDashboardModuleSettings(daemonID string) (bool, error return hasChanged, nil } -func (c *Cluster) initializeSecureDashboard() (bool, error) { +func (c *Cluster) initializeSecureDashboard() error { // we need to wait a short period after enabling the module before we can call the `ceph dashboard` commands. time.Sleep(dashboardInitWaitTime) password, err := c.getOrGenerateDashboardPassword() if err != nil { - return false, errors.Wrap(err, "failed to generate a password for the ceph dashboard") + return errors.Wrap(err, "failed to generate a password for the ceph dashboard") } if c.spec.Dashboard.SSL { alreadyCreated, err := c.createSelfSignedCert() if err != nil { - return false, errors.Wrap(err, "failed to create a self signed cert for the ceph dashboard") + return errors.Wrap(err, "failed to create a self signed cert for the ceph dashboard") } if alreadyCreated { - return false, nil + return nil + } + if err := c.restartMgrModule(dashboardModuleName); err != nil { + logger.Warningf("failed to restart dashboard after generating ssl cert. %v", err) } } if err := c.setLoginCredentials(password); err != nil { - return false, errors.Wrap(err, "failed to set login credentials for the ceph dashboard") + return errors.Wrap(err, "failed to set login credentials for the ceph dashboard") } - return false, nil + return nil } func (c *Cluster) createSelfSignedCert() (bool, error) { diff --git a/pkg/operator/ceph/cluster/mgr/dashboard_test.go b/pkg/operator/ceph/cluster/mgr/dashboard_test.go index 965be9a6e..6c86fa602 100644 --- a/pkg/operator/ceph/cluster/mgr/dashboard_test.go +++ b/pkg/operator/ceph/cluster/mgr/dashboard_test.go @@ -136,8 +136,8 @@ func TestStartSecureDashboard(t *testing.T) { err = c.configureDashboardModules() assert.NoError(t, err) // the dashboard is enabled once with the new dashboard and modules - assert.Equal(t, 2, enables) - assert.Equal(t, 1, disables) + assert.Equal(t, 3, enables) + assert.Equal(t, 2, disables) assert.Equal(t, 2, moduleRetries) svc, err := c.context.Clientset.CoreV1().Services(clusterInfo.Namespace).Get(ctx, "rook-ceph-mgr-dashboard", metav1.GetOptions{}) @@ -152,8 +152,8 @@ func TestStartSecureDashboard(t *testing.T) { assert.Nil(t, err) err = c.configureDashboardModules() assert.NoError(t, err) - assert.Equal(t, 2, enables) - assert.Equal(t, 2, disables) + assert.Equal(t, 3, enables) + assert.Equal(t, 3, disables) svc, err = c.context.Clientset.CoreV1().Services(clusterInfo.Namespace).Get(ctx, "rook-ceph-mgr-dashboard", metav1.GetOptions{}) assert.NotNil(t, err)