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

Controllers doesn't take any actions when being deleted. #27438

Merged
merged 3 commits into from
Jul 12, 2016

Conversation

gmarek
Copy link
Contributor

@gmarek gmarek commented Jun 15, 2016

I started doing it for other controllers but it's not always clear to me how it should work. I'll be adding other ones as separate commits to this PR.

cc @caesarxuchao @lavalamp

@gmarek gmarek added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jun 15, 2016
@gmarek gmarek self-assigned this Jun 15, 2016
@k8s-github-robot k8s-github-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-label-needed labels Jun 15, 2016
@@ -671,7 +671,7 @@ func (dsc *DaemonSetsController) syncDaemonSet(key string) error {
return err
}
dsNeedsSync := dsc.expectations.SatisfiedExpectations(dsKey)
if dsNeedsSync {
if dsNeedsSync && ds.DeletionTimestamp == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I'm doing this in a similar way for RC, so SGTM.

Copy link
Member

Choose a reason for hiding this comment

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

For RC, I also need to check DeletionTimestamp!=nil before adopting orphaned pods. daemon controller may need to do the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The amount of boilerplate is insane...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I mistaken, or adoption is not implemented for Daemons yet?

Copy link
Member

Choose a reason for hiding this comment

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

It's where you want to set the pod's Controller ref. I mean you need to stop setting controller ref if the controller is about to be deleted. In daemon set's case, we might do it in addPod().

I'll push my changes to RC later today so I can get your comments, though it's not completed :)

@gmarek gmarek changed the title DaemonController doesn't take any actions when being deleted. Controllers doesn't take any actions when being deleted. Jun 17, 2016
@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 17, 2016
@gmarek
Copy link
Contributor Author

gmarek commented Jun 17, 2016

CC @janetkuo for deployment @soltysh for job

@caesarxuchao
Copy link
Member

#27600 is a WIP implementation for RC.

@soltysh
Copy link
Contributor

soltysh commented Jun 20, 2016

cc @Kargakis @pwittrock @mfojtik for deployments

@soltysh
Copy link
Contributor

soltysh commented Jun 20, 2016

jobs LGTM

@0xmichalis
Copy link
Contributor

Shouldn't we just not resync the object in case it is deleted? It's much simpler than handling DeletionTimestamp in the controller loop.

everything := unversioned.LabelSelector{}
if reflect.DeepEqual(d.Spec.Selector, &everything) {
dc.eventRecorder.Eventf(d, api.EventTypeWarning, "SelectingAll", "This deployment is selecting all pods. A non-empty selector is required.")
return nil
}

if d.Spec.Paused {
if d.Spec.Paused || d.DeletionTimestamp != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

A deleted deployment is different from a paused deployment; these two should be separate. I think the best fix would be to stop requeueing the deployment when it is deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this and check for the timestamp before checking for paused. #20273 changes paused deployments to do more things than simple staus updates.

@gmarek
Copy link
Contributor Author

gmarek commented Jun 20, 2016

@Kargakis - I'm not certain if I understand correctly what you're saying - do you mean that we shouldn't run syncPausedDeploymentStatus on DeploymentController if deletionTimestamp is set? That was my original idea, but if I correctly recall my discussion with @bgrant0607 we decided that we want to prevent controllers from doing any meaningful changes while we still want to update Statuses.

@0xmichalis
Copy link
Contributor

I mean that we shouldn't requeue at all on deletion:

Deletions ought to be fast so I am not sure if there is any value in updating the status of an object but I may be wrong.

@gmarek
Copy link
Contributor Author

gmarek commented Jun 20, 2016

@Kargakis - they won't be fast soon enough, when cascading deletion will be turned on. Before deleting object X we'll wait until all dependees are deleted, which can take some time - especially that Pods do have 30s grace period by default.

@gmarek
Copy link
Contributor Author

gmarek commented Jun 20, 2016

Thanks for the line - I'll look at that part of code.

@0xmichalis
Copy link
Contributor

0xmichalis commented Jun 20, 2016

@Kargakis - they won't be fast soon enough, when cascading deletion will be turned on. Before deleting object X we'll wait until all dependees are deleted, which can take some time - especially that Pods do have 30s grace period by default.

Hm, i see. Agreed

@gmarek gmarek removed the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jun 23, 2016
@gmarek
Copy link
Contributor Author

gmarek commented Jun 23, 2016

I didn't manage to finish this before vacation:/ Let's proceed with reviews.

@gmarek gmarek assigned caesarxuchao and unassigned gmarek Jun 23, 2016
@pwittrock pwittrock self-assigned this Jun 23, 2016
@pwittrock
Copy link
Member

Added myself as a reviewer for Deployments.

@caesarxuchao
Copy link
Member

@janetkuo @pwittrock do you know if the deployment controller adopts existing replication controllers? Non-empty DeleteTimestamp should prevent the adoption as well.

@0xmichalis
Copy link
Contributor

@janetkuo @pwittrock do you know if the deployment controller adopts existing replication controllers? Non-empty DeleteTimestamp should prevent the adoption as well.

Yes, Deployments can adopt replica sets.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 4, 2016
@0xmichalis
Copy link
Contributor

Deployment controller changes LGTM

@gmarek
Copy link
Contributor Author

gmarek commented Jul 4, 2016

@mikedanese - can you take a look at DaemonController changes?

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 7, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 7, 2016
@gmarek
Copy link
Contributor Author

gmarek commented Jul 7, 2016

Ping @mikedanese

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 8, 2016
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2016
@mikedanese
Copy link
Member

DaemonsetController change LGTM

@gmarek
Copy link
Contributor Author

gmarek commented Jul 11, 2016

Squashed commit. @caesarxuchao - can you apply the final LGTM?

@@ -289,6 +289,24 @@ func TestSufficentCapacityNodeDaemonLaunchesPod(t *testing.T) {
syncAndValidateDaemonSets(t, manager, ds, podControl, 1, 0)
}

// DaemonSets should place onto nodes with sufficient free resource
Copy link
Member

@caesarxuchao caesarxuchao Jul 11, 2016

Choose a reason for hiding this comment

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

Could you update the comment? Or just remove it, the test name has enough information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yikes. Thanks for noticing.

@caesarxuchao
Copy link
Member

Just a nit, otherwise LGTM.

@gmarek
Copy link
Contributor Author

gmarek commented Jul 12, 2016

Done. @caesarxuchao PTAL

@k8s-bot
Copy link

k8s-bot commented Jul 12, 2016

GCE e2e build/test passed for commit 95de5a3.

@caesarxuchao
Copy link
Member

LGTM. Thanks!!

@caesarxuchao caesarxuchao added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 12, 2016
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Jul 12, 2016

GCE e2e build/test passed for commit 95de5a3.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit d90cc90 into kubernetes:master Jul 12, 2016
@gmarek gmarek deleted the controllerDeletion branch August 30, 2016 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants