Skip to content

✨ Refactor MS controller status patching #1944

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

Merged
merged 1 commit into from
Dec 30, 2019

Conversation

vincepri
Copy link
Member

@vincepri vincepri commented Dec 20, 2019

Signed-off-by: Vince Prignano [email protected]

What this PR does / why we need it:

This PR improves the MachineSet code by:

  • Moves all the code to sync Status to machineset_controller.go.
  • Uses patch instead of update for the status resource, but fall back to Update if the validation fails (explained in comment).
  • Moves setting Status.Selector in calculateStatus instead of the main reconciler function.

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 #1689

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 20, 2019
@k8s-ci-robot k8s-ci-robot requested review from detiber and ncdc December 20, 2019 17:10
@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 Dec 20, 2019
@vincepri
Copy link
Member Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 20, 2019
@vincepri vincepri force-pushed the ms-controller-patch branch from 2fd1671 to acd13dc Compare December 20, 2019 17:55
@vincepri
Copy link
Member Author

/hold cancel
/assign @ncdc

@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 Dec 20, 2019
Copy link
Contributor

@ncdc ncdc left a comment

Choose a reason for hiding this comment

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

The bulk of this was just copy/paste across files, right?

@vincepri vincepri force-pushed the ms-controller-patch branch from acd13dc to 4b738bc Compare December 23, 2019 16:51
@vincepri
Copy link
Member Author

/assign @detiber

Copy link
Member

@detiber detiber left a comment

Choose a reason for hiding this comment

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

Question related to ignoring the error when converting the labelselector, otherwise, lgtm


// Copy label selector to its status counterpart in string format.
// This is necessary for CRDs including scale subresources.
selector, _ := metav1.LabelSelectorAsSelector(&ms.Spec.Selector)
Copy link
Member

Choose a reason for hiding this comment

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

Is it actually safe to ignore the error here? I know we have a validating webhook now, but that wouldn't affect pre-existing stored resources (unless they have been read and then re-written to the new storage version).

Copy link
Member Author

Choose a reason for hiding this comment

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

I figured given that we're coming from a LabelSelector type that this function should never return an error, unless something very wrong happened.

I'll add it though, just to be safe

@vincepri vincepri force-pushed the ms-controller-patch branch from 4b738bc to 4c1687a Compare December 30, 2019 17:52
@vincepri vincepri force-pushed the ms-controller-patch branch from 4c1687a to a6db0cc Compare December 30, 2019 17:56
@detiber
Copy link
Member

detiber commented Dec 30, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 30, 2019
@k8s-ci-robot k8s-ci-robot merged commit c246f9b into kubernetes-sigs:master Dec 30, 2019
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