Skip to content

Commit

Permalink
Merge pull request #128 from daniarmas/fix/createJob
Browse files Browse the repository at this point in the history
Adding backofflimit and ttl to the CreateJob func
  • Loading branch information
daniarmas authored Jan 19, 2025
2 parents 4d13de4 + 5356ae6 commit 973030e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions internal/k8sc/k8sc.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,19 @@ func NewClient() (K8sC, error) {

// CreateJob creates a job in the k8s cluster
func (c *k8sc) CreateJob(ctx context.Context, jobName, namespace, imageName string, args []string, envs []corev1.EnvFromSource) error {
// Define the TTL duration in seconds
ttlSecondsAfterFinished := int32(15) // 15 seconds
// Define the backoff limit
backoffLimit := int32(4) // Retry up to 4 times

// Create a job spec
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: jobName,
},
Spec: batchv1.JobSpec{
TTLSecondsAfterFinished: &ttlSecondsAfterFinished,
BackoffLimit: &backoffLimit,
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyNever,
Expand Down

0 comments on commit 973030e

Please sign in to comment.