-
Notifications
You must be signed in to change notification settings - Fork 561
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
use cluster api patch helper to do the scope close #1020
Conversation
Welcome @xrmzju! |
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 @xrmzju. Thanks for your PR. I'm waiting for a kubernetes-sigs or kubernetes 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. |
/hold |
@xrmzju It seems that the issue can be fixed by issuing Status().Patch() before the normal Patch(), see kubernetes-sigs/cluster-api#1261 |
I signed it |
@vincepri this is my first solution when i found the overwrite issue. but i found another problem about it. in my provider controller, i will generate certs info if not specified in the provider spec and store it in a secret. after first reconcile, the certs info and secret are generated normally. after status.Patch, it will trigger a new update event, and the cert info of the upcoming object is still nil<status.Patch does not update spec>, so the second reconcile round would do the generate certs action again without update the secret info(cause i'll try to get the secret, if exist i will not create it), that causes inconsistence between the cert info in the spec and stored in the secret. |
@xrmzju Thanks for the detailed explanation! The change LGTM, can we add unit tests to cover the behaviors you've described? It'd be great to cover both the failing and success cases with DeepCopy, so we can track this issue. @detiber is also working on a generic implementation of patching in Cluster API, once that's ready we should switch to that one. |
/ok-to-test |
@detiber your patch helper will handle this, won't it? |
That is correct, an example of usage can be found here: kubernetes-retired/cluster-api-bootstrap-provider-kubeadm#148 |
@xrmzju do you want to adjust this PR to be based on the new patch helper & the example Jason provided? If not, please let us know, and we can get someone else to work on it. |
pkg/cloud/scope/machine.go
Outdated
} | ||
|
||
return nil | ||
return m.patchHelper.Patch(context.Background(), m.Machine) |
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.
return m.patchHelper.Patch(context.Background(), m.Machine) | |
return m.patchHelper.Patch(context.Background(), m.AWSMachine) |
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.
my fault... done.
pkg/cloud/scope/cluster.go
Outdated
@@ -66,13 +67,17 @@ func NewClusterScope(params ClusterScopeParams) (*ClusterScope, error) { | |||
params.AWSClients.ELB = elb.New(session) | |||
} | |||
|
|||
helper, err := patch.NewHelper(params.AWSCluster, params.Client) | |||
if err != nil { | |||
return nil, errors.Errorf("failed to init patch helper: %v", err) |
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 use errors.Wrap
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.
done
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.
done
pkg/cloud/scope/machine.go
Outdated
@@ -63,25 +63,28 @@ func NewMachineScope(params MachineScopeParams) (*MachineScope, error) { | |||
params.Logger = klogr.New() | |||
} | |||
|
|||
helper, err := patch.NewHelper(params.AWSMachine, params.Client) | |||
if err != nil { | |||
return nil, errors.Errorf("failed to init patch helper: %v", err) |
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 use errors.Wrap
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.
done
}, nil | ||
} | ||
|
||
// MachineScope defines a scope defined around a machine and its cluster. | ||
type MachineScope struct { | ||
logr.Logger | ||
patch client.Patch |
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.
A lot of times we separate the unexported from the exported fields, as was the case here. I'd recommend you keep this pattern - move patchHelper
back up here, and preserve the blank line in between client
and Cluster
.
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, i'll keep that pattern
/lgtm /assign @detiber |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ncdc, xrmzju 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 |
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.
/lgtm
/hold cancel |
What this PR does / why we need it:
fix issue: #1019
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 #
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
Release note: