Skip to content

Commit

Permalink
Define all cron jobs in the values.yaml file again, but allows time d…
Browse files Browse the repository at this point in the history
…urations to be parameterized.
  • Loading branch information
ksuderman committed Feb 19, 2024
1 parent 93930d7 commit 287cf13
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 113 deletions.
102 changes: 1 addition & 101 deletions galaxy/templates/cronjob-maintenance.yaml
Original file line number Diff line number Diff line change
@@ -1,101 +1,3 @@
{{- if .Values.maintenance.tmp.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "galaxy.fullname" . }}-maintenance-clean-tmp
labels:
{{- include "galaxy.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.maintenance.tmp.schedule | quote }}
jobTemplate:
spec:
template:
spec:
securityContext:
runAsUser: 0
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 16 }}
{{- end }}
containers:
- name: galaxy-maintenance-clean-tmp
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
# delete all tmp files older than walltime limit
command:
- find
- {{ .Values.persistence.mountPath }}/tmp
- '!'
- -newermt
- "{{ .Values.maintenance.tmp.seconds }} seconds"
- -type
- f
- -exec
- rm
- '{}'
- ;
volumeMounts:
- name: galaxy-data
mountPath: {{ .Values.persistence.mountPath }}
volumes:
- name: galaxy-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "galaxy.pvcname" . }}
{{- else }}
emptyDir: {}
{{- end }}
restartPolicy: OnFailure
{{- end }}
{{- if .Values.maintenance.script.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "galaxy.fullname" . }}-maintenance-script
labels:
{{- include "galaxy.labels" . | nindent 4 }}
spec:
schedule: {{ .Values.maintenance.script.schedule | quote }}
jobTemplate:
spec:
template:
spec:
securityContext:
runAsUser: 0
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 16 }}
{{- end }}
containers:
- name: galaxy-maintenance-script
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
# delete all tmp files older than walltime limit
command:
- "/bin/bash"
- "-c"
args:
- "/galaxy/server/scripts/maintenance.sh"
- "--no-dry-run"
- "--days"
- {{ .Values.maintenance.script.days | quote }}
volumeMounts:
- name: galaxy-data
mountPath: {{ .Values.persistence.mountPath }}
volumes:
- name: galaxy-data
{{- if .Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "galaxy.pvcname" . }}
{{- else }}
emptyDir: {}
{{- end }}
restartPolicy: OnFailure
{{- end }}
{{ if .Values.cronJobs -}}
{{ range $key, $cronjob := .Values.cronJobs }}
---
apiVersion: batch/v1
Expand All @@ -116,13 +18,12 @@ spec:
{{- end}}
{{- with $.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 16 }}
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: galaxy-maintenance-{{ $key }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
# delete all tmp files older than walltime limit
command:
{{- range $cmd := $cronjob.command }}
- {{ tpl $cmd $ | quote }}
Expand All @@ -146,4 +47,3 @@ spec:
{{- end }}
restartPolicy: OnFailure
{{- end }}
{{- end }}
46 changes: 34 additions & 12 deletions galaxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,41 @@ cronJobs:
- "-R"
- "galaxy"
- "/galaxy/server/database"
#- Maintenance tasks that should be run periodically to prevent storage from being exhausted
maintenance:
#- Remove files in the tmp directory.
tmp:
enabled: true
maintenance:
schedule: "5 2 * * *"
seconds: "604800" # Default wall time for jobs
#- The maintenance script removes histories, datasets, and other Galaxy objects older than 7 days.
script:
enabled: true
schedule: "10 2 * * *"
days: "7"

extraSettings:
days: 7
securityContext:
runAsUser: 0
command:
- "/bin/bash"
- "-c"
args:
- "/galaxy/server/scripts/maintenance.sh"
- "--no-dry-run"
- "--days"
- "{{ .Values.cronJobs.maintenance.extraSettings.days }}"
#- Remove files from the tmp directory that are older than the allowable wall time for a job
tmp:
schedule: "15 2 * * *"
extraSettings:
seconds: 604800
securityContext:
runAsUser: 0
command:
- /usr/bin/find
args:
- "{{ .Values.persistence.mountPath }}/tmp"
- "!"
- "-newermt"
- "{{ .Values.cronJobs.tmp.extraSettings.seconds }}"
- "seconds"
- "-type"
- "f"
- "-exec"
- "rm"
- "{}"
- ";"
ingress:
#- Should ingress be enabled. Defaults to `true`
enabled: true
Expand Down

0 comments on commit 287cf13

Please sign in to comment.