Skip to content

Commit

Permalink
Merge branch 'master' into localtest
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Apr 14, 2024
2 parents a11e7fe + 2bc07a8 commit fbbc756
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
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

0 comments on commit fbbc756

Please sign in to comment.