Skip to content

Commit

Permalink
feat: 🎸 add backfill cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
severo committed Apr 21, 2023
1 parent 364e77c commit 768513d
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.11.0
version: 1.12.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
3 changes: 3 additions & 0 deletions chart/env/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ cacheMaintenance:
cpu: 1

# --- cron jobs ---
backfill:
enabled: false

metricsCollector:
action: "collect-metrics"
schedule: "*/5 * * * *"
Expand Down
14 changes: 14 additions & 0 deletions chart/env/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ cacheMaintenance:
memory: "8Gi"

# --- cron jobs ---
backfill:
enabled: true
action: "backfill"
schedule: "0 * * * *"
# every hour
nodeSelector: {}
resources:
requests:
cpu: 1
limits:
cpu: 1
memory: "512Mi"
tolerations: []

metricsCollector:
action: "collect-metrics"
schedule: "*/2 * * * *"
Expand Down
5 changes: 5 additions & 0 deletions chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ app.kubernetes.io/component: "{{ include "name" . }}-cache-maintenance"
app.kubernetes.io/component: "{{ include "name" . }}-metrics-collector"
{{- end -}}

{{- define "labels.backfill" -}}
{{ include "hf.labels.commons" . }}
app.kubernetes.io/component: "{{ include "name" . }}-backfill"
{{- end -}}

{{- define "labels.admin" -}}
{{ include "hf.labels.commons" . }}
app.kubernetes.io/component: "{{ include "name" . }}-admin"
Expand Down
19 changes: 19 additions & 0 deletions chart/templates/cron-jobs/backfill/_container.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Authors.

{{- define "containerBackfill" -}}
- name: "{{ include "name" . }}-backfill"
image: {{ include "jobs.cacheMaintenance.image" . }}
imagePullPolicy: {{ .Values.images.pullPolicy }}
securityContext:
allowPrivilegeEscalation: false
resources: {{ toYaml .Values.backfill.resources | nindent 4 }}
env:
{{ include "envLog" . | nindent 2 }}
{{ include "envCache" . | nindent 2 }}
{{ include "envQueue" . | nindent 2 }}
{{ include "envCommon" . | nindent 2 }}
{{ include "envMetrics" . | nindent 2 }}
- name: CACHE_MAINTENANCE_ACTION
value: {{ .Values.backfill.action | quote }}
{{- end -}}
24 changes: 24 additions & 0 deletions chart/templates/cron-jobs/backfill/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2022 The HuggingFace Authors.

{{- if and .Values.images.jobs.cacheMaintenance .Values.backfill.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
labels: {{ include "labels.backfill" . | nindent 4 }}
name: "{{ include "name" . }}-job-backfill"
namespace: {{ .Release.Namespace }}
spec:
schedule: {{ .Values.backfill.schedule | quote }}
jobTemplate:
spec:
ttlSecondsAfterFinished: 3600
template:
spec:
restartPolicy: OnFailure
{{- include "image.imagePullSecrets" . | nindent 6 }}
nodeSelector: {{ toYaml .Values.backfill.nodeSelector | nindent 12 }}
tolerations: {{ toYaml .Values.backfill.tolerations | nindent 12 }}
containers: {{ include "containerBackfill" . | nindent 12 }}
securityContext: {{ include "securityContext" . | nindent 12 }}
{{- end}}
14 changes: 14 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@ cacheMaintenance:
tolerations: []

# --- cron jobs ---
backfill:
enabled: false
action: "backfill"
schedule: "0 */3 * * *"
# every 3 hours
nodeSelector: {}
resources:
requests:
cpu: 0
limits:
cpu: 0
tolerations: []


metricsCollector:
action: "collect-metrics"
schedule: "*/5 * * * *"
Expand Down

0 comments on commit 768513d

Please sign in to comment.