-
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
⚠️ Unexport MachineHealthCheck patchUnhealthyTargets
method
#4579
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. |
Hi @mshitrit. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
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.
/ok-to-test
@@ -145,7 +145,7 @@ func (r *MachineHealthCheckReconciler) Reconcile(ctx context.Context, req ctrl.R | |||
defer func() { | |||
// Always attempt to patch the object and status after each reconciliation. | |||
// Patch ObservedGeneration only if the reconciliation completed successfully | |||
patchOpts := []patch.Option{} | |||
var patchOpts []patch.Option |
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.
Why is this preferred? These two lines are functionally equivalent, I think this is very much a style preference. Which is most used throughout the codebase?
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.
I think that's the most common argumentation: https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices
Just saw that there is no actual explanation in there :)
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.
According to go lint the second one is preferred because there is no memory allocation (just declaring a slice that is nil)
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.
@mshitrit Did make lint
fail on this?
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.
I didn't try but I find it hard to believe that it will.
I caught it because of my golint plugin on my IDE - it's considered a "weak warning" which is pretty minor.
@@ -288,7 +288,7 @@ func (r *MachineHealthCheckReconciler) reconcile(ctx context.Context, logger log | |||
conditions.MarkTrue(m, clusterv1.RemediationAllowedCondition) | |||
|
|||
errList := r.PatchUnhealthyTargets(ctx, logger, unhealthy, cluster, m) | |||
errList = append(errList, r.PatchHealthyTargets(ctx, logger, healthy, cluster, m)...) | |||
errList = append(errList, r.PatchHealthyTargets(ctx, logger, healthy, m)...) |
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.
Why was the cluster
removed from this list in this change? Is the cluster not actually used in the PatchHealthyTargets
?
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.
Yep, exactly
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.
/hold
@mshitrit Can you please open issues before pull requests to explain why a change is needed? I'm not inclined to merge most of the proposed changes because these are personal preferences.
func (r *MachineHealthCheckReconciler) PatchHealthyTargets(ctx context.Context, logger logr.Logger, healthy []healthCheckTarget, cluster *clusterv1.Cluster, m *clusterv1.MachineHealthCheck) []error { | ||
errList := []error{} | ||
// PatchHealthyTargets patches healthy machines with MachineHealthCheckSucceededCondition. | ||
func (r *MachineHealthCheckReconciler) PatchHealthyTargets(ctx context.Context, logger logr.Logger, healthy []healthCheckTarget, m *clusterv1.MachineHealthCheck) []error { |
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 is technically a breaking change because this method is exported (which probably shouldn't be)
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.
@JoelSpeed Should we unexport this method and remove the Cluster parameter?
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.
Seems this method was added as part of #3901, which also added PatchUnhealthyTargets
. I think it's reasonable to unexport this, but in that case, I would suggest we do the same for PatchUnhealthyTargets
too for consistency.
Seems the method has never used the cluster parameter so +1 to dropping that.
@@ -75,7 +75,7 @@ type MachineHealthCheckReconciler struct { | |||
} | |||
|
|||
func (r *MachineHealthCheckReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error { | |||
controller, err := ctrl.NewControllerManagedBy(mgr). | |||
managedController, err := ctrl.NewControllerManagedBy(mgr). |
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.
Please revert this.
Looking at the proposed changes, even though the variable collides with the package name, it reads much better as it is today. Moreover, it's consistent with the rest of the codebase and the controller package isn't used within this method.
Hi I've updated the PR. |
c9b1b4b
to
906058b
Compare
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.
/retitle patchUnhealthyTargets
method
@@ -440,7 +440,7 @@ func (r *MachineHealthCheckReconciler) clusterToMachineHealthCheck(o client.Obje | |||
} | |||
|
|||
// This list should only contain MachineHealthChecks which belong to the given Cluster | |||
requests := []reconcile.Request{} | |||
var requests []reconcile.Request |
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.
Let's revert these declarations? It's mostly a style preference (and a small saving in initial memory allocation, which is probably ok in most uses). I'd rather not set a precedent to merge changes to declarations for small gains.
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.
Hmm I'm not sure I follow.
I think we can probable agree that var requests []reconcile.Request
is better than requests := []reconcile.Request{}
which is also supported by the official goland code standards.
I agree it's a minor change and I can understand the argument against merging a minor change, but since it's merged along with other changes and not all by itself I don't think this is a valid argument (unless we decide the whole PR is too minor to be merged).
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.
I think we can probable agree that var requests []reconcile.Request is better than requests := []reconcile.Request{}
I'm trying to avoid these kind of discussions, which are based mostly on personal preferences.
but since it's merged along with other changes and not all by itself I don't think this is a valid argument
No. We make it an effort to keep the pull request focused on one task at hand. If all PRs start bringing in minor style changes, the noise to signal ratio becomes too high.
unless we decide the whole PR is too minor to be merged
I'm fine merging the unexporting of the method, and removing the unused parameter. The rest of the changes (minor or not) are personal preferences that I'm not comfortable merging, even if they were standing in a different PR on their own.
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.
I guess we'll have to agree to disagree on that.
But since I'm a new guest to this repo I think it's only common curtsy to respect the house rules 🙂
patchUnhealthyTargets
method
Signed-off-by: Michael Shitrit <[email protected]>
@mshitrit: 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. |
/hold cancel /lgtm |
/lgtm |
Hi All, |
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
[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 |
@mshitrit Just fyi |
Tidy: changed empty slice declaration, modified var name that collides with pkg name, fixed typo and removed unused func variable
Signed-off-by: Michael Shitrit [email protected]
Not much just a bit of tidy up fixing couple of minor cosmetic stuff: