Skip to content

Commit

Permalink
Return error ResourceExpired when cancelling non-running jobs(#431)
Browse files Browse the repository at this point in the history
Returning this K8s api error type ensures that external systems (ie. Flyte) will not keep retrying the cancellation of a job.
  • Loading branch information
Barnabas Kutassy authored Jun 27, 2022
1 parent 8651a33 commit 70fc6b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apis/flinkcluster/v1beta1/flinkcluster_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/hashicorp/go-version"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -149,7 +150,7 @@ func (v *Validator) checkControlAnnotations(old *FlinkCluster, new *FlinkCluster
if old.Spec.Job == nil {
return fmt.Errorf(SessionClusterWarnMsg, ControlNameJobCancel, ControlAnnotation)
} else if job == nil || job.IsTerminated(old.Spec.Job) {
return fmt.Errorf(InvalidJobStateForJobCancelMsg, ControlAnnotation)
return errors.NewResourceExpired(fmt.Sprintf(InvalidJobStateForJobCancelMsg, ControlAnnotation))
}
case ControlNameSavepoint:
var job = old.Status.Components.Job
Expand Down

0 comments on commit 70fc6b7

Please sign in to comment.