From fb3d9e3ac9d244047efa411e9e6ae162692ad79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20G=C3=BC=C3=A7l=C3=BC?= Date: Thu, 13 Oct 2022 11:45:42 +0300 Subject: [PATCH] rollout restart: Change error message to more descriptive `rollout restart` command calculates patches according to the `kubectl.kubernetes.io/restartedAt` annotation whose time format is RFC3339. That is sufficient for users. However, if automated scripts execute `rollout restart` in multiple times within second, commands fails by returning an error "empty patch". This PR changes error message to more descriptive format to warn users that rollout restart does not work subsequent execution within second. --- staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart.go b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart.go index a7cc5bc762b..8a803a19b2d 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/rollout/rollout_restart.go @@ -18,7 +18,6 @@ package rollout import ( "fmt" - "github.com/spf13/cobra" "k8s.io/apimachinery/pkg/types" utilerrors "k8s.io/apimachinery/pkg/util/errors" @@ -183,7 +182,8 @@ func (o RestartOptions) RunRestart() error { } if string(patch.Patch) == "{}" || len(patch.Patch) == 0 { - allErrs = append(allErrs, fmt.Errorf("failed to create patch for %v: empty patch", info.Name)) + allErrs = append(allErrs, fmt.Errorf("failed to create patch for %v: if restart has already been triggered within the past second, please wait before attempting to trigger another", info.Name)) + continue } obj, err := resource.NewHelper(info.Client, info.Mapping).