Skip to content

Commit

Permalink
mgr: adding logic to keep retrying in case mgr config delete fails
Browse files Browse the repository at this point in the history
we dont set removeMgrDaemonConfiguration to true unless all the
delete operations went successfull.

Signed-off-by: Redouane Kachach <rkachach@redhat.com>
  • Loading branch information
rkachach committed Jan 25, 2024
1 parent 57e3937 commit 39c06d2
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
47 changes: 36 additions & 11 deletions pkg/operator/ceph/cluster/mgr/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,41 @@ func (c *Cluster) configureDashboardModules() error {
return nil
}

// Delete the manager per-daemon configuration. Returns true
// if all the configuration entries have been delete successfully.
func (c *Cluster) deleteManagerDaemonConfiguration() bool {

mgrKeysToDelete := []string{
"mgr/dashboard/url_prefix",
"mgr/dashboard/ssl",
"mgr/dashboard/PROMETHEUS_API_HOST",
"mgr/dashboard/PROMETHEUS_API_SSL_VERIFY",
"mgr/dashboard/server_port",
"mgr/dashboard/ssl_server_port",
}

success := true
monStore := config.GetMonStore(c.context, c.clusterInfo)
for _, daemonID := range c.getDaemonIDs() {
mgrDaemonID := fmt.Sprintf("%s.%s", config.MgrType, daemonID)
for _, key := range mgrKeysToDelete {
err := monStore.Delete(mgrDaemonID, key)
if err != nil {
logger.Errorf("failed to delete configuration entry %q %q, err: %v", mgrDaemonID, key, err)
success = false
}
}
}

if success {
logger.Info("All per-daemon mgr configuration has been deleted successfully.")
} else {
logger.Error("At least one delete operation failed while trying to delete per-daemon mgr configuration.")
}

return success
}

func (c *Cluster) configureDashboardModuleSettings() (bool, error) {

monStore := config.GetMonStore(c.context, c.clusterInfo)
Expand Down Expand Up @@ -158,17 +193,7 @@ func (c *Cluster) configureDashboardModuleSettings() (bool, error) {

// Remove any existing per mgr-daemon configuration
if removeMgrDaemonConfiguration {
logger.Info("Removing any previous per mgr-daemon configuration")
for _, daemonID := range c.getDaemonIDs() {
mgrDaemonID := fmt.Sprintf("%s.%s", config.MgrType, daemonID)
monStore.Delete(mgrDaemonID, "mgr/dashboard/url_prefix")
monStore.Delete(mgrDaemonID, "mgr/dashboard/ssl")
monStore.Delete(mgrDaemonID, "mgr/dashboard/PROMETHEUS_API_HOST")
monStore.Delete(mgrDaemonID, "mgr/dashboard/PROMETHEUS_API_SSL_VERIFY")
monStore.Delete(mgrDaemonID, "mgr/dashboard/server_port")
monStore.Delete(mgrDaemonID, "mgr/dashboard/ssl_server_port")
}
removeMgrDaemonConfiguration = false
removeMgrDaemonConfiguration = !c.deleteManagerDaemonConfiguration()
}

return hasChanged, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/ceph/config/monstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (m *MonStore) Set(who, option, value string) error {

// Delete a config in the centralized mon configuration database.
func (m *MonStore) Delete(who, option string) error {
logger.Infof("deleting %q option from the mon configuration database", option)
logger.Infof("deleting %q %q option from the mon configuration database", who, option)
args := []string{"config", "rm", who, normalizeKey(option)}
cephCmd := client.NewCephCommand(m.context, m.clusterInfo, args)
out, err := cephCmd.RunWithTimeout(exec.CephCommandsTimeout)
Expand Down

0 comments on commit 39c06d2

Please sign in to comment.