From 287cf133f440a03b37cc3549e91462c745cf7844 Mon Sep 17 00:00:00 2001 From: Keith Suderman Date: Mon, 19 Feb 2024 12:12:38 -0500 Subject: [PATCH] Define all cron jobs in the values.yaml file again, but allows time durations to be parameterized. --- galaxy/templates/cronjob-maintenance.yaml | 102 +--------------------- galaxy/values.yaml | 46 +++++++--- 2 files changed, 35 insertions(+), 113 deletions(-) diff --git a/galaxy/templates/cronjob-maintenance.yaml b/galaxy/templates/cronjob-maintenance.yaml index 9df57386..3f626e35 100644 --- a/galaxy/templates/cronjob-maintenance.yaml +++ b/galaxy/templates/cronjob-maintenance.yaml @@ -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 @@ -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 }} @@ -146,4 +47,3 @@ spec: {{- end }} restartPolicy: OnFailure {{- end }} -{{- end }} diff --git a/galaxy/values.yaml b/galaxy/values.yaml index fd821f04..454215eb 100644 --- a/galaxy/values.yaml +++ b/galaxy/values.yaml @@ -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