Merge pull request #12041 from rook/mergify/bp/release-1.11/pr-11932

mgr: failed to update the port of dashboard (backport #11932)
This commit is contained in:
Travis Nielsen authored and GitHub committed 2023-04-06 09:03:24 -06:00
commit 2b8b2c019a
2 files changed
+15 -11

No files matched your search

+11 -7
View File
@@ -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) {
@@ -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)