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.

Kubernetes-commit: fb3d9e3ac9d244047efa411e9e6ae162692ad79e
This commit is contained in:
Arda Güçlü 2022-10-13 11:45:42 +03:00 committed by Kubernetes Publisher
parent ef876e7ec2
commit 6b1e3be978
1 changed files with 2 additions and 2 deletions

View File

@ -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).