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

Wire contexts to Apps controllers #105377

Merged
merged 1 commit into from
Oct 14, 2021

Conversation

damemi
Copy link
Contributor

@damemi damemi commented Sep 30, 2021

What type of PR is this?

/kind design

What this PR does / why we need it:

This wires a context to Apps controllers in kube-controller-manager, so that KCM can eventually release on cancel.

This originally came from PR #101379, which builds on top of #101125

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/design Categorizes issue or PR as related to design. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 30, 2021
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 30, 2021
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.

I found still a few context.TODO() instances I've listed above.

/assign
/triage accepted
/priority backlog

pkg/controller/daemon/daemon_controller.go Show resolved Hide resolved
@@ -141,22 +141,22 @@ func NewStatefulSetController(
}
Copy link
Contributor

Choose a reason for hiding this comment

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

a few more in:
pkg/controller/statefulset/stateful_set_status_updater.go
pkg/controller/statefulset/stateful_pod_control.go

Copy link
Contributor

Choose a reason for hiding this comment

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

This comment still holds.

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 30, 2021
@damemi damemi force-pushed the wire-contexts-apps branch 2 times, most recently from 2828eb2 to 55b38c3 Compare September 30, 2021 17:01
@spiffxp
Copy link
Member

spiffxp commented Sep 30, 2021

/test pull-kubernetes-node-e2e-containerd
ref: #105381

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels Sep 30, 2021
@damemi damemi force-pushed the wire-contexts-apps branch 2 times, most recently from 40befc1 to 6f5471d Compare September 30, 2021 19:21
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 30, 2021
@damemi
Copy link
Contributor Author

damemi commented Sep 30, 2021

/retest

@damemi
Copy link
Contributor Author

damemi commented Oct 1, 2021

/retest
Sorry for all the test failure spam, I had some trouble finding all of the missing updates locally.

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 few more nits, but we can handle them in a followups.
/lgtm
/approve

pkg/controller/daemon/daemon_controller.go Show resolved Hide resolved
pkg/controller/replicaset/replica_set.go Show resolved Hide resolved
@@ -141,22 +141,22 @@ func NewStatefulSetController(
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment still holds.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2021
@soltysh
Copy link
Contributor

soltysh commented Oct 7, 2021

/lgtm cancel
Stefan's point is legit and should be addressed before merging this

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 7, 2021
@alculquicondor
Copy link
Member

Consider a retitle of the PR, as I don't think all Apps controller are covered.

@damemi
Copy link
Contributor Author

damemi commented Oct 7, 2021

Consider a retitle of the PR, as I don't think all Apps controller are covered.

This is referring to the KCM Apps controllers, in cmd/kube-controller-manager/app/apps.go... is that okay?

@alculquicondor
Copy link
Member

Uhm.. kind of tricky, as batch is under sig-apps, but it's listed separately. Maybe you can say core apps (the core API). But it's a nit.

@damemi damemi force-pushed the wire-contexts-apps branch 2 times, most recently from 04bb6a9 to 3405184 Compare October 8, 2021 17:56
@damemi
Copy link
Contributor Author

damemi commented Oct 8, 2021

/retest

@nikhita
Copy link
Member

nikhita commented Oct 11, 2021

/kind feature
/remove-kind design

We are removing the kind/design label. Please see kubernetes/community#5641 for more details.

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/design Categorizes issue or PR as related to design. labels Oct 11, 2021
pkg/controller/daemon/daemon_controller.go Show resolved Hide resolved
pkg/controller/controller_ref_manager.go Outdated Show resolved Hide resolved
pkg/controller/daemon/daemon_controller.go Show resolved Hide resolved
set *apps.StatefulSet,
status *apps.StatefulSetStatus) error {
// don't wait due to limited number of clients, but backoff after the default number of steps
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
set.Status = *status
_, updateErr := ssu.client.AppsV1().StatefulSets(set.Namespace).UpdateStatus(context.TODO(), set, metav1.UpdateOptions{})
_, updateErr := ssu.client.AppsV1().StatefulSets(set.Namespace).UpdateStatus(ctx, set, metav1.UpdateOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to pass context here through RetryOnConflict, so revert this back to context.TODO for now and we'll need a separate PR to add RetryOnConflictWithContext similarly to how we have wait.UntilWithContext as discussed with @sttts offline.

@@ -310,15 +310,15 @@ func NewReplicaSetControllerRefManager(
// If the error is nil, either the reconciliation succeeded, or no
// reconciliation was necessary. The list of ReplicaSets that you now own is
// returned.
func (m *ReplicaSetControllerRefManager) ClaimReplicaSets(sets []*apps.ReplicaSet) ([]*apps.ReplicaSet, error) {
func (m *ReplicaSetControllerRefManager) ClaimReplicaSets(ctx context.Context, sets []*apps.ReplicaSet) ([]*apps.ReplicaSet, error) {
var claimed []*apps.ReplicaSet
var errlist []error

match := func(obj metav1.Object) bool {
return m.Selector.Matches(labels.Set(obj.GetLabels()))
}
adopt := func(obj metav1.Object) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need the context being argument here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually missed all of these adopt functions... updated to add the param to them all. Could you check that I did that right again? This one looks similar to the last, where I think I need to pass ctx as an extra parameter along with the functions, but I'm pretty sure I actually need that now

pkg/controller/daemon/daemon_controller.go Show resolved Hide resolved
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.

One more nit about adopt function in pkg/controller/controller_ref_manager.go and what about that wait.UntilWithContext in pkg/controller/daemon/daemon_controller.go

@@ -56,7 +56,8 @@ func (ssu *realStatefulSetStatusUpdater) UpdateStatefulSetStatus(
// don't wait due to limited number of clients, but backoff after the default number of steps
return retry.RetryOnConflict(retry.DefaultRetry, func() error {
set.Status = *status
_, updateErr := ssu.client.AppsV1().StatefulSets(set.Namespace).UpdateStatus(ctx, set, metav1.UpdateOptions{})
// TODO: This context.TODO should use a real context once we have RetryOnConflictWithContext
_, updateErr := ssu.client.AppsV1().StatefulSets(set.Namespace).UpdateStatus(context.TODO(), set, metav1.UpdateOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

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.

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 14, 2021
@sttts
Copy link
Contributor

sttts commented Oct 14, 2021

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damemi, soltysh, sttts

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit f27e471 into kubernetes:master Oct 14, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 14, 2021
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. area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/backlog Higher priority than priority/awaiting-more-evidence. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants