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

🌱 refactor failure domains logic out of controlplane internal package #4160

Merged

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Feb 9, 2021

What this PR does / why we need it:

What: In preparation for #3358, this PR moves the failure domains business logic out of controlplane/kubeadm/internal into util/. There should be no behavior changes as a result of this PR.
Why: Nothing in failure_domains.go, machine_filters.go and machine_collection.go is kubeadm or control plane specific. The logic should be available for reuse for other packages outside the KCP implementation.
How:

  • controlplane/kubeadm/internal/failure_domain.go → util/failuredomains/failure_domains.go
  • controlplane/kubeadm/internal/machine_collection.go → util/collections/machine_collection.go
  • controlplane/kubeadm/internal/machinefilters/machine_filters.go → util/collections/machine_filters.go
  • moved the global internal Log var to controlplane/kubeadm/internal/control_plane.go
  • renamed FilterableMachineCollection to Machines
  • changed PickMost signature (from func PickMost(c *ControlPlane, machines FilterableMachineCollection) *string to func PickMost(failureDomains clusterv1.FailureDomains, groupMachines, machines collections.Machines) *string) to allow make it generic, just like PickFewest (nothing in the func logic is control plane specific).

Note that none of these should be breaking changes as the modified code was previously part of the internal package which by Go convention cannot be imported.

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Feb 9, 2021
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 9, 2021
@CecileRobertMichon CecileRobertMichon force-pushed the refactor-cp-utils branch 3 times, most recently from f217a4b to cb305d8 Compare February 9, 2021 00:51
@vincepri
Copy link
Member

vincepri commented Feb 9, 2021

/milestone v0.4.0

@k8s-ci-robot k8s-ci-robot added this to the v0.4.0 milestone Feb 9, 2021
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

Thanks for this refactor @CecileRobertMichon !

Two nits not blocking and some question about machine_filters.go:

  • does it makes sense to have machine filters a a separate package or should we merge machine filters into collections given that they are used together?
  • should we leave KCP specific filters somewhere in KCP and move under util only generic machine filters (instead of moving everything)?

controlplane/kubeadm/controllers/scale_test.go Outdated Show resolved Hide resolved
util/collections/machine_collection.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 10, 2021
@fabriziopandini
Copy link
Member

/lgtm

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

/approve

will follow up with #2062

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 Feb 12, 2021
@k8s-ci-robot k8s-ci-robot merged commit 522b569 into kubernetes-sigs:master Feb 13, 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants