Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ScaledJob's label to its job #1322

Merged
merged 4 commits into from
Nov 16, 2020
Merged

Conversation

AIchovy
Copy link
Contributor

@AIchovy AIchovy commented Nov 12, 2020

Signed-off-by: mosesyou [email protected]

This PR is about to add ScaledJob's label to its job.

Checklist

Fixes #1311

Copy link
Member

@zroubalik zroubalik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zroubalik
Copy link
Member

@mosesyou could you please add this feature to the Changelog? to the Improvements section in Unreleased, thanks!

@AIchovy
Copy link
Contributor Author

AIchovy commented Nov 16, 2020

@mosesyou could you please add this feature to the Changelog? to the Improvements section in Unreleased, thanks!

Sure

@zroubalik zroubalik merged commit 9a17d10 into kedacore:main Nov 16, 2020
arschles pushed a commit to arschles/keda that referenced this pull request Dec 1, 2020
* add ScaledJob's label to its job

Signed-off-by: mosesyou <[email protected]>

* Changelog: Add ScaledJob's label to its job

Signed-off-by: mosesyou <[email protected]>

Co-authored-by: Zbynek Roubalik <[email protected]>
Signed-off-by: Aaron Schlesinger <[email protected]>
@erichorwath
Copy link

@zroubalik I have big interest in this PR and tested it, here are my findings:

  1. With this PR labels can be added to the "jobs" but not to the "pods" created by the job (see pictures). Was this intended?
  2. Annotations are still not working :( This would be needed to disable istio, see here: Using Istio with CronJobs istio/istio#11659 (comment) (this annotation is needed in the pod spec but not in the job spec)

image
image

@zroubalik
Copy link
Member

@ericbottard sad to hear that. Thanks for the confirmation! We should fix this. Could you please open an issue with the details. And are you willing to contribute this? Or @mosesyou do you want to take a look?

@erichorwath
Copy link

@zroubalik Can you maybe just reopen #1311 since the issue described there still exists?

@ycabrer
Copy link
Contributor

ycabrer commented Dec 4, 2020

Hi, I would like to help if I can.

I took a look at the code and it seems to do a deep copy of the scaledjob spec.template to job spec.template on creation.

If we want a label or annotation to appear in the pod, wouldn't we would add it in the scaledjob spec.template metadata?

@erichorwath would you provide a snip of your scaledjob? To help me better understand the issue.

@erichorwath
Copy link

erichorwath commented Dec 8, 2020

@ycabrer sure, the interesting part is here spec.template.metadata part. It would be great to be able to set this in an scaledJob yaml (-> spec.jobTargetRef.template.spec.metadata).

apiVersion: batch/v1
kind: Job
metadata:
  name: redis-job
spec:
  activeDeadlineSeconds: 96000
  backoffLimit: 0
  completions: 1
  parallelism: 1
  template:
    metadata:
      labels:
        my-workload: app
      annotations:
        sidecar.istio.io/inject: "false"
    spec:
      containers:
      - image: busybox
        imagePullPolicy: IfNotPresent
        name: redis-worker
        env: []
        ports:
        - containerPort: 8080
          name: http
          protocol: TCP
        resources: {}
        volumeMounts:
        - mountPath: /data
          name: worker-data
      imagePullSecrets:
      - name: regcred
      restartPolicy: Never
      terminationGracePeriodSeconds: 259200
      volumes:
      - emptyDir: {}
        name: worker-data

@AIchovy
Copy link
Contributor Author

AIchovy commented Dec 14, 2020

job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
GenerateName: scaledJob.GetName() + "-",
Namespace: scaledJob.GetNamespace(),
Labels: labels,
},
Spec: *scaledJob.Spec.JobTargetRef.DeepCopy(),
}

I'm not sure, Spec: *scaledJob.Spec.JobTargetRef.DeepCopy(), Doesn't this line of code mean copy ScaledJob's Job Spec including PodTemplate to Job? So why we can't pass labels or annotations from ScaledJob's JobSpec{PodTemplate{ObjectMeta}} to Job{PodTemplate{ObjectMeta}}?

@julienperignon
Copy link

Hi there

I know this has been merged in and apparently works for labels but we still cannot add annotations on the PodSpec (to disable istio injection for example). Do we have a rough idea of when this feature will be brought back in Keda ?

Cheers

@tomkerkhove
Copy link
Member

@julienperignon I've opened #1627 for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support metadata labels in ScaledJob template
6 participants