Skip to content

Commit

Permalink
feat: allow waiting for pending changes when changeId is unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
deepthidevaki committed Mar 14, 2024
1 parent bcba6d8 commit a7bef87
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion go-chaos/cmd/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func AddClusterCommands(rootCmd *cobra.Command, flags *Flags) {
clusterCommand.AddCommand(waitCommand)
clusterCommand.AddCommand(forceFailoverCommand)
waitCommand.Flags().Int64Var(&flags.changeId, "changeId", 0, "The id of the change to wait for")
waitCommand.MarkFlagRequired("changeId")
clusterCommand.AddCommand(scaleCommand)
scaleCommand.Flags().IntVar(&flags.brokers, "brokers", 0, "The amount of brokers to scale to")
scaleCommand.Flags().Int32Var(&flags.replicationFactor, "replicationFactor", -1, "The new replication factor")
Expand Down Expand Up @@ -219,6 +218,16 @@ func waitForChange(port int, changeId int64) error {
internal.LogInfo("Failed to query topology: %s", err)
continue
}
if changeId <= 0 {
if topology.PendingChange != nil {
changeId = topology.PendingChange.Id
} else if topology.LastChange != nil {
changeId = topology.LastChange.Id
} else {
internal.LogInfo("No change exists")
return nil
}
}
changeStatus := describeChangeStatus(topology, int64(changeId))
switch changeStatus {
case ChangeStatusCompleted:
Expand Down

0 comments on commit a7bef87

Please sign in to comment.