-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally delay replica deletion (#2252)
Fixes #2170 The number of days to delay file replication deletion by is configurable in the Helm chart with `replica_deletion_delay_days` (set by default to 7 days in `values.yaml` to encourage good practice, though we could change this). When `replica_deletion_delay_days` is set to an int above 0, when a delete replica job would otherwise be started as a Kubernetes Job, a CronJob is created instead with a cron schedule set to run yearly, starting x days from the current moment. This cronjob is then deleted by the operator after the job successfully completes. If a failed background job is retried, it is re-run immediately as a Job rather than being scheduled out into the future again. --------- Co-authored-by: Ilya Kreymer <[email protected]>
- Loading branch information
Showing
8 changed files
with
169 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
name: "{{ id }}" | ||
labels: | ||
role: "cron-background-job" | ||
job_type: {{ job_type }} | ||
btrix.org: {{ oid }} | ||
|
||
spec: | ||
concurrencyPolicy: Forbid | ||
successfulJobsHistoryLimit: 0 | ||
failedJobsHistoryLimit: 2 | ||
|
||
schedule: "{{ schedule }}" | ||
|
||
jobTemplate: | ||
metadata: | ||
labels: | ||
role: "background-job" | ||
job_type: {{ job_type }} | ||
job_id: {{ id }} | ||
btrix.org: {{ oid }} | ||
|
||
spec: | ||
template: | ||
spec: | ||
restartPolicy: Never | ||
priorityClassName: bg-job | ||
podFailurePolicy: | ||
rules: | ||
- action: FailJob | ||
onExitCodes: | ||
containerName: rclone | ||
operator: NotIn | ||
values: [0] | ||
|
||
containers: | ||
- name: rclone | ||
image: rclone/rclone:latest | ||
env: | ||
|
||
- name: RCLONE_CONFIG_REPLICA_TYPE | ||
value: "s3" | ||
|
||
- name: RCLONE_CONFIG_REPLICA_ACCESS_KEY_ID | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ replica_secret_name }}" | ||
key: STORE_ACCESS_KEY | ||
|
||
- name: RCLONE_CONFIG_REPLICA_SECRET_ACCESS_KEY | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ replica_secret_name }}" | ||
key: STORE_SECRET_KEY | ||
|
||
- name: RCLONE_CONFIG_REPLICA_REGION | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ replica_secret_name }}" | ||
key: STORE_REGION | ||
|
||
- name: RCLONE_CONFIG_REPLICA_PROVIDER | ||
valueFrom: | ||
secretKeyRef: | ||
name: "{{ replica_secret_name }}" | ||
key: STORE_S3_PROVIDER | ||
|
||
- name: RCLONE_CONFIG_REPLICA_ENDPOINT | ||
value: "{{ replica_endpoint }}" | ||
|
||
command: ["rclone", "-vv", "delete", "replica:{{ replica_file_path }}"] | ||
|
||
resources: | ||
limits: | ||
memory: "200Mi" | ||
|
||
requests: | ||
memory: "200Mi" | ||
cpu: "50m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters