Description of problem: - ScheduledJob pod doesn't take over the label Version-Release number of selected component (if applicable): - OCP 3.3 How reproducible: Steps to Reproduce: 1. Create ScheduledJob as [1]. (oc create -f hello.yaml) 2. Check label in the pods. (oc get pod -o yaml) Actual results: - The pods don't have the label. Expected results: - The pods ran by scheduledjob take over the label. (in this case job=test) Additional info: - Without label, it is not possible to delete "Completed" pod and oc get pod showed tons of Completed pods[2]. [1]--- apiVersion: batch/v2alpha1 kind: ScheduledJob metadata: name: hello labels: job: test spec: schedule: "* * * * *" jobTemplate: spec: template: spec: containers: - name: hello image: busybox args: - /bin/sh - -c - date; echo Hello from the Kubernetes cluster restartPolicy: OnFailure [2]--- [joe@knakayam-ose33-master1 ~]$ oc get pod NAME READY STATUS RESTARTS AGE hello-1160671760-tahw1 0/1 Completed 0 6h hello-1160737296-ywvge 0/1 Completed 0 3h hello-1160802832-3ciew 0/1 Completed 0 23h hello-1160868368-j7em6 0/1 Completed 0 23h hello-1160933904-ryoi3 0/1 Completed 0 23h hello-1160999440-lo5b2 0/1 Completed 0 23h hello-1161064976-ncelk 0/1 Completed 0 23h hello-1161130512-ogl33 0/1 Completed 0 23h hello-1376088595-kvvy4 0/1 Completed 0 23h ....
This is not a bug, for one you should rather put label on a podTemplate spec to have it in pods created by the CronJob, the same applies to jobs, if you want some labels on jobs generated by CronJob set it on jobTemplate. Secondly, the removal will be fixed by actually implementing cascade removal of the jobs and pods generated by CronJob.
Verified with latest OSE3.3 puddle: # openshift version openshift v3.3.1.9 kubernetes v1.3.0+52492b4 etcd 2.3.0+git Have put label on the podTemplate spec, then the pod crated by Scheduledjob with label setting in the resource file[1]. [1]---- apiVersion: batch/v2alpha1 kind: ScheduledJob metadata: name: hello labels: job: test spec: schedule: "* * * * *" jobTemplate: spec: template: metadata: labels: job: test spec: containers: - name: hello image: busybox args: - /bin/sh - -c - date; echo Hello from the Kubernetes cluster restartPolicy: OnFailure
This bug was fixed with the latest OCP 3.3.1 that is already released.