-
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
⚠️ Improve Context handling in clusterctl #8939
Conversation
Overall change lgtm. This is affecting multiple public functions so we might want to consider a deprecation notice, not sure what would be best way here given the surface of the change though. |
Didn't have time to review. Just a quick note about API changes in clusterctl:
|
Hey, thanks for your comments! I think capi operator is the main consumer of clusterctl functions, and we are okay with this change. Although there are a lot of changes, they are very primitive, 80% of them is just about adding |
It will take some time for me to review such a big PR; it would be great if clusterctl reviewers can make a preliminary pass first
We have many other users that have built tooling or automation on top of clusterctl functions; in fact clusterctl has been built as a library for those use cases, and the operator was added on top later. Considering this, even if we are allowed to do such changes, given that they are so extensive I think we should advertise them a little bit and let the community provide feedback before merging at this stage of the release. |
I can take a pass at this. |
@ykakarap thanks! ping me here or in slack if you have any questions about this PR. |
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.
Overall LGTM.
/hold |
c6a948a
to
d69185a
Compare
d69185a
to
105ddb7
Compare
105ddb7
to
d69185a
Compare
d69185a
to
fb926c4
Compare
/test pull-cluster-api-test-main |
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.
Nice work! This must have taken a while. Everything looks pretty straightforward to me. Just had a question about if we can use the context we're passing in for logs.
} | ||
|
||
func (cm *certManagerClient) install() error { | ||
func (cm *certManagerClient) install(ctx context.Context) 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.
In the line below, can we get a logger from the context now that we're passing one in? I'm not sure as we're not in a controller.
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.
Yeah, technically we can. sigs.k8s.io/controller-runtime/pkg/log
provides required mechanisms to do so, and we can replace log := logf.Log
with log := crlog.FromContext(ctx)
.
The issue is that the current pattern is found in many places in the code, not just where we pass the context (for instance here).
So I believe getting a logger from the context is achievable, but not within the scope of this PR, because a change like that would make it harder to review.
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.
That's fine by me, this PR is already pretty large, and we can consider a follow up if we still want a log from context.
/lgtm |
LGTM label has been added. Git tree hash: 37e42ff7f954fb3b54ee354a989884eca5cbb6af
|
@Fedosin I propose to move forward with this PR by changing the PR type into breaking change and adding a note about this change into https://main.cluster-api.sigs.k8s.io/developer/providers/migrations/v1.5-to-v1.6 @sbueringer @killianmuldoon opinions? |
/test pull-cluster-api-e2e-full-main |
Thank you very much!! /lgtm /hold I'm planning to merge this PR as soon as CI is green to avoid further rebasing (we also have a few more huge PRs in the pipeline) @Fedosin Please follow-up with a PR to "add a note about this change into main.cluster-api.sigs.k8s.io/developer/providers/migrations/v1.5-to-v1.6" |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer 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 |
@Fedosin Not sure why the errors are just showing up now. PTAL at the CI issues. Please add additional changes in separate commits to make delta-reviewing easy for those Also feel free to directly make the change to the migration doc directly in this PR, now that we need some changes anyway :) |
46f11e7
to
7d626ae
Compare
7d626ae
to
8e5c51a
Compare
/test pull-cluster-api-e2e-full-main |
Thank you very much!! /lgtm Can you squash the commits (with just a squash without another rebase onto main the lgtm label should be preserved) Feel free to hold cancel after squash + e2e-full green |
LGTM label has been added. Git tree hash: eceeb15c679ba8107479c3f43c205e990ff3344d
|
8e5c51a
to
b3b9613
Compare
/test pull-cluster-api-e2e-full-main |
add context suppport to cmd/clusterctl/client/alpha add context suppport to cmd/clusterctl/client/cluster add context suppport to cmd/clusterctl/client/config add context suppport to cmd/clusterctl/client/repository add context suppport to cmd/clusterctl/client add context suppport to cmd/clusterctl/cmd add context suppport to cmd/clusterctl/internal start using clusterctl context in external functions fix conflicts in cmd/clusterctl/client/cluster/mover update migration docs
b3b9613
to
dae1103
Compare
/test pull-cluster-api-e2e-full-main |
@Fedosin: 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. |
thank you all so much for the review! /hold cancel |
Thx, especially for the patience! :) |
What this PR does / why we need it:
Today we have plenty of places in
clusterctl
where we use context.TODO(). Moreover in many placesctx
is defined as a global variable, which is considered as an anti-pattern. This PR allows to pass context variable to all public functions to manage their behavior.Note: This code breaks backward compatibility as it changes public function signatures by adding
context
parameter to them.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 #8733