Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm: add cronjob to apply pending retention rules #656

Merged
merged 2 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Version 0.9.0 (UNRELEASED)
- Adds "infinity" option to ``REANA_SCHEDULER_REQUEUE_COUNT`` to disable requeue count.
- Adds support for Kubernetes clusters 1.22, 1.23, 1.24.
- Removes support for Kubernetes version prior to 1.19.
- Adds new configuration option ``workspaces.retention_period`` to set a default period for workspace retention rules.
- Adds new configuration option ``workspaces.retention_rules.maximum_period`` to set a default period for workspace retention rules.
- Adds new configuration option ``workspaces.retention_rules.cronjob_schedule`` to set how often pending retention rules should be applied.
- Adds configuration environment variable ``reana_server.environment.REANA_RATELIMIT_SLOW`` to limit API requests to some protected endpoints e.g launch workflow.
- Adds configuration environment variable ``reana_server.environment.REANA_WORKFLOW_SCHEDULING_READINESS_CHECK_LEVEL`` to define checks that are performed to assess whether the cluster is ready to start new workflows.
- Adds new configuration option `ingress.tls.self_signed_cert` to enable the generation of a self-signed TLS certificate.
Expand Down
3 changes: 2 additions & 1 deletion helm/reana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,6 @@ This Helm automatically prefixes all names using the release name to avoid colli
| `quota.workflow_termination_update_policy` | Resources to calculate quotas on worflow termination. Possible values: "cpu" and "disk". Leave it empty to deactivate workflow termination accounting. | "" |
| `quota.default_disk_limit` | Default users disk quota limit in bytes. | None |
| `quota.default_cpu_limit` | Default users CPU quota limit in milliseconds. | None |
| `workspaces.retention_period` | Set a default period for workspace retention rules. Users will not be able to specify a longer period to retain the workspace files. After this period the workspace will be cleared. | 365 |
| `workspaces.retention_rules.maximum_period` | Set a default period in days for workspace retention rules. Users will not be able to specify a longer period to retain the workspace files. After this period the workspace will be cleared. | 365 |
| `workspaces.retention_rules.cronjob_schedule` | Cron format string describing how often pending retention rules should be applied. | "0 2 * * *" |
| `workspaces.paths` | List of additional workspace paths as strings. Each mount string is composed by a key `hostPath`(path to the directory to be mounted from the Kubernetes nodes) and a cluster_pod_mountpath (path inside the cluster containers where the `mountPath` will be mounted) e.g. `hostPath:mountPath`. The first value listed will be the default workspace root path. Any POSIX filesystem mounted on cluster nodes is supported | None |
69 changes: 69 additions & 0 deletions helm/reana/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,72 @@ spec:
hostPath:
path: /code/reana-server
{{- end }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "reana.prefix" . }}-retention-rules-apply
namespace: {{ .Release.Namespace }}
spec:
schedule: {{ .Values.workspaces.retention_rules.cronjob_schedule }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
spec:
containers:
- name: {{ include "reana.prefix" . }}-retention-rules-apply
image: {{ .Values.components.reana_server.image }}
command:
- '/bin/sh'
- '-c'
args:
- 'flask reana-admin retention-rules-apply'
{{- if .Values.debug.enabled }}
tty: true
stdin: true
{{- end }}
env:
{{- range $key, $value := .Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .Values.debug.enabled }}
- name: FLASK_ENV
value: "development"
{{- else }}
- name: REANA_DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-db-secrets
key: user
- name: REANA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-db-secrets
key: password
{{- end }}
volumeMounts:
{{- if .Values.debug.enabled }}
- mountPath: /code/
name: reana-code
{{- end }}
- mountPath: {{ .Values.shared_storage.shared_volume_mount_path }}
name: reana-shared-volume
imagePullPolicy: IfNotPresent
restartPolicy: Never
volumes:
- name: reana-shared-volume
{{- if not (eq .Values.shared_storage.backend "hostpath") }}
persistentVolumeClaim:
claimName: {{ include "reana.prefix" . }}-shared-persistent-volume
readOnly: false
{{- else }}
hostPath:
path: {{ .Values.shared_storage.hostpath.root_path }}
{{- end }}
- name: reana-code
hostPath:
path: /code/reana-server
2 changes: 1 addition & 1 deletion helm/reana/templates/reana-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ spec:
- name: WORKSPACE_PATHS
value: {{ .Values.workspaces.paths | toJson | quote }}
- name: WORKSPACE_RETENTION_PERIOD
value: {{ .Values.workspaces.retention_period | default "365" | quote }}
value: {{ .Values.workspaces.retention_rules.maximum_period | default "365" | quote }}
{{- if .Values.quota.enabled }}
- name: REANA_WORKFLOW_TERMINATION_QUOTA_UPDATE_POLICY
value: {{ tpl .Values.quota.workflow_termination_update_policy . | default "null" }}
Expand Down
4 changes: 3 additions & 1 deletion helm/reana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ eos:
enabled: false

workspaces:
retention_period: 365
retention_rules:
maximum_period: 365
cronjob_schedule: "0 2 * * *" # everyday at 2am
paths:
- /var/reana:/var/reana

Expand Down