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 unit test coverage for machineDeployments. reconcileOldMachineSets #4498

Conversation

enxebre
Copy link
Member

@enxebre enxebre commented Apr 20, 2021

What this PR does / why we need it:
Increase unit test coverage fo machineDeployments rolling upgrades. TestReconcileOldMachineSets.

Follow up PR for #4495 related to #4457

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 #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 20, 2021
@enxebre
Copy link
Member Author

enxebre commented Apr 20, 2021

/hold
Needs #4495

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 20, 2021
@enxebre enxebre changed the title Unit test md rolling reconcile old machine sets 🌱 Add unit test coverage for machineDeployments. reconcileOldMachineSets Apr 20, 2021
@enxebre enxebre force-pushed the unit-test-md-rolling-reconcileOldMachineSets branch 3 times, most recently from f35ea8f to ad3323e Compare April 21, 2021 11:01
// Safely scale down all old machine sets with unhealthy replicas. Replica set will sort the machines in the order
// such that not-ready < ready, unscheduled < scheduled, and pending < running. This ensures that unhealthy replicas will
// been deleted first and won't increase unavailability.
// Scale down all old MachineSets with any unhealthy replicas. MachineSet will honour Spec.DeletePolicy
Copy link
Member Author

Choose a reason for hiding this comment

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

This comment seemed very old left over from pod/replicaSet/Deployment. Please review my update to consolidate with reality.

@enxebre enxebre force-pushed the unit-test-md-rolling-reconcileOldMachineSets branch from ad3323e to 7040d62 Compare April 21, 2021 11:05
@enxebre
Copy link
Member Author

enxebre commented Apr 21, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 21, 2021
@enxebre
Copy link
Member Author

enxebre commented Apr 21, 2021

2/2292 Tests Failed. | expand_less
-- | --
sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile/When_remediationTemplate_is_set_and_node_transitions_back_to_healthy,_new_Remediation_Request_should_be_deleted expand_more2s | sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile/When_remediationTemplate_is_set_and_node_transitions_back_to_healthy,_new_Remediation_Request_should_be_deleted expand_more | 2s
sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile/When_remediationTemplate_is_set_and_node_transitions_back_to_healthy,_new_Remediation_Request_should_be_deleted expand_more | 2s
sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile expand_more | sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile expand_more
sigs.k8s.io/cluster-api/controllers: TestMachineHealthCheck_Reconcile expand_more

known flake?

/test pull-cluster-api-test-main

@sbueringer
Copy link
Member

sbueringer commented Apr 21, 2021

@enxebre I think yes. Maybe this link helps for identifying flakes more easily: https://testgrid.k8s.io/sig-cluster-lifecycle-cluster-api#capi-test-main&exclude-non-failed-tests=&sort-by-failures=&width=12&group-by-hierarchy-pattern=(sigs.k8s.io%2Fcluster-api%2F%5B%5E%5C.%5D*.%7CTest%5B%5E%5C%2F%5D*%2F%7C.*)

That's the best testgrid filter I could come up with. But those flakes are so rare that you can just run the test twice and if the test fails both times it's probably caused by a change in the code.

@enxebre enxebre force-pushed the unit-test-md-rolling-reconcileOldMachineSets branch 2 times, most recently from 5843b7c to 8941326 Compare April 22, 2021 10:28
Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

one nit, not sure how we handle this usually, apart from that lgtm


err := r.reconcileOldMachineSets(ctx, allMachineSets, tc.oldMachineSets, tc.newMachineSet, tc.machineDeployment)
if tc.error != nil {
g.Expect(err.Error()).To(BeEquivalentTo(tc.error.Error()))
Copy link
Member

Choose a reason for hiding this comment

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

if tc.error != nil and err == nil this will lead to a nil pointer, probably better if we guard against that. (same in TestReconcileNewMachineSet above)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thanks!

@enxebre enxebre force-pushed the unit-test-md-rolling-reconcileOldMachineSets branch 2 times, most recently from 50565c3 to be93472 Compare April 29, 2021 09:18
@enxebre enxebre force-pushed the unit-test-md-rolling-reconcileOldMachineSets branch from be93472 to a31cb9b Compare April 29, 2021 09:25
@sbueringer
Copy link
Member

/lgtm
Thx! Very nice to see the test coverage improve :)

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

vincepri commented May 5, 2021

/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 5, 2021
@k8s-ci-robot k8s-ci-robot merged commit ff489c8 into kubernetes-sigs:master May 5, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.4 milestone May 5, 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.

4 participants