ceph: fix mgr - dashboard settings
This fix passes on the mgrName to the configureDashboard function. Signed-off-by: Maximilian Mack <max@mack.io>
This commit is contained in:
4 files changed
+29
-28
No files matched your search
@@ -34,11 +34,6 @@ func MgrDisableModule(context *clusterd.Context, clusterName, name string) error
|
||||
return enableModule(context, clusterName, name, false, "disable")
|
||||
}
|
||||
|
||||
// MgrSetAllConfig applies a setting for all mgr daemons
|
||||
func MgrSetAllConfig(context *clusterd.Context, clusterName string, cephVersion cephver.CephVersion, key, val string) (bool, error) {
|
||||
return MgrSetConfig(context, clusterName, "", cephVersion, key, val, false)
|
||||
}
|
||||
|
||||
// MgrSetConfig applies a setting for a single mgr daemon
|
||||
func MgrSetConfig(context *clusterd.Context, clusterName, mgrName string, cephVersion cephver.CephVersion, key, val string, force bool) (bool, error) {
|
||||
var getArgs, setArgs []string
|
||||
|
||||
@@ -52,13 +52,13 @@ func init() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
}
|
||||
|
||||
func (c *Cluster) configureDashboard(port int) error {
|
||||
func (c *Cluster) configureDashboard(m *mgrConfig) error {
|
||||
// enable or disable the dashboard module
|
||||
if err := c.toggleDashboardModule(port); err != nil {
|
||||
if err := c.toggleDashboardModule(m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dashboardService := c.makeDashboardService(appName, port)
|
||||
dashboardService := c.makeDashboardService(appName, m.DashboardPort)
|
||||
if c.dashboard.Enabled {
|
||||
// expose the dashboard service
|
||||
if _, err := c.context.Clientset.CoreV1().Services(c.Namespace).Create(dashboardService); err != nil {
|
||||
@@ -70,9 +70,9 @@ func (c *Cluster) configureDashboard(port int) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get dashboard service. %+v", err)
|
||||
}
|
||||
if original.Spec.Ports[0].Port != int32(port) {
|
||||
if original.Spec.Ports[0].Port != int32(m.DashboardPort) {
|
||||
logger.Infof("dashboard port changed. updating service")
|
||||
original.Spec.Ports[0].Port = int32(port)
|
||||
original.Spec.Ports[0].Port = int32(m.DashboardPort)
|
||||
if _, err := c.context.Clientset.CoreV1().Services(c.Namespace).Update(original); err != nil {
|
||||
return fmt.Errorf("failed to update dashboard mgr service. %+v", err)
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (c *Cluster) configureDashboard(port int) error {
|
||||
}
|
||||
|
||||
// Ceph docs about the dashboard module: http://docs.ceph.com/docs/luminous/mgr/dashboard/
|
||||
func (c *Cluster) toggleDashboardModule(dashboardPort int) error {
|
||||
func (c *Cluster) toggleDashboardModule(m *mgrConfig) error {
|
||||
if c.dashboard.Enabled {
|
||||
if err := client.MgrEnableModule(c.context, c.Namespace, dashboardModuleName, true); err != nil {
|
||||
return fmt.Errorf("failed to enable mgr dashboard module. %+v", err)
|
||||
@@ -102,7 +102,7 @@ func (c *Cluster) toggleDashboardModule(dashboardPort int) error {
|
||||
return fmt.Errorf("failed to initialize dashboard. %+v", err)
|
||||
}
|
||||
|
||||
if err := c.configureDashboardModule(dashboardPort); err != nil {
|
||||
if err := c.configureDashboardModule(m); err != nil {
|
||||
return fmt.Errorf("failed to configure mgr dashboard module. %+v", err)
|
||||
}
|
||||
} else {
|
||||
@@ -113,16 +113,16 @@ func (c *Cluster) toggleDashboardModule(dashboardPort int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) configureDashboardModule(dashboardPort int) error {
|
||||
func (c *Cluster) configureDashboardModule(m *mgrConfig) error {
|
||||
// url prefix
|
||||
hasChanged, err := client.MgrSetAllConfig(c.context, c.Namespace, c.clusterInfo.CephVersion, "mgr/dashboard/url_prefix", c.dashboard.UrlPrefix)
|
||||
hasChanged, err := client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/url_prefix", c.dashboard.UrlPrefix, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// server port
|
||||
port := strconv.Itoa(dashboardPort)
|
||||
changed, err := client.MgrSetAllConfig(c.context, c.Namespace, c.clusterInfo.CephVersion, "mgr/dashboard/server_port", port)
|
||||
port := strconv.Itoa(m.DashboardPort)
|
||||
changed, err := client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/server_port", port, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func (c *Cluster) configureDashboardModule(dashboardPort int) error {
|
||||
} else {
|
||||
ssl = strconv.FormatBool(*c.dashboard.SSL)
|
||||
}
|
||||
changed, err = client.MgrSetAllConfig(c.context, c.Namespace, c.clusterInfo.CephVersion, "mgr/dashboard/ssl", ssl)
|
||||
changed, err = client.MgrSetConfig(c.context, c.Namespace, m.DaemonID, c.clusterInfo.CephVersion, "mgr/dashboard/ssl", ssl, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -104,9 +104,14 @@ func TestStartSecureDashboard(t *testing.T) {
|
||||
}
|
||||
return exitCodeResponse, false
|
||||
}
|
||||
mgrConfig := &mgrConfig{
|
||||
DaemonID: "a",
|
||||
ResourceName: "mgr",
|
||||
DashboardPort: dashboardPortHTTP,
|
||||
}
|
||||
|
||||
dashboardInitWaitTime = 0
|
||||
err := c.configureDashboard(dashboardPortHTTP)
|
||||
err := c.configureDashboard(mgrConfig)
|
||||
assert.Nil(t, err)
|
||||
// the dashboard is enabled, then disabled and enabled again to restart
|
||||
// it with the cert, and another restart when setting the dashboard port
|
||||
@@ -120,7 +125,7 @@ func TestStartSecureDashboard(t *testing.T) {
|
||||
|
||||
// disable the dashboard
|
||||
c.dashboard.Enabled = false
|
||||
err = c.configureDashboard(dashboardPortHTTP)
|
||||
err = c.configureDashboard(mgrConfig)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, 3, enables)
|
||||
assert.Equal(t, 3, disables)
|
||||
|
||||
@@ -141,18 +141,19 @@ func (c *Cluster) Start() error {
|
||||
return fmt.Errorf("failed to update mgr deployment %s. %+v", resourceName, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.configureOrchestratorModules(); err != nil {
|
||||
logger.Errorf("failed to enable orchestrator modules. %+v", err)
|
||||
}
|
||||
if err := c.configureOrchestratorModules(); err != nil {
|
||||
logger.Errorf("failed to enable orchestrator modules. %+v", err)
|
||||
}
|
||||
|
||||
if err := c.enablePrometheusModule(c.Namespace); err != nil {
|
||||
logger.Errorf("failed to enable mgr prometheus module. %+v", err)
|
||||
}
|
||||
if err := c.enablePrometheusModule(c.Namespace); err != nil {
|
||||
logger.Errorf("failed to enable mgr prometheus module. %+v", err)
|
||||
}
|
||||
|
||||
if err := c.configureDashboard(mgrConfig); err != nil {
|
||||
logger.Errorf("failed to enable mgr dashboard. %+v", err)
|
||||
}
|
||||
|
||||
if err := c.configureDashboard(c.dashboardPort()); err != nil {
|
||||
logger.Errorf("failed to enable mgr dashboard. %+v", err)
|
||||
}
|
||||
|
||||
// create the metrics service
|
||||
|
||||
Reference in new issue
Block a user