From a7bef87c53ce9a223377c2e2f30b7858279efe34 Mon Sep 17 00:00:00 2001 From: Deepthi Devaki Akkoorath Date: Thu, 14 Mar 2024 11:23:59 +0100 Subject: [PATCH] feat: allow waiting for pending changes when changeId is unknown --- go-chaos/cmd/cluster.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/go-chaos/cmd/cluster.go b/go-chaos/cmd/cluster.go index eeaa901fe..26f5b3c11 100644 --- a/go-chaos/cmd/cluster.go +++ b/go-chaos/cmd/cluster.go @@ -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") @@ -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: