Skip to content

Commit cbef565

Browse files
Add conventional annotation to triggered jobs
1 parent 5eaf2ef commit cbef565

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/pkg/callbacks/rolling_upgrade.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
"k8s.io/apimachinery/pkg/runtime"
1616
patchtypes "k8s.io/apimachinery/pkg/types"
1717

18+
"maps"
19+
1820
argorolloutv1alpha1 "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1"
1921
openshiftv1 "github.com/openshift/api/apps/v1"
2022
)
@@ -338,11 +340,16 @@ func UpdateDeployment(clients kube.Clients, namespace string, resource runtime.O
338340
// CreateJobFromCronjob performs rolling upgrade on cronjob
339341
func CreateJobFromCronjob(clients kube.Clients, namespace string, resource runtime.Object) error {
340342
cronJob := resource.(*batchv1.CronJob)
343+
344+
annotations := make(map[string]string)
345+
annotations["cronjob.kubernetes.io/instantiate"] = "manual"
346+
maps.Copy(annotations, cronJob.Spec.JobTemplate.Annotations)
347+
341348
job := &batchv1.Job{
342349
ObjectMeta: meta_v1.ObjectMeta{
343350
GenerateName: cronJob.Name + "-",
344351
Namespace: cronJob.Namespace,
345-
Annotations: cronJob.Spec.JobTemplate.Annotations,
352+
Annotations: annotations,
346353
Labels: cronJob.Spec.JobTemplate.Labels,
347354
OwnerReferences: []meta_v1.OwnerReference{*meta_v1.NewControllerRef(cronJob, batchv1.SchemeGroupVersion.WithKind("CronJob"))},
348355
},

0 commit comments

Comments
 (0)