Skip to content

Commit 70fc6b7

Browse files
author
Barnabas Kutassy
authored
Return error ResourceExpired when cancelling non-running jobs(#431)
Returning this K8s api error type ensures that external systems (ie. Flyte) will not keep retrying the cancellation of a job.
1 parent 8651a33 commit 70fc6b7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

apis/flinkcluster/v1beta1/flinkcluster_validate.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"time"
2626

2727
"github.com/hashicorp/go-version"
28+
"k8s.io/apimachinery/pkg/api/errors"
2829
"k8s.io/apimachinery/pkg/api/resource"
2930

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

0 commit comments

Comments
 (0)