From a8f2428105d71d16208a8a7e54e5d54bc29e6004 Mon Sep 17 00:00:00 2001 From: Soumik Majumder Date: Mon, 5 Feb 2024 16:47:41 +0530 Subject: [PATCH] Do not wait for App pause on package install pause if wait is disabled. Add wait flags to pkg i pause. Signed-off-by: Soumik Majumder --- cli/pkg/kctrl/cmd/package/installed/create_or_update.go | 3 +++ cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/cli/pkg/kctrl/cmd/package/installed/create_or_update.go b/cli/pkg/kctrl/cmd/package/installed/create_or_update.go index 4eeabdf6b..831854df7 100644 --- a/cli/pkg/kctrl/cmd/package/installed/create_or_update.go +++ b/cli/pkg/kctrl/cmd/package/installed/create_or_update.go @@ -920,6 +920,9 @@ func (o *CreateOrUpdateOptions) unpauseReconciliation(client kcclient.Interface) // TODO: Have common place for waiting logic and refactor based on // https://github.com/carvel-dev/kapp-controller/issues/639 func (o *CreateOrUpdateOptions) waitForAppPause(client kcclient.Interface) error { + if !o.WaitFlags.Enabled { + return nil + } if err := wait.Poll(o.WaitFlags.CheckInterval, o.WaitFlags.Timeout, func() (done bool, err error) { appResource, err := client.KappctrlV1alpha1().Apps(o.NamespaceFlags.Name).Get(context.Background(), o.Name, metav1.GetOptions{}) if err != nil { diff --git a/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go b/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go index f42c83303..d7e8bf4bd 100644 --- a/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go +++ b/cli/pkg/kctrl/cmd/package/installed/pause_or_kick.go @@ -65,6 +65,12 @@ func NewPauseCmd(o *PauseOrKickOptions, flagsFactory cmdcore.FlagsFactory) *cobr cmd.Use = "pause INSTALLED_PACKAGE_NAME" } + o.WaitFlags.Set(cmd, flagsFactory, &cmdcore.WaitFlagsOpts{ + AllowDisableWait: true, + DefaultInterval: 2 * time.Second, + DefaultTimeout: 5 * time.Minute, + }) + return cmd } @@ -228,6 +234,9 @@ func (o *PauseOrKickOptions) unpause(client kcclient.Interface) error { } func (o *PauseOrKickOptions) waitForAppPause(client kcclient.Interface) error { + if !o.WaitFlags.Enabled { + return nil + } if err := wait.Poll(o.WaitFlags.CheckInterval, o.WaitFlags.Timeout, func() (done bool, err error) { appResource, err := client.KappctrlV1alpha1().Apps(o.NamespaceFlags.Name).Get(context.Background(), o.Name, metav1.GetOptions{}) if err != nil {