Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return command status for set-config commands #52

Merged
merged 3 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deployment/aeroinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ func SetMigrateFillDelay(log logr.Logger, policy *aero.ClientPolicy, allHosts []

// SetConfigCommandsOnHosts runs set config command for dynamic config on all the given cluster nodes
func SetConfigCommandsOnHosts(log logr.Logger, policy *aero.ClientPolicy, allHosts, selectedHosts []*HostConn,
cmds []string) error {
cmds []string) ([]string, error) {
c, err := newCluster(log, policy, allHosts, selectedHosts)
if err != nil {
return fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
return nil, fmt.Errorf("unable to create a cluster copy for running aeroinfo: %v", err)
}

return c.setConfigCommandsOnHosts(cmds, selectedHosts)
Expand Down
15 changes: 9 additions & 6 deletions deployment/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ func (c *cluster) setMigrateFillDelay(migrateFillDelay int, hosts []*HostConn) e

cmd := fmt.Sprintf("set-config:context=service;migrate-fill-delay=%d", migrateFillDelay)

if err := c.setConfigCommandsOnHosts([]string{cmd}, hosts); err != nil {
if _, err := c.setConfigCommandsOnHosts([]string{cmd}, hosts); err != nil {
return err
}

Expand All @@ -862,8 +862,9 @@ func (c *cluster) setMigrateFillDelay(migrateFillDelay int, hosts []*HostConn) e
}

// setConfigCommandsOnHosts runs the set-config commands on the hosts.
func (c *cluster) setConfigCommandsOnHosts(cmds []string, hosts []*HostConn) error {
func (c *cluster) setConfigCommandsOnHosts(cmds []string, hosts []*HostConn) ([]string, error) {
hostIDs := getHostIDsFromHostConns(hosts)
succeededCmds := make([]string, 0, len(cmds))

log := c.log.WithValues("nodes", hostIDs)
log.V(1).Info("Running set-config")
Expand All @@ -872,26 +873,28 @@ func (c *cluster) setConfigCommandsOnHosts(cmds []string, hosts []*HostConn) err
for _, cmd := range cmds {
infoResults, iErr := c.infoOnHosts(hostIDs, cmd)
if iErr != nil {
return iErr
return succeededCmds, iErr
}

for id, info := range infoResults {
output, err := info.toString(cmd)
if err != nil {
return fmt.Errorf(
return succeededCmds, fmt.Errorf(
"ServerError: failed to execute set-config command %s on node %s: %v", cmd, id, err)
}

if !strings.EqualFold(output, "ok") {
return fmt.Errorf("ServerError: failed to execute set-config"+
return succeededCmds, fmt.Errorf("ServerError: failed to execute set-config"+
" command %s on node %s: %v", cmd, id, output)
}
}

succeededCmds = append(succeededCmds, cmd)
}

log.V(1).Info("Finished running set-config")

return nil
return succeededCmds, nil
}

func (c *cluster) findHost(hostID string) (*host, error) {
Expand Down
Loading