Skip to content

Commit

Permalink
adding clean stats cache cron job (#1986)
Browse files Browse the repository at this point in the history
* adding clean stats cache cron job

* Apply suggestions from code review

Co-authored-by: Quentin Lhoest <[email protected]>

---------

Co-authored-by: Quentin Lhoest <[email protected]>
  • Loading branch information
AndreaFrancis and lhoestq authored Oct 16, 2023
1 parent 47171d7 commit 520157c
Show file tree
Hide file tree
Showing 6 changed files with 82 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.19.0
version: 1.20.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
5 changes: 5 additions & 0 deletions chart/env/prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ cleanDuckdbIndexJobRunner:
role-datasets-server: "true"
expiredTimeIntervalSeconds: 10_800 # 3 hours

cleanStatsCache:
nodeSelector:
role-datasets-server: "true"
expiredTimeIntervalSeconds: 10_800 # 3 hours

postMessages:
nodeSelector:
role-datasets-server: "true"
Expand Down
5 changes: 5 additions & 0 deletions chart/templates/_common/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ app.kubernetes.io/component: "{{ include "name" . }}-clean-duckdb-job-runner"
app.kubernetes.io/component: "{{ include "name" . }}-clean-hf-datasets-cache"
{{- end -}}

{{- define "labels.cleanStatsCache" -}}
{{ include "hf.labels.commons" . }}
app.kubernetes.io/component: "{{ include "name" . }}-clean-stats-cache"
{{- end -}}

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

{{- define "containerCleanStatsCache" -}}
- name: "{{ include "name" . }}-clean-stats-cache"
image: {{ include "jobs.cacheMaintenance.image" . }}
imagePullPolicy: {{ .Values.images.pullPolicy }}
volumeMounts:
{{ include "volumeMountDescriptiveStatisticsRW" . | nindent 2 }}
securityContext:
allowPrivilegeEscalation: false
resources: {{ toYaml .Values.cleanStatsCache.resources | nindent 4 }}
env:
{{ include "envCommon" . | nindent 2 }}
- name: CACHE_MAINTENANCE_ACTION
value: {{ .Values.cleanStatsCache.action | quote }}
- name: LOG_LEVEL
value: {{ .Values.cleanStatsCache.log.level | quote }}
- name: DIRECTORY_CLEANING_CACHE_DIRECTORY
value: {{ .Values.descriptiveStatistics.cacheDirectory | quote }}
- name: DIRECTORY_CLEANING_SUBFOLDER_PATTERN
value: {{ .Values.cleanStatsCache.subfolderPattern | quote }}
- name: DIRECTORY_CLEANING_EXPIRED_TIME_INTERVAL_SECONDS
value: {{ .Values.cleanStatsCache.expiredTimeIntervalSeconds | quote }}
{{- end -}}
27 changes: 27 additions & 0 deletions chart/templates/cron-jobs/clean-stats-cache/job.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 The HuggingFace Authors.

{{- if and .Values.images.jobs.cacheMaintenance .Values.cleanStatsCache.enabled }}
apiVersion: batch/v1
kind: CronJob
metadata:
labels: {{ include "labels.cleanStatsCache" . | nindent 4 }}
name: "{{ include "name" . }}-job-clean-stats-cache"
namespace: {{ .Release.Namespace }}
spec:
schedule: {{ .Values.cleanStatsCache.schedule | quote }}
jobTemplate:
spec:
ttlSecondsAfterFinished: 3600
template:
spec:
restartPolicy: OnFailure
{{- include "dnsConfig" . | nindent 10 }}
{{- include "image.imagePullSecrets" . | nindent 6 }}
nodeSelector: {{ toYaml .Values.cleanStatsCache.nodeSelector | nindent 12 }}
tolerations: {{ toYaml .Values.cleanStatsCache.tolerations | nindent 12 }}
containers: {{ include "containerCleanStatsCache" . | nindent 12 }}
securityContext: {{ include "securityContext" . | nindent 12 }}
initContainers: {{ include "initContainerDescriptiveStatistics" . | nindent 12 }}
volumes: {{ include "volumeDescriptiveStatistics" . | nindent 12 }}
{{- end}}
19 changes: 19 additions & 0 deletions chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,25 @@ cleanDuckdbIndexJobRunner:
subfolderPattern: "job_runner/*"


cleanStatsCache:
enabled: true
log:
level: "info"
action: "clean-directory"
error_codes_to_retry: ""
schedule: "0 */3 * * *"
# every 3 hours
nodeSelector: {}
resources:
requests:
cpu: 0
limits:
cpu: 0
tolerations: []
expiredTimeIntervalSeconds: 600
subfolderPattern: "*"


postMessages:
enabled: true
log:
Expand Down

0 comments on commit 520157c

Please sign in to comment.