# SPDX-License-Identifier: Apache-2.0
# Copyright 2024 The HuggingFace Authors.

{{- if and .Values.images.jobs.cacheMaintenance .Values.backfillRetryableErrors.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
  labels: {{ include "labels.backfillRetryableErrors" . | nindent 4 }}
  name: "{{ include "name" . }}-job-backfill-retryable-errors"
  namespace: {{ .Release.Namespace }}
spec:
  schedule: {{ .Values.backfillRetryableErrors.schedule | quote }}
  jobTemplate:
    spec:
      ttlSecondsAfterFinished: 1200
      template:
        spec:
          restartPolicy: OnFailure
          {{- include "dnsConfig" . | nindent 10 }}
          {{- include "image.imagePullSecrets" . | nindent 6 }}
          nodeSelector: {{ toYaml .Values.backfillRetryableErrors.nodeSelector | nindent 12 }}
          tolerations: {{ toYaml .Values.backfillRetryableErrors.tolerations | nindent 12 }}
          containers: {{ include "containerBackfillRetryableErrors" . | nindent 12 }}
          securityContext: {{ include "securityContext" . | nindent 12 }}
{{- end}}
