Skip to content

Commit

Permalink
Merge pull request #329 from Vandebron/feature/FTS-1818-cronjob-timezone
Browse files Browse the repository at this point in the history
[FTS-1818] Added timezone to cronjob specs
  • Loading branch information
basweitjens authored Dec 18, 2023
2 parents d07455d + 48ff192 commit 0f44be1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 41 deletions.
56 changes: 54 additions & 2 deletions src/mpyl/schema/k8s_api_core.schema.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Taken from https://github.com/instrumenta/kubernetes-json-schema and converted to YAML
# Taken from https://github.com/kubernetes/kubernetes/blob/master/api/openapi-spec/swagger.json and converted to YAML
definitions:
io.k8s.api.core.v1.EnvVarSource:
description: EnvVarSource represents a source for the value of an EnvVar.
Expand Down Expand Up @@ -142,4 +142,56 @@ definitions:
kinds.
type: array
items:
type: string
type: string
io.k8s.api.batch.v1.CronJobSpec:
description: CronJobSpec describes how the job execution will look like and when
it will actually run.
properties:
concurrencyPolicy:
description: |-
Specifies how to treat concurrent executions of a Job. Valid values are:
- "Allow" (default): allows CronJobs to run concurrently; - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet; - "Replace": cancels currently running job and replaces it with a new one
type: string
enum:
- Allow
- Forbid
- Replace
failedJobsHistoryLimit:
description: The number of failed finished jobs to retain. Value must be non-negative
integer. Defaults to 1.
format: int32
type: integer
schedule:
description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
type: string
startingDeadlineSeconds:
description: Optional deadline in seconds for starting the job if it misses
scheduled time for any reason. Missed jobs executions will be counted as
failed ones.
format: int64
type: integer
successfulJobsHistoryLimit:
description: The number of successful finished jobs to retain. Value must be
non-negative integer. Defaults to 3.
format: int32
type: integer
suspend:
description: This flag tells the controller to suspend subsequent executions,
it does not apply to already started executions. Defaults to false.
type: boolean
timeZone:
description: The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
If not specified, this will default to the time zone of the kube-controller-manager
process. The set of valid time zone names and the time zone offset is loaded
from the system-wide time zone database by the API server during CronJob validation
and the controller manager during execution. If no system-wide time zone database
can be found a bundled version of the database is used instead. If the time
zone name becomes invalid during the lifetime of a CronJob or due to a change
in host configuration, the controller will stop creating new new Jobs and
will create a system event with the reason UnknownTimeZone. More information
can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones
type: string
required:
- schedule
type: object
40 changes: 1 addition & 39 deletions src/mpyl/schema/project.schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -815,45 +815,7 @@ definitions:
activeDeadlineSeconds:
$ref: '#/definitions/dtapNumberValue'
cron:
description: 'CronJobSpec describes how the job execution will look like and when it
will actually run. Identical to See https://kubernetesjsonschema.dev/v1.14.0/_definitions.json#/definitions/io.k8s.api.batch.v1beta1.CronJobSpec
but without jobTemplate'
additionalProperties: false
properties:
concurrencyPolicy:
description: 'Specifies how to treat concurrent executions of a Job. Valid values
are: - "Allow" (default): allows CronJobs to run concurrently; - "Forbid": forbids
concurrent runs, skipping next run if previous run hasn''t finished yet; - "Replace":
cancels currently running job and replaces it with a new one
See https://kubernetes.io/docs/tasks/job/automated-tasks-with-cron-jobs/#concurrency-policy
'
type: string
enum:
- Allow
- Forbid
- Replace
failedJobsHistoryLimit:
description: The number of failed finished jobs to retain. This is a pointer to
distinguish between explicit zero and not specified. Defaults to 1.
format: int32
type: integer
schedule:
description: The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
type: string
startingDeadlineSeconds:
description: Optional deadline in seconds for starting the job if it misses scheduled
time for any reason. Missed jobs executions will be counted as failed ones.
format: int64
type: integer
successfulJobsHistoryLimit:
description: The number of successful finished jobs to retain. This is a pointer
to distinguish between explicit zero and not specified. Defaults to 3.
format: int32
type: integer
suspend:
description: This flag tells the controller to suspend subsequent executions,
it does not apply to already started executions. Defaults to false.
type: boolean
$ref: 'k8s_api_core.schema.yml#/definitions/io.k8s.api.batch.v1.CronJobSpec'
spark:
description: >-
Spark job. Requires google spark operator to be installed.
Expand Down
1 change: 1 addition & 0 deletions tests/projects/job/deployment/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ deployment:
job:
cron:
schedule: "0 22 * * *"
timeZone: "Europe/Amsterdam"
dependencies:
test:
- tests/projects/service/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ spec:
schedule: 0 22 * * *
successfulJobsHistoryLimit: 3
suspend: true
timeZone: Europe/Amsterdam
1 change: 1 addition & 0 deletions tests/test_resources/test_cron_job_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ deployment:
cron:
suspend: true
schedule: "0 22 * * *"
timeZone: "Europe/Amsterdam"
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1
concurrencyPolicy: Allow
Expand Down

0 comments on commit 0f44be1

Please sign in to comment.