Skip to content

Commit 3fd81ac

Browse files
author
Gaurav Nelson
authored
Merge pull request openshift#7220 from gaurav-nelson/enterprise-3.7-stage
[enterprise-3.7] Cron jobs suggestions for pruning and quota
2 parents 56269c2 + bfe2b87 commit 3fd81ac

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

admin_guide/pruning_resources.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,3 +614,30 @@ finished, the registry can be switched back to read-write mode by executing:
614614
$ oc env -n default dc/docker-registry REGISTRY_STORAGE_MAINTENANCE_READONLY-
615615
----
616616
endif::[]
617+
618+
[[pruning-cronjobs]]
619+
== Pruning Cron Jobs
620+
621+
[IMPORTANT]
622+
====
623+
Cron Jobs is a Technology Preview feature only.
624+
ifdef::openshift-enterprise[]
625+
Technology Preview features are not
626+
supported with Red Hat production service level agreements (SLAs), might not be
627+
functionally complete, and Red Hat does not recommend to use them for
628+
production. These features provide early access to upcoming product features,
629+
enabling customers to test functionality and provide feedback during the
630+
development process.
631+
632+
For more information on Red Hat Technology Preview features support scope, see
633+
https://access.redhat.com/support/offerings/techpreview/.
634+
endif::[]
635+
====
636+
637+
At this time, the results of cron jobs are not automatically pruned, unless a
638+
application developer explicitly configures that feature. Therefore, cluster
639+
administrator should manually perform a regular
640+
xref:../../dev_guide/cron_jobs.adoc#cleaning-up-after-a-cron-job[Cron job cleanup].
641+
Red Hat recommends to xref:manage_authorization_policy.adoc[restrict the access] to cron jobs
642+
to a small group of trusted users and set appropriate xref:quota.adoc[quota] to
643+
prevent the cron job from creating too many jobs and pods.

dev_guide/cron_jobs.adoc

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ endif::[]
4545
[WARNING]
4646
====
4747
A cron job creates a job object approximately once per execution time of its
48-
schedule, but there are circumstances in which it will fail to create a job or
49-
two jobs might be created. As a result, jobs should be idempotent.
48+
schedule, but there are circumstances in which it fails to create a job or
49+
two jobs might be created. Therefore, jobs should be idempotent and you
50+
should monitor and xref:cleaning-up-after-a-cron-job[clean cron jobs]
51+
frequently.
5052
====
5153

5254
[[creating-a-cronjob]]
@@ -127,14 +129,29 @@ Doing this prevents them from generating unnecessary artifacts.
127129
[[cleaning-up-after-a-cron-job]]
128130
== Cleaning Up After a Cron Job
129131

130-
Cron jobs can leave behind artifact resources such as jobs or pods. Check if any remain:
132+
Cron jobs can leave behind artifact resources such as jobs or pods. Configuring history limits is important, so that old jobs and their pods are properly cleaned. There are
133+
two optional fields within cron job's spec responsible for that:
131134

135+
[source,yaml]
132136
----
133-
$ oc get jobs
134-
$ oc get pods
137+
apiVersion: batch/v2alpha1
138+
kind: CronJob
139+
metadata:
140+
name: pi
141+
spec:
142+
successfulJobsHistoryLimit: 3 <1>
143+
failedJobsHistoryLimit: 1 <2>
144+
schedule: "*/1 * * * *"
145+
jobTemplate:
146+
spec:
147+
...
135148
----
136149

137-
All artifacts left over from a job execution use the job name as their prefix. For example, given the cron job example:
150+
<1> The number of successful finished jobs to retain.
151+
<2> The number of failed finished jobs to retain.
152+
153+
At any point in time, you can manually verify all artifacts left over from a job execution by using
154+
the job name as their prefix. For example, given the cron job example:
138155

139156
----
140157
$ oc get jobs

0 commit comments

Comments
 (0)