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

🐛 Add ability for nodeToMachines to filter by clusterName and namespace #4513

Merged
merged 1 commit into from
May 18, 2021

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Apr 22, 2021

What this PR does / why we need it:
This is a best effort to filter machines by clusterName and namespace when reconciling from a node event.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #3831

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 22, 2021
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 22, 2021
@enxebre enxebre changed the title Add ability for nodeToMachines to filter by clusterName and namespace 🐛 Add ability for nodeToMachines to filter by clusterName and namespace Apr 22, 2021
@mrajashree
Copy link
Contributor

lgtm

controllers/machine_controller.go Outdated Show resolved Hide resolved
controllers/machine_controller.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 23, 2021
@enxebre
Copy link
Member Author

enxebre commented Apr 23, 2021

@vincepri I added tests for all the cases. I used a testEnv since fakeClient does not support indexes.
I also created #4518 and so then we can also filter by providerID. Just realised the node.Spec is not accesible in MapFunc so can't use it to filter.

targetNode := &corev1.Node{
ObjectMeta: metav1.ObjectMeta{
Name: "node-1",
Namespace: ns.Name,
Copy link
Member

Choose a reason for hiding this comment

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

As Nodes are cluster-wide setting the Namespace doesn't make a lot of sense imho. Should we also prefix this again to make sure we don't clash with other tests?

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!

}, timeout).Should(BeTrue())

// Fake nodes for actual test of nodeToMachine.
FakeNodes := []*corev1.Node{
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
FakeNodes := []*corev1.Node{
fakeNodes := []*corev1.Node{

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!

@enxebre enxebre force-pushed the node-to-machine branch from 4f96587 to 2ac5704 Compare May 11, 2021 10:34
This is a best effort to filter machines by clusterName and namespace when reconciling from a node event.
@enxebre enxebre force-pushed the node-to-machine branch from 2ac5704 to 61d8ca8 Compare May 11, 2021 10:35
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 11, 2021
@sbueringer
Copy link
Member

/lgtm

Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

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 May 18, 2021
@k8s-ci-robot k8s-ci-robot merged commit 02f7225 into kubernetes-sigs:master May 18, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone May 18, 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

Node to Machine mapping function should filter by namespace and cluster
5 participants