-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Job: Respect ControllerRef #42176
Job: Respect ControllerRef #42176
Conversation
51aa4f9
to
38c4f5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit, but mostly LGTM.
} | ||
// Make sure the ControllerRefs are correct. | ||
for _, controllerRef := range fakePodControl.ControllerRefs { | ||
if got, want := controllerRef.APIVersion, "batch/v1"; got != want { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you verify the entire ControllerRef object, iow. including the Name and UID?
Reviewed 31 of 31 files at r1. pkg/controller/job/jobcontroller.go, line 51 at r1 (raw file):
Probably should be package private pkg/controller/job/jobcontroller.go, line 149 at r1 (raw file):
This is already here, but you have been removing th Comments from Reviewable |
38c4f5d
to
db98286
Compare
db98286
to
9e87ecf
Compare
9e87ecf
to
9b724c9
Compare
@k8s-bot non-cri e2e test this |
9b724c9
to
37f804b
Compare
@k8s-bot non-cri e2e test this |
@soltysh Please take a look. I believe all comments are addressed. |
I've removed LGTM because I have some changes planned to bring this up to date with the other ControllerRef PRs that moved forward during the 1.6 cycle. I'll request re-review once I've pushed those changes. |
37c0e26
to
3eed987
Compare
Now that Job adds ControllerRef to Pods it creates, we need to set this default so legacy behavior is maintained.
3eed987
to
a307588
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in general
jobKey, err := controller.KeyFunc(job) | ||
if err != nil { | ||
utilruntime.HandleError(fmt.Errorf("Couldn't get key for job %#v: %v", job, err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In a comment on another ControllerRef PR, the reviewer asked me to remove this type of logging during watch handlers.
@@ -598,7 +599,8 @@ func TestJobPodLookup(t *testing.T) { | |||
} | |||
for _, tc := range testCases { | |||
sharedInformerFactory.Batch().V1().Jobs().Informer().GetIndexer().Add(tc.job) | |||
if job := manager.getPodJob(tc.pod); job != nil { | |||
if jobs := manager.getPodJobs(tc.pod); len(jobs) > 0 { | |||
job := jobs[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also make sure len(jobs)==1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
This is part of the completion of ControllerRef, as described here: https://github.com/kubernetes/community/blob/master/contributors/design-proposals/controller-ref.md#watches
The Job Listers still use selectors, because this is the behavior expected by callers. This clarifies the meaning of the returned list. Some callers may need to switch to using GetControllerOf() instead, but that is a separate, case-by-case issue.
Now that the default delete option for Job is OrphanDependents, Job deletion is asynchronous.
This is necessary to avoid racing with the GC when it orphans dependents.
This is needed to update ControllerRef during adopt/release.
An e2e test is currently the only way to ensure we have the correct RBAC permissions to PATCH Pods.
a307588
to
d5b86bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Automatic merge from submit-queue (batch tested with PRs 42177, 42176, 44721) |
What this PR does / why we need it:
This is part of the completion of the ControllerRef proposal. It brings Job into full compliance with ControllerRef. See the individual commit messages for details.
Which issue this PR fixes:
This ensures that Job does not fight with other controllers over control of Pods.
Ref: #24433
Special notes for your reviewer:
Release note:
cc @erictune @kubernetes/sig-apps-pr-reviews