Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore unknown resource version in scaler error #51962

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions pkg/kubectl/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ type ScaleError struct {
}

func (c ScaleError) Error() string {
return fmt.Sprintf(
"Scaling the resource failed with: %v; Current resource version %s",
c.ActualError, c.ResourceVersion)
msg := fmt.Sprintf("Scaling the resource failed with: %v", c.ActualError)
if len(c.ResourceVersion) > 0 {
msg += fmt.Sprintf("; Current resource version %s", c.ResourceVersion)
}
return msg
}

// RetryParams encapsulates the retry parameters used by kubectl's scaler.
Expand Down Expand Up @@ -169,7 +171,7 @@ type ReplicationControllerScaler struct {
func (scaler *ReplicationControllerScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
controller, err := scaler.c.ReplicationControllers(namespace).Get(name, metav1.GetOptions{})
if err != nil {
return "", ScaleError{ScaleGetFailure, "Unknown", err}
return "", ScaleError{ScaleGetFailure, "", err}
}
if preconditions != nil {
if err := preconditions.ValidateReplicationController(controller); err != nil {
Expand Down Expand Up @@ -267,7 +269,7 @@ type ReplicaSetScaler struct {
func (scaler *ReplicaSetScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
rs, err := scaler.c.ReplicaSets(namespace).Get(name, metav1.GetOptions{})
if err != nil {
return "", ScaleError{ScaleGetFailure, "Unknown", err}
return "", ScaleError{ScaleGetFailure, "", err}
}
if preconditions != nil {
if err := preconditions.ValidateReplicaSet(rs); err != nil {
Expand Down Expand Up @@ -338,7 +340,7 @@ type StatefulSetScaler struct {
func (scaler *StatefulSetScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
ss, err := scaler.c.StatefulSets(namespace).Get(name, metav1.GetOptions{})
if err != nil {
return "", ScaleError{ScaleGetFailure, "Unknown", err}
return "", ScaleError{ScaleGetFailure, "", err}
}
if preconditions != nil {
if err := preconditions.ValidateStatefulSet(ss); err != nil {
Expand Down Expand Up @@ -391,7 +393,7 @@ type JobScaler struct {
func (scaler *JobScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
job, err := scaler.c.Jobs(namespace).Get(name, metav1.GetOptions{})
if err != nil {
return "", ScaleError{ScaleGetFailure, "Unknown", err}
return "", ScaleError{ScaleGetFailure, "", err}
}
if preconditions != nil {
if err := preconditions.ValidateJob(job); err != nil {
Expand Down Expand Up @@ -460,7 +462,7 @@ type DeploymentScaler struct {
func (scaler *DeploymentScaler) ScaleSimple(namespace, name string, preconditions *ScalePrecondition, newSize uint) (string, error) {
deployment, err := scaler.c.Deployments(namespace).Get(name, metav1.GetOptions{})
if err != nil {
return "", ScaleError{ScaleGetFailure, "Unknown", err}
return "", ScaleError{ScaleGetFailure, "", err}
}
if preconditions != nil {
if err := preconditions.ValidateDeployment(deployment); err != nil {
Expand Down