1
0
mirror of https://github.com/appuio/appuio-pruner.git synced 2026-02-05 09:45:36 +01:00

Merge pull request #18 from 54nd20/cronjobs-disableable

Individual cronjobs can be disabled
This commit is contained in:
Simon Gerber
2020-06-09 17:18:25 +02:00
committed by GitHub
3 changed files with 22 additions and 5 deletions

View File

@@ -24,9 +24,10 @@ and role bindings for the jobs to do their job.
| Name | Default value | Description |
|------|---------------|-------------|
| appuio_pruner_namespace | `appuio-infra` | Namespace to install the APPUiO pruner into |
| appuio_pruner_namespace | `appuio-pruner` | Namespace to install the APPUiO pruner into |
| appuio_pruner_image | `"docker.io/appuio/oc:{{ openshift_release }}"` | Image for the pruner job |
| appuio_pruner_schedule | `@hourly` | Schedule in [Cron] format |
| appuio_pruner_disabled_jobs | `[]` | List of pruner jobs to be disabled |
| appuio_pruner_extra_args_<kind> | `[]` | List of extra args to add to a prune command. See below |
| appuio_pruner_state | `present` | When set to `absent`, the pruner is removed from the cluster |

View File

@@ -11,6 +11,8 @@ appuio_pruner_cmd:
- adm
- prune
appuio_pruner_disabled_jobs: []
appuio_pruner_args:
builds:
- builds

View File

@@ -23,11 +23,15 @@
arguments:
NAMESPACE: "{{ appuio_pruner_namespace }}"
- name: Validate appuio_pruner_disabled_jobs
with_list: "{{ appuio_pruner_disabled_jobs }}"
assert:
that: item in appuio_pruner_jobs
msg: "'{{ item }}' is not a valid job. Valid jobs are '{{ appuio_pruner_jobs | join(', ') }}'."
- name: Install cronjobs
with_list:
- builds
- deployments
- images
with_list: "{{ appuio_pruner_jobs }}"
when: item not in appuio_pruner_disabled_jobs
vars:
cmd: >-
{{
@@ -49,6 +53,16 @@
MEMORY_REQUEST: "{{ appuio_pruner_memory_request }}"
MEMORY_LIMIT: "{{ appuio_pruner_memory_limit }}"
- name: Remove disabled cronjobs
ignore_errors: true
with_list: "{{ appuio_pruner_disabled_jobs }}"
command: >-
oc -n {{ appuio_pruner_namespace | quote }}
delete cronjob "prune-{{ item }}"
register: r_remove_cronjob
changed_when: r_remove_cronjob.rc == 0
vars:
appuio_pruner_jobs: [builds, deployments, images]
always:
- name: Delete temp directory
file: