From e0b960dadf8dc2495d6f6067f2a886dd21b1ef0b Mon Sep 17 00:00:00 2001 From: Keith Suderman Date: Fri, 9 Feb 2024 16:20:10 -0500 Subject: [PATCH] First pass at defining cron jobs in the values.yaml file. --- galaxy/templates/cronjob-maintenance.yaml | 46 ++++++++--------- galaxy/values.yaml | 63 ++++++++++++++++++++++- 2 files changed, 85 insertions(+), 24 deletions(-) diff --git a/galaxy/templates/cronjob-maintenance.yaml b/galaxy/templates/cronjob-maintenance.yaml index 17b0219a..a9344494 100644 --- a/galaxy/templates/cronjob-maintenance.yaml +++ b/galaxy/templates/cronjob-maintenance.yaml @@ -1,47 +1,47 @@ +{{ if .Values.cronJobs -}} +{{ range $key, $cronjob := .Values.cronJobs }} +--- apiVersion: batch/v1 kind: CronJob metadata: - name: {{ include "galaxy.fullname" . }}-maintenance + name: {{ include "galaxy.fullname" $ }}-maintenance-{{ $key }} labels: - {{- include "galaxy.labels" . | nindent 4 }} + {{- include "galaxy.labels" $ | nindent 4 }} spec: - schedule: "0 2 * * *" + schedule: {{ $cronjob.schedule | quote }} jobTemplate: spec: template: spec: securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - {{- with .Values.nodeSelector }} + {{- toYaml $cronjob.securityContext | nindent 12 }} + {{- with $.nodeSelector }} nodeSelector: {{- toYaml . | nindent 16 }} {{- end }} containers: - - name: galaxy-maintenance - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} + - name: galaxy-maintenance-{{ $key }} + 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 - - -{{ (index .Values "configs" "job_conf.yml" "runners" "k8s" "k8s_walltime_limit" | default 604800) }} seconds - - -type - - f - - -exec - - rm - - '{}' - - ; + command: {{ $cronjob.command }} + {{- if $cronjob.args }} + args: + {{- range $arg := $cronjob.args }} + - {{ tpl $arg $ }} + {{- end }} + {{- end }} volumeMounts: - name: galaxy-data - mountPath: {{ .Values.persistence.mountPath }} + mountPath: {{ $.Values.persistence.mountPath }} volumes: - name: galaxy-data - {{- if .Values.persistence.enabled }} + {{- if $.Values.persistence.enabled }} persistentVolumeClaim: - claimName: {{ template "galaxy.pvcname" . }} + claimName: {{ template "galaxy.pvcname" $ }} {{- else }} emptyDir: {} {{- end }} restartPolicy: OnFailure +{{- end }} +{{- end }} diff --git a/galaxy/values.yaml b/galaxy/values.yaml index 9c85c0c0..ad8e3e25 100644 --- a/galaxy/values.yaml +++ b/galaxy/values.yaml @@ -267,6 +267,66 @@ extraEnv: [] # - name: EXAMPLE_ENV # value: MY_VALUE +cronJobs: + clean-tmp: + schedule: "0 2 * * *" + securityContext: + runAsUser: 0 + command: /bin/bash + args: + - "-c" + - "find" + - "{{ .Values.persistence.mountPath }}/tmp" + - "!" + - "-newermt" + - "-{{ (index .Values \"configs\" \"job_conf.yml\" \"runners\" \"k8s\" \"k8s_walltime_limit\" | default 604800) }} seconds" + - "-type" + - "f" + - "-exec" + - "rm" + - "{}" + - ";" + clean-jobs: + schedule: "10 2 * * *" + securityContext: + runAsUser: 0 + command: /usr/bin/tmpwatch + args: + - "-v" + - "--all" + - "--mtime" + - "--dirmtime" + - "7d" + - "{{ .Values.persistence.mountPath }}/jobs_directory" + cleanup-datasets: + schedule: "20 2 * * *" + securityContext: + runAsUser: 0 + command: /galaxy/server/.venv/bin/python + args: + - "/galaxy/server/scripts/cleanup_datasets/pgcleanup.py" + - "-c" + - "/galaxy/server/config/galaxy.yml" + - "-o" + - "7" + - "-l" + - "{{ .Values.persistence.mountPath }}/tmp" + - "-w" + - "128MB" + - "delete_userless_histories" + - "delete_exported_histories" + cleanup-tusd-store: + schedule: "30 2 * * *" + securityContext: + runAsUser: 0 + command: /usr/bin/tmpwatch + args: + - "-v" + - "--all" + - "--mtime" + - "--dirmtime" + - "7d" + - "{{ .Values.persistence.mountPath }}/tmp/tus_upload_store" ingress: #- Should ingress be enabled. Defaults to `true` enabled: true @@ -301,7 +361,8 @@ resources: memory: 7G ephemeral-storage: 10Gi -nodeSelector: {} +#nodeSelector: {} +nodeSelector: "cloud:google:com/gke-nodepool: default-pool" tolerations: []