Skip to content

Commit

Permalink
fix(action): Add missing owner refs and annotation to create-job acti…
Browse files Browse the repository at this point in the history
…on (#16607) (#16608)

Signed-off-by: Arron Francis <arron.francis@mettle.co.uk>
Co-authored-by: afrancis101 <64639952+afrancis101@users.noreply.github.com>
  • Loading branch information
gcp-cherry-pick-bot[bot] and afrancis101 authored Dec 14, 2023
1 parent 8436954 commit a10cb87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ if job.metadata == nil then
end
job.metadata.name = obj.metadata.name .. "-" ..os.date("!%Y%m%d%H%M")
job.metadata.namespace = obj.metadata.namespace
if job.metadata.annotations == nil then
job.metadata.annotations = {}
end
job.metadata.annotations['cronjob.kubernetes.io/instantiate'] = "manual"

local ownerRef = {}
ownerRef.apiVersion = obj.apiVersion
ownerRef.kind = obj.kind
ownerRef.name = obj.metadata.name
ownerRef.uid = obj.metadata.uid
ownerRef.blockOwnerDeletion = true
ownerRef.controller = true
job.metadata.ownerReferences = {}
job.metadata.ownerReferences[1] = ownerRef

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
labels:
my: label
annotations:
cronjob.kubernetes.io/instantiate: manual
my: annotation
spec:
ttlSecondsAfterFinished: 100
Expand All @@ -26,4 +27,4 @@
- /bin/sh
- -c
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
restartPolicy: OnFailure

0 comments on commit a10cb87

Please sign in to comment.