From 13290b901dd495f6681e1c664c719ef0abb2ab81 Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Mon, 22 Feb 2021 14:24:43 +0000 Subject: [PATCH 01/11] Initial attempt at status command Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/cmd.go | 2 + .../cmd/status/status.go | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 pkg/kubectl-argo-rollouts/cmd/status/status.go diff --git a/pkg/kubectl-argo-rollouts/cmd/cmd.go b/pkg/kubectl-argo-rollouts/cmd/cmd.go index 7426b3c1b2..f6762b96c1 100644 --- a/pkg/kubectl-argo-rollouts/cmd/cmd.go +++ b/pkg/kubectl-argo-rollouts/cmd/cmd.go @@ -13,6 +13,7 @@ import ( "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/restart" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/retry" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/set" + "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/status" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/terminate" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/undo" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/cmd/version" @@ -64,5 +65,6 @@ func NewCmdArgoRollouts(o *options.ArgoRolloutsOptions) *cobra.Command { cmd.AddCommand(terminate.NewCmdTerminate(o)) cmd.AddCommand(set.NewCmdSet(o)) cmd.AddCommand(undo.NewCmdUndo(o)) + cmd.AddCommand(status.NewCmdStatus(o)) return cmd } diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go new file mode 100644 index 0000000000..7b40ce4c89 --- /dev/null +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -0,0 +1,62 @@ +package status + +import ( + "context" + "fmt" + + "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/info" + "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/options" + "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/viewcontroller" + "github.com/spf13/cobra" +) + +const ( + statusExample = `` + statusUsage = `` + statusUsageCommon = `` +) + +type StatusOptions struct { + Watch bool + + options.ArgoRolloutsOptions +} + +// NewCmdStatus returns a new instance of an `rollouts status` command +func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { + statusOptions := StatusOptions{ + ArgoRolloutsOptions: *o, + } + + var cmd = &cobra.Command{ + Use: "status ROLLOUT_NAME", + Short: "", + Long: "", + Example: "", + SilenceUsage: true, + RunE: func(c *cobra.Command, args []string) error { + if len(args) != 1 { + return o.UsageErr(c) + } + name := args[0] + controller := viewcontroller.NewRolloutViewController(o.Namespace(), name, statusOptions.KubeClientset(), statusOptions.RolloutsClientset()) + ctx := context.Background() + controller.Start(ctx) + + ri, err := controller.GetRolloutInfo() + if err != nil { + return err + } + + statusOptions.PrintStatus(ri) + + return nil + }, + } + cmd.Flags().BoolVarP(&statusOptions.Watch, "watch", "w", false, "Watch the status of the rollout until it's done") + return cmd +} + +func (o *StatusOptions) PrintStatus(roInfo *info.RolloutInfo) { + fmt.Println(roInfo.Status) +} From 003b0959ef1486f03f365386b4ef13733122c228 Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Tue, 23 Feb 2021 12:16:32 +0000 Subject: [PATCH 02/11] Add watch support to status command Signed-off-by: Pedro Arvela --- .../cmd/status/status.go | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 7b40ce4c89..53bab188b6 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -3,6 +3,7 @@ package status import ( "context" "fmt" + "time" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/info" "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/options" @@ -40,7 +41,8 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { } name := args[0] controller := viewcontroller.NewRolloutViewController(o.Namespace(), name, statusOptions.KubeClientset(), statusOptions.RolloutsClientset()) - ctx := context.Background() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() controller.Start(ctx) ri, err := controller.GetRolloutInfo() @@ -48,7 +50,17 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { return err } - statusOptions.PrintStatus(ri) + if !statusOptions.Watch { + fmt.Println(ri.Status) + } else { + rolloutUpdates := make(chan *info.RolloutInfo) + defer close(rolloutUpdates) + controller.RegisterCallback(func(roInfo *info.RolloutInfo) { + rolloutUpdates <- roInfo + }) + go statusOptions.WatchStatus(ctx.Done(), cancel, rolloutUpdates) + controller.Run(ctx) + } return nil }, @@ -57,6 +69,27 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { return cmd } -func (o *StatusOptions) PrintStatus(roInfo *info.RolloutInfo) { - fmt.Println(roInfo.Status) +func (o *StatusOptions) WatchStatus(stopCh <-chan struct{}, cancelFunc context.CancelFunc, rolloutUpdates chan *info.RolloutInfo) { + ticker := time.NewTicker(time.Second) + var roInfo *info.RolloutInfo + var preventFlicker time.Time + + for { + select { + case roInfo = <-rolloutUpdates: + case <-ticker.C: + case <-stopCh: + return + } + if roInfo != nil && time.Now().After(preventFlicker.Add(200*time.Millisecond)) { + fmt.Printf("%s - %s\n", roInfo.Status, roInfo.Message) + + if roInfo.Status == "Healthy" || roInfo.Status == "Degraded" { + cancelFunc() + return + } + + preventFlicker = time.Now() + } + } } From 00afc56d743eb882ec96220dc04cf3b83776eb33 Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Tue, 23 Feb 2021 15:06:30 +0000 Subject: [PATCH 03/11] Fail the command if the rollout is broken Signed-off-by: Pedro Arvela --- .../cmd/status/status.go | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 53bab188b6..73db318efa 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -60,6 +60,15 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { }) go statusOptions.WatchStatus(ctx.Done(), cancel, rolloutUpdates) controller.Run(ctx) + + finalRi, err := controller.GetRolloutInfo() + if err != nil { + return err + } + + if finalRi.Status == "Degraded" { + return fmt.Errorf("The rollout is in degraded state with message: %s", finalRi.Message) + } } return nil @@ -77,19 +86,18 @@ func (o *StatusOptions) WatchStatus(stopCh <-chan struct{}, cancelFunc context.C for { select { case roInfo = <-rolloutUpdates: - case <-ticker.C: - case <-stopCh: - return - } - if roInfo != nil && time.Now().After(preventFlicker.Add(200*time.Millisecond)) { - fmt.Printf("%s - %s\n", roInfo.Status, roInfo.Message) - - if roInfo.Status == "Healthy" || roInfo.Status == "Degraded" { + if roInfo != nil && roInfo.Status == "Healthy" || roInfo.Status == "Degraded" { + fmt.Println(roInfo.Status) cancelFunc() return } - - preventFlicker = time.Now() + if roInfo != nil && time.Now().After(preventFlicker.Add(200*time.Millisecond)) { + fmt.Printf("%s - %s\n", roInfo.Status, roInfo.Message) + preventFlicker = time.Now() + } + case <-ticker.C: + case <-stopCh: + return } } } From 67389c8e7ad85cf3287b369cd5320af7e6a231bc Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Tue, 23 Feb 2021 15:46:31 +0000 Subject: [PATCH 04/11] Add timeout to status command Signed-off-by: Pedro Arvela --- .../cmd/status/status.go | 50 +++++++++++++------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 73db318efa..0154f4e608 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -12,13 +12,21 @@ import ( ) const ( - statusExample = `` - statusUsage = `` - statusUsageCommon = `` + statusLong = `Watch the progress of a rollout until it is done. The return will be success if +the Rollout ends as Healthy and error if the Rollout ends degraded or if the +timeout is hit before the progress finishes.` + statusExample = ` + # Watch the rollout until it succeeds + %[1]s status gestbook + + # Watch the rollout until it succeeds, fail if it takes more than 60 seconds + %[1]s status --timeout 60 guestbook + ` ) type StatusOptions struct { - Watch bool + Watch bool + Timeout int64 options.ArgoRolloutsOptions } @@ -31,9 +39,9 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { var cmd = &cobra.Command{ Use: "status ROLLOUT_NAME", - Short: "", - Long: "", - Example: "", + Short: "Show the status of a rollout.", + Long: statusLong, + Example: o.Example(statusExample), SilenceUsage: true, RunE: func(c *cobra.Command, args []string) error { if len(args) != 1 { @@ -51,14 +59,14 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { } if !statusOptions.Watch { - fmt.Println(ri.Status) + fmt.Fprintln(o.Out, ri.Status) } else { rolloutUpdates := make(chan *info.RolloutInfo) defer close(rolloutUpdates) controller.RegisterCallback(func(roInfo *info.RolloutInfo) { rolloutUpdates <- roInfo }) - go statusOptions.WatchStatus(ctx.Done(), cancel, rolloutUpdates) + go statusOptions.WatchStatus(ctx.Done(), cancel, statusOptions.Timeout, rolloutUpdates) controller.Run(ctx) finalRi, err := controller.GetRolloutInfo() @@ -68,36 +76,48 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { if finalRi.Status == "Degraded" { return fmt.Errorf("The rollout is in degraded state with message: %s", finalRi.Message) + } else if finalRi.Status != "Healthy" { + return fmt.Errorf("The rollout progress did not finish within the specified timeout") } } return nil }, } - cmd.Flags().BoolVarP(&statusOptions.Watch, "watch", "w", false, "Watch the status of the rollout until it's done") + cmd.Flags().BoolVarP(&statusOptions.Watch, "watch", "w", true, "Watch the status of the rollout until it's done") + cmd.Flags().Int64VarP(&statusOptions.Timeout, "timeout", "t", 300, "The length of time in seconds to wait before ending watch, zero means never.") return cmd } -func (o *StatusOptions) WatchStatus(stopCh <-chan struct{}, cancelFunc context.CancelFunc, rolloutUpdates chan *info.RolloutInfo) { - ticker := time.NewTicker(time.Second) +func (o *StatusOptions) WatchStatus(stopCh <-chan struct{}, cancelFunc context.CancelFunc, timeoutSeconds int64, rolloutUpdates chan *info.RolloutInfo) { + timeout := make(chan bool) var roInfo *info.RolloutInfo var preventFlicker time.Time + if timeoutSeconds != 0 { + go func() { + time.Sleep(time.Duration(timeoutSeconds) * time.Second) + timeout <- true + }() + } + for { select { case roInfo = <-rolloutUpdates: if roInfo != nil && roInfo.Status == "Healthy" || roInfo.Status == "Degraded" { - fmt.Println(roInfo.Status) + fmt.Fprintln(o.Out, roInfo.Status) cancelFunc() return } if roInfo != nil && time.Now().After(preventFlicker.Add(200*time.Millisecond)) { - fmt.Printf("%s - %s\n", roInfo.Status, roInfo.Message) + fmt.Fprintf(o.Out, "%s - %s\n", roInfo.Status, roInfo.Message) preventFlicker = time.Now() } - case <-ticker.C: case <-stopCh: return + case <-timeout: + cancelFunc() + return } } } From 87e4898f1cf2b3eef1a3d074fccc48da3050991f Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Thu, 25 Feb 2021 12:21:08 +0000 Subject: [PATCH 05/11] Add tests for status command Signed-off-by: Pedro Arvela --- .../cmd/status/status_test.go | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 pkg/kubectl-argo-rollouts/cmd/status/status_test.go diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status_test.go b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go new file mode 100644 index 0000000000..abb7c95edb --- /dev/null +++ b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go @@ -0,0 +1,143 @@ +package status + +import ( + "bytes" + "testing" + + "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/info/testdata" + options "github.com/argoproj/argo-rollouts/pkg/kubectl-argo-rollouts/options/fake" + "github.com/stretchr/testify/assert" +) + +const noWatch = "--watch=false" + +func TestStatusUsage(t *testing.T) { + tf, o := options.NewFakeArgoRolloutsOptions() + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{}) + err := cmd.Execute() + + assert.Error(t, err) +} + +func TestStatusRolloutNotFound(t *testing.T) { + tf, o := options.NewFakeArgoRolloutsOptions() + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{"does-not-exist", noWatch}) + err := cmd.Execute() + + assert.Error(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Empty(t, stdout) + assert.Equal(t, "Error: rollout.argoproj.io \"does-not-exist\" not found\n", stderr) +} + +func TestWatchStatusRolloutNotFound(t *testing.T) { + tf, o := options.NewFakeArgoRolloutsOptions() + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{"does-not-exist"}) + err := cmd.Execute() + + assert.Error(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Empty(t, stdout) + assert.Equal(t, "Error: rollout.argoproj.io \"does-not-exist\" not found\n", stderr) +} + +func TestStatusBlueGreenRollout(t *testing.T) { + rolloutObjs := testdata.NewBlueGreenRollout() + + tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...) + o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace) + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name, noWatch}) + err := cmd.Execute() + + assert.NoError(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Equal(t, "Paused\n", stdout) + assert.Empty(t, stderr) +} + +func TestStatusInvalidRollout(t *testing.T) { + rolloutObjs := testdata.NewInvalidRollout() + + tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...) + o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace) + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name, noWatch}) + err := cmd.Execute() + + assert.NoError(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Equal(t, "Degraded\n", stdout) + assert.Empty(t, stderr) +} + +func TestStatusAbortedRollout(t *testing.T) { + rolloutObjs := testdata.NewAbortedRollout() + + tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...) + o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace) + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name, noWatch}) + err := cmd.Execute() + + assert.NoError(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Equal(t, "Degraded\n", stdout) + assert.Empty(t, stderr) +} + +func TestWatchAbortedRollout(t *testing.T) { + rolloutObjs := testdata.NewAbortedRollout() + + tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...) + o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace) + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name}) + err := cmd.Execute() + + assert.Error(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Equal(t, "Degraded\n", stdout) + assert.Equal(t, "Error: The rollout is in degraded state with message: RolloutAborted: metric \"web\" assessed Failed due to failed (1) > failureLimit (0)\n", stderr) +} + +func TestWatchTimeoutRollout(t *testing.T) { + rolloutObjs := testdata.NewBlueGreenRollout() + + tf, o := options.NewFakeArgoRolloutsOptions(rolloutObjs.AllObjects()...) + o.RESTClientGetter = tf.WithNamespace(rolloutObjs.Rollouts[0].Namespace) + defer tf.Cleanup() + cmd := NewCmdStatus(o) + cmd.PersistentPreRunE = o.PersistentPreRunE + cmd.SetArgs([]string{rolloutObjs.Rollouts[0].Name, "--timeout=1"}) + err := cmd.Execute() + + assert.Error(t, err) + stdout := o.Out.(*bytes.Buffer).String() + stderr := o.ErrOut.(*bytes.Buffer).String() + assert.Equal(t, "Paused - BlueGreenPause\n", stdout) + assert.Equal(t, "Error: The rollout progress did not finish within the specified timeout\n", stderr) +} From 23d50a6c0bf294e6f488c0bacf328e2ab63515d0 Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Fri, 26 Feb 2021 12:37:10 +0000 Subject: [PATCH 06/11] Update message strings Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 8 ++++---- pkg/kubectl-argo-rollouts/cmd/status/status_test.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 0154f4e608..af7010d8b3 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -31,7 +31,7 @@ type StatusOptions struct { options.ArgoRolloutsOptions } -// NewCmdStatus returns a new instance of an `rollouts status` command +// NewCmdStatus returns a new instance of a `rollouts status` command func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { statusOptions := StatusOptions{ ArgoRolloutsOptions: *o, @@ -75,9 +75,9 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { } if finalRi.Status == "Degraded" { - return fmt.Errorf("The rollout is in degraded state with message: %s", finalRi.Message) + return fmt.Errorf("The rollout is in a degraded state with message: %s", finalRi.Message) } else if finalRi.Status != "Healthy" { - return fmt.Errorf("The rollout progress did not finish within the specified timeout") + return fmt.Errorf("Timeout reached before rollout completed") } } @@ -85,7 +85,7 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { }, } cmd.Flags().BoolVarP(&statusOptions.Watch, "watch", "w", true, "Watch the status of the rollout until it's done") - cmd.Flags().Int64VarP(&statusOptions.Timeout, "timeout", "t", 300, "The length of time in seconds to wait before ending watch, zero means never.") + cmd.Flags().Int64VarP(&statusOptions.Timeout, "timeout", "t", 300, "The length of time in seconds to watch before giving up, zero means wait forever") return cmd } diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status_test.go b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go index abb7c95edb..eb01fa22ab 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status_test.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go @@ -121,7 +121,7 @@ func TestWatchAbortedRollout(t *testing.T) { stdout := o.Out.(*bytes.Buffer).String() stderr := o.ErrOut.(*bytes.Buffer).String() assert.Equal(t, "Degraded\n", stdout) - assert.Equal(t, "Error: The rollout is in degraded state with message: RolloutAborted: metric \"web\" assessed Failed due to failed (1) > failureLimit (0)\n", stderr) + assert.Equal(t, "Error: The rollout is in a degraded state with message: RolloutAborted: metric \"web\" assessed Failed due to failed (1) > failureLimit (0)\n", stderr) } func TestWatchTimeoutRollout(t *testing.T) { @@ -139,5 +139,5 @@ func TestWatchTimeoutRollout(t *testing.T) { stdout := o.Out.(*bytes.Buffer).String() stderr := o.ErrOut.(*bytes.Buffer).String() assert.Equal(t, "Paused - BlueGreenPause\n", stdout) - assert.Equal(t, "Error: The rollout progress did not finish within the specified timeout\n", stderr) + assert.Equal(t, "Error: Timeout reached before rollout completed\n", stderr) } From 1e1e1ef54cef34d87a4007b049c1b9368dece2cd Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Fri, 26 Feb 2021 12:42:41 +0000 Subject: [PATCH 07/11] Update status command long description Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index af7010d8b3..7affdf89d2 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -12,9 +12,8 @@ import ( ) const ( - statusLong = `Watch the progress of a rollout until it is done. The return will be success if -the Rollout ends as Healthy and error if the Rollout ends degraded or if the -timeout is hit before the progress finishes.` + statusLong = `Watch rollout until it finishes or the specified timeout is exceeded. Returns +success if the rollout is healthy upon completion and an error otherwise.` statusExample = ` # Watch the rollout until it succeeds %[1]s status gestbook From 8463edc6525f1107bfef8c24ee68322a19c8a37a Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Fri, 26 Feb 2021 12:59:18 +0000 Subject: [PATCH 08/11] Remove specified from timeout Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 7affdf89d2..77443f0f12 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -12,8 +12,8 @@ import ( ) const ( - statusLong = `Watch rollout until it finishes or the specified timeout is exceeded. Returns -success if the rollout is healthy upon completion and an error otherwise.` + statusLong = `Watch rollout until it finishes or the timeout is exceeded. Returns success if +the rollout is healthy upon completion and an error otherwise.` statusExample = ` # Watch the rollout until it succeeds %[1]s status gestbook From e307e02bcc982d1e4db53ecee63a11605c7f626a Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Mon, 1 Mar 2021 11:30:17 +0000 Subject: [PATCH 09/11] Update status timeout error Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 2 +- pkg/kubectl-argo-rollouts/cmd/status/status_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 77443f0f12..bbfffa67e4 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -76,7 +76,7 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { if finalRi.Status == "Degraded" { return fmt.Errorf("The rollout is in a degraded state with message: %s", finalRi.Message) } else if finalRi.Status != "Healthy" { - return fmt.Errorf("Timeout reached before rollout completed") + return fmt.Errorf("Rollout progress exceeded timeout") } } diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status_test.go b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go index eb01fa22ab..bb8130b0e0 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status_test.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status_test.go @@ -139,5 +139,5 @@ func TestWatchTimeoutRollout(t *testing.T) { stdout := o.Out.(*bytes.Buffer).String() stderr := o.ErrOut.(*bytes.Buffer).String() assert.Equal(t, "Paused - BlueGreenPause\n", stdout) - assert.Equal(t, "Error: Timeout reached before rollout completed\n", stderr) + assert.Equal(t, "Error: Rollout progress exceeded timeout\n", stderr) } From 4039f9f064f59b83430821f7bb539c7c27a5c10b Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Mon, 1 Mar 2021 17:31:18 +0000 Subject: [PATCH 10/11] Fix status command help typos Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index bbfffa67e4..18da698802 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -16,7 +16,7 @@ const ( the rollout is healthy upon completion and an error otherwise.` statusExample = ` # Watch the rollout until it succeeds - %[1]s status gestbook + %[1]s status guestbook # Watch the rollout until it succeeds, fail if it takes more than 60 seconds %[1]s status --timeout 60 guestbook @@ -38,7 +38,7 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { var cmd = &cobra.Command{ Use: "status ROLLOUT_NAME", - Short: "Show the status of a rollout.", + Short: "Show the status of a rollout", Long: statusLong, Example: o.Example(statusExample), SilenceUsage: true, From 3f754e862ca05c2a1fdbd734b4b06d8cdfacc655 Mon Sep 17 00:00:00 2001 From: Pedro Arvela Date: Mon, 22 Mar 2021 10:53:08 +0000 Subject: [PATCH 11/11] Fix default to match official kubectl command Signed-off-by: Pedro Arvela --- pkg/kubectl-argo-rollouts/cmd/status/status.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kubectl-argo-rollouts/cmd/status/status.go b/pkg/kubectl-argo-rollouts/cmd/status/status.go index 18da698802..f92f231e65 100644 --- a/pkg/kubectl-argo-rollouts/cmd/status/status.go +++ b/pkg/kubectl-argo-rollouts/cmd/status/status.go @@ -84,7 +84,7 @@ func NewCmdStatus(o *options.ArgoRolloutsOptions) *cobra.Command { }, } cmd.Flags().BoolVarP(&statusOptions.Watch, "watch", "w", true, "Watch the status of the rollout until it's done") - cmd.Flags().Int64VarP(&statusOptions.Timeout, "timeout", "t", 300, "The length of time in seconds to watch before giving up, zero means wait forever") + cmd.Flags().Int64VarP(&statusOptions.Timeout, "timeout", "t", 0, "The length of time in seconds to watch before giving up, zero means wait forever") return cmd }