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

Expose job backoffLimit to users #678

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ spec:
afterJobFails: KeepCluster
afterJobCancelled: DeleteCluster
mode: Detached
backoffLimit: 0
flinkProperties:
taskmanager.numberOfTaskSlots: "1"
recreateOnUpdate: true
7 changes: 7 additions & 0 deletions apis/flinkcluster/v1beta1/flinkcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ type JobSpec struct {
// +kubebuilder:validation:Enum=Never;FromSavepointOnFailure
RestartPolicy *JobRestartPolicy `json:"restartPolicy,omitempty"`

// BackoffLimit limits the number of job pod restarts. This can happen when when the pod is kicked out of a node
// or when the RestartPolicy is set to Never and a container errors out
// default: `0`,
// 0 means no retry.
// +kubebuilder:default:=0
BackoffLimit *int32 `json:"backoffLimit,omitempty"`

// The action to take after job finishes.
// +kubebuilder:default:={afterJobSucceeds:DeleteCluster, afterJobFails:KeepCluster, afterJobCancelled:DeleteCluster}
CleanupPolicy *CleanupPolicy `json:"cleanupPolicy,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions apis/flinkcluster/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config/crd/bases/flinkoperator.k8s.io_flinkclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ spec:
autoSavepointSeconds:
format: int32
type: integer
backoffLimit:
default: 0
format: int32
type: integer
cancelRequested:
type: boolean
className:
Expand Down
2 changes: 0 additions & 2 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
Expand Down Expand Up @@ -26,7 +25,6 @@ webhooks:
resources:
- flinkclusters
sideEffects: None

---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
Expand Down
3 changes: 1 addition & 2 deletions controllers/flinkcluster/flinkcluster_converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const (
)

var (
backoffLimit int32 = 0
terminationGracePeriodSeconds int64 = 60
flinkSysProps = map[string]struct{}{
"jobmanager.rpc.address": {},
Expand Down Expand Up @@ -927,7 +926,7 @@ func newJob(flinkCluster *v1beta1.FlinkCluster) *batchv1.Job {
},
Spec: *podSpec,
},
BackoffLimit: &backoffLimit,
BackoffLimit: jobSpec.BackoffLimit,
},
}
}
Expand Down
5 changes: 4 additions & 1 deletion controllers/flinkcluster/flinkcluster_converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var (
memoryOffHeapMin = resource.MustParse("600M")
memoryProcessRatio int32 = 80
jobMode v1beta1.JobMode = v1beta1.JobModeDetached
jobBackoffLimit int32 = 0
jobBackoffLimit int32 = 10
ingressPathType = networkingv1.PathTypePrefix
storageClassName = "default-class"
jmReadinessProbe = corev1.Probe{
Expand Down Expand Up @@ -192,6 +192,7 @@ func getDummyFlinkCluster() *v1beta1.FlinkCluster {
},
SecurityContext: &securityContext,
HostAliases: hostAliases,
BackoffLimit: &jobBackoffLimit,
},
JobManager: &v1beta1.JobManagerSpec{
AccessScope: v1beta1.AccessScopeVPC,
Expand Down Expand Up @@ -1634,4 +1635,6 @@ func TestClassPath(t *testing.T) {
args := desired.Job.Spec.Template.Spec.Containers[0].Args

assert.DeepEqual(t, args, expectedArgs)

assert.Equal(t, observed.cluster.Spec.Job.BackoffLimit, desired.Job.Spec.BackoffLimit)
}