Skip to content

run-cron-job action

Description

RunCronJobAction runs an existing CronJob template under an explicit invocation name. An unchanged action skips. Change job-name to request another Job, or @trigger to observe the same Job again. Removal never deletes the Job. CronJob ownership, history limits and inherited TTL can later remove it; disappearance cannot prove completion. Manual creation bypasses the source schedule, suspension and concurrency policy. Reusing a name requires the same source UID and template fingerprint. A deleted Job can later be created under the same name; this is not durable execution history. Failure, deletion or replacement while waiting returns an error. Failed Jobs remain available for inspection. The complete Job template is copied with CronJob ownership.

Source: internal/api/batch/v1/run_cron_job_action.go:33

Example usage:

imports: {
  kubernetes-batch-v1: 'github.com/cloudboss/unobin-library-kubernetes//api/batch/v1'
}

actions: {
  example: kubernetes-batch-v1.run-cron-job {
    # Set input fields here.
  }
}

Inputs

cron-job-name

string

required

job-name

string

required

namespace

optional(string)

Namespace defaults to the configured kubeconfig or library namespace.

expected-cron-job-uid

optional(string)

ExpectedCronJobUID optionally guards the source identity.

wait-for-completion

optional(boolean)

default true

WaitForCompletion defaults true. False returns a verified Job without checking completion.

timeout

optional(string)

default 10m

Timeout bounds Kubernetes HTTP requests and polling; defaults to 10m for source lookup, creation and completion together.

Input Constraints

Cron job name rules

Requirement.

Rule logic
Require
@core.is-match(input.cron-job-name, '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$')
&& @core.length(input.cron-job-name) <= 253

Job name rules

Requirement.

Rule logic
Require
@core.is-match(input.job-name, '^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$')
&& @core.length(input.job-name) <= 63

Namespace rules

Requirement.

Rule logic
Require
@core.is-match(input.namespace, '^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')
&& @core.length(input.namespace ?? '') <= 63

Expected cron job uid rules

Conditional requirement.

Rule logic
When
input.expected-cron-job-uid != null
Require
@core.length(input.expected-cron-job-uid) >= 1

Timeout rules

If set, timeout must be a positive duration.

Rule logic
Require
@core.is-format(input.timeout, 'positive-duration')

Outputs

server

string

namespace

string

cron-job-name

string

cron-job-uid

string

job-name

string

job-uid

string

completed

boolean