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

cloud node controller: implement with workqueues and node lister #94736

Merged
merged 1 commit into from
Sep 17, 2020

Conversation

nicolehanjing
Copy link
Member

@nicolehanjing nicolehanjing commented Sep 11, 2020

As title

What type of PR is this?
/kind cleanup

What this PR does / why we need it:
Refactor the node controller to use Workqueue and Node Lister so that Informer watches for changes on the current state of Kubernetes objects and sends events to Workqueue where events are then popped up by worker(s) to process.
If we can use Workqueue in the implementation, it will be more readable and gain better maintenance.

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 11, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @HaibaraAi96!

It looks like this is your first PR to kubernetes/kubernetes 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kubernetes has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 11, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @HaibaraAi96. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@nicolehanjing
Copy link
Member Author

/assign @andrewsykim

@k8s-ci-robot k8s-ci-robot added sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 11, 2020
// Finally, if no error occurs we Forget this item so it does not
// get queued again until another change happens.
cnc.workqueue.Forget(obj)
klog.Infof("Successfully synced '%s'", key)
Copy link
Member

Choose a reason for hiding this comment

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

This is probably too verbose for Infof, maybe increase verbosity here:

klog.V(4).Infof("Successfully synced '%s'", key)

// Start a loop to periodically update the node addresses obtained from the cloud
wait.Until(func() { cnc.UpdateNodeStatus(context.TODO()) }, cnc.nodeStatusUpdateFrequency, stopCh)
go wait.Until(cnc.runWorker, cnc.nodeStatusUpdateFrequency, stopCh)
Copy link
Member

Choose a reason for hiding this comment

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

I think we still want the periodic run of UpdateNodeStatus based on cnc.nodeStatusUpdateFrequency and syncHandler should actually only call UpdateCloudNode and not UpdateNodeStatus. So this should look like this instead:

go wait.Until(func() { cnc.UpdateNodeStatus(context.TODO()) }, cnc.nodeStatusUpdateFrequency, stopCh)
go wait.Until(c.runWorker, time.Second, stopCh)

@andrewsykim
Copy link
Member

Thanks for the PR @HaibaraAi96!

I think overall we need this PR to update cloud node controller to use workqueues so that failed syncs aren't dropped. I left some initial feedback.

@nicolehanjing
Copy link
Member Author

/retest

@k8s-ci-robot
Copy link
Contributor

@HaibaraAi96: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@andrewsykim
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 14, 2020
@nicolehanjing
Copy link
Member Author

/retest

return nil
}

// Get the Node resource with this namespace/name
Copy link
Member

Choose a reason for hiding this comment

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

"Get the Node resource with this name" since nodes do not have namespaces.

// The Node resource may no longer exist, in which case we stop
// processing.
if apierrors.IsNotFound(err) {
utilruntime.HandleError(fmt.Errorf("Node '%s' in work queue no longer exists", key))
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this line is necessary since nodes not existing is not an error case here.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, will remove that

@@ -295,7 +432,8 @@ func (cnc *CloudNodeController) updateNodeAddress(ctx context.Context, node *v1.
// in a retry-if-conflict loop.
type nodeModifier func(*v1.Node)

func (cnc *CloudNodeController) UpdateCloudNode(ctx context.Context, _, newObj interface{}) {
// UpdateCloudNode handles updating existing nodes registered with the cloud taint.
func (cnc *CloudNodeController) UpdateCloudNode(ctx context.Context, newObj interface{}) {
Copy link
Member

Choose a reason for hiding this comment

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

maybe just name this syncNode now?

Copy link
Member

Choose a reason for hiding this comment

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

Also thinking that syncNode should receive the name of the node instead of newObj interface{} and in initializeNode we fetch the latest node from the informer cache line 478, instead of from apiserver.

@nicolehanjing
Copy link
Member Author

/retest

@@ -347,60 +433,51 @@ func (cnc *CloudNodeController) initializeNode(ctx context.Context, node *v1.Nod
})
if err != nil {
utilruntime.HandleError(err)
Copy link
Member

Choose a reason for hiding this comment

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

this can be removed as well

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 16, 2020
@nicolehanjing nicolehanjing force-pushed the mynodecontroller branch 2 times, most recently from d0abb51 to 91c641b Compare September 16, 2020 20:37
if err != nil {
return err
var curNode *v1.Node

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove line here

@nicolehanjing nicolehanjing force-pushed the mynodecontroller branch 2 times, most recently from 1f587fb to d654864 Compare September 16, 2020 21:30
@nicolehanjing nicolehanjing changed the title cloud provider: refactor node controller cloud node controller: implement with workqueues and node lister Sep 16, 2020
@nicolehanjing
Copy link
Member Author

/test pull-kubernetes-e2e-gce-ubuntu-containerd

@andrewsykim
Copy link
Member

/retest

Copy link
Member

@andrewsykim andrewsykim left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

Thanks @HaibaraAi96!

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 16, 2020
@andrewsykim
Copy link
Member

/retest

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewsykim, HaibaraAi96

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 Sep 16, 2020
@andrewsykim
Copy link
Member

/milestone v1.20

@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Sep 17, 2020
@k8s-ci-robot k8s-ci-robot merged commit aaccd5f into kubernetes:master Sep 17, 2020
if err != nil {
return err
var curNode *v1.Node
if cnc.cloud.ProviderName() == "gce" {
Copy link
Member

Choose a reason for hiding this comment

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

FYI @cheftako we should probably discuss getting rid of this custom check for GCE, I can't recall the initial reason behind the GCE specific check. Would probably be nice to have something generic here.

Copy link
Member

Choose a reason for hiding this comment

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

+1. Most of these checks are because the test needs something which wasn't generally available. Not sure about this particular test but I've written a few of these. Its frequently something like the webhook tests. You need to create a special test container and deploy it to your registry. The intention was always that other cloud providers would follow adding the container to their registry.

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/cloudprovider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants