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

Job: Respect ControllerRef #42176

Merged
merged 12 commits into from
Apr 20, 2017
Merged

Conversation

enisoc
Copy link
Member

@enisoc enisoc commented Feb 27, 2017

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:

Job controller now respects ControllerRef to avoid fighting over Pods.

cc @erictune @kubernetes/sig-apps-pr-reviews

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 27, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Feb 27, 2017
@enisoc enisoc added this to the v1.6 milestone Feb 27, 2017
@enisoc enisoc force-pushed the controller-ref-job branch from 51aa4f9 to 38c4f5d Compare February 27, 2017 18:30
@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 27, 2017
Copy link
Contributor

@soltysh soltysh left a 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 {
Copy link
Contributor

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?

@kow3ns
Copy link
Member

kow3ns commented Feb 27, 2017

Reviewed 31 of 31 files at r1.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks broke.


pkg/controller/job/jobcontroller.go, line 51 at r1 (raw file):

// ControllerKind contains the schema.GroupVersionKind for this controller type.
var ControllerKind = batch.SchemeGroupVersion.WithKind("Job")

Probably should be package private


pkg/controller/job/jobcontroller.go, line 149 at r1 (raw file):

func (jm *JobController) getPodJobs(pod *v1.Pod) []*batch.Job {
	jobs, err := jm.jobLister.GetPodJobs(pod)
	if err != nil {

This is already here, but you have been removing th


Comments from Reviewable

@enisoc enisoc force-pushed the controller-ref-job branch from 38c4f5d to db98286 Compare February 28, 2017 01:00
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 28, 2017
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 1, 2017
@enisoc enisoc added the kind/bug Categorizes issue or PR as related to a bug. label Mar 1, 2017
@enisoc enisoc force-pushed the controller-ref-job branch from db98286 to 9e87ecf Compare March 2, 2017 19:02
@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 2, 2017
@enisoc enisoc force-pushed the controller-ref-job branch from 9e87ecf to 9b724c9 Compare March 3, 2017 22:15
@enisoc
Copy link
Member Author

enisoc commented Mar 3, 2017

@k8s-bot non-cri e2e test this

@enisoc
Copy link
Member Author

enisoc commented Mar 6, 2017

@k8s-bot non-cri e2e test this

@enisoc
Copy link
Member Author

enisoc commented Mar 6, 2017

@soltysh Please take a look. I believe all comments are addressed.

@enisoc enisoc removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 10, 2017
@enisoc
Copy link
Member Author

enisoc commented Apr 10, 2017

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.

@enisoc enisoc force-pushed the controller-ref-job branch 3 times, most recently from 37c0e26 to 3eed987 Compare April 13, 2017 22:41
@enisoc enisoc removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Apr 14, 2017
@enisoc
Copy link
Member Author

enisoc commented Apr 14, 2017

This is ready for final re-review.

I've added 3 commits to fix the equivalent of #42938 and #43034. I made no changes to the previous commits other than rebasing on master.

enisoc added 3 commits April 18, 2017 13:56
Now that Job adds ControllerRef to Pods it creates,
we need to set this default so legacy behavior is maintained.
@enisoc enisoc force-pushed the controller-ref-job branch from 3eed987 to a307588 Compare April 18, 2017 20:59
Copy link
Member

@janetkuo janetkuo left a 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))
Copy link
Member

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Member Author

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]
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

enisoc added 9 commits April 19, 2017 14:03
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.
@enisoc enisoc force-pushed the controller-ref-job branch from a307588 to d5b86bb Compare April 19, 2017 21:03
Copy link
Member

@janetkuo janetkuo left a comment

Choose a reason for hiding this comment

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

LGTM

@enisoc enisoc added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 20, 2017
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 42177, 42176, 44721)

@k8s-github-robot k8s-github-robot merged commit 7b43f92 into kubernetes:master Apr 20, 2017
@enisoc enisoc deleted the controller-ref-job branch April 21, 2017 19:19
@enisoc enisoc mentioned this pull request Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.