-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🌱 refactor: standardize machine filter functions and improve testing #4207
🌱 refactor: standardize machine filter functions and improve testing #4207
Conversation
@@ -1377,12 +1303,20 @@ func TestIsDeleteNodeAllowed(t *testing.T) { | |||
expectedError: errNilNodeRef, | |||
}, | |||
{ | |||
name: "no control plane members", | |||
cluster: &clusterv1.Cluster{}, | |||
name: "no control plane members", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test was not fully correct as the machines were being excluded from the filter by not having the right cluster name label and/or namespace. Added all the required object metadata so it's actually checking that the described missing piece (eg. no control plane members) is what causes the error.
@@ -46,6 +46,10 @@ func TestKubeadmControlPlaneReconciler_updateStatusNoMachines(t *testing.T) { | |||
} | |||
|
|||
kcp := &controlplanev1.KubeadmControlPlane{ | |||
TypeMeta: metav1.TypeMeta{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one got me debugging the test for a while 😬
the test was actually a no-op because of https://github.com/kubernetes-sigs/cluster-api/pull/4207/files#diff-a6639fd91ffb9cff50ef1f3af76ec2371aa5c41e0d28b98b651cb9193eeaab62L52
Since the fake management cluster Management
was nil, it wasn't actually listing machines and filtering them, it was just returning ALL machines that were passed into managementCluster.Machines. When I changed it to actually using the filter, it was failing because the Machines weren't "owned" by KCP since the KCP TypeMeta was missing here but not in the owner ref, it was comparing empty string to the ref's Kind, Group, and Version.
All of should be removed in #4078 already |
/milestone v0.4.0 |
1acc194
to
ff3ae11
Compare
ff3ae11
to
f35662d
Compare
All 4 are deprecated in alpha3: https://github.com/kubernetes-sigs/cluster-api/blob/release-0.3/util/util.go |
836a87e
to
baa1241
Compare
@MarcelMue @fabriziopandini thanks for the reviews. Now that #4078 has merged I've rebased this PR and addressed your comments, PTAL. |
baa1241
to
b1c8248
Compare
@CecileRobertMichon: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
/lgtm |
/approve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon, 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 |
What this PR does / why we need it: The util, controllers, kcp internal packages had overlapping functions that fetch or filter many machines. Some functions use the clusterv1.MachineList type, others use []*clusterv1.Machine, others use collections.Machines. This PR standardizes the use of filter functions in util/collections across the codebase.
(Issue came out this discussion: #2037 (comment))
In addition, I found a few "bugs" in tests of those functions - tests that weren't actually testing what they said they were testing so I fixed those.
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 #2062