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

🐛 Fix watch & log of ProviderServiceAccount controller #2592

Merged

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Jan 5, 2024

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
The ProviderServiceAccount reconciler is actually reconciling VSphereClusters so the For should reflect that to ensure correct logging k/v pairs (For is used the determine the log key that is combined with the log value from the request).

To ensure correct controller name (which also ends up in logs and metrics) we have to then set Named. Otherwise the controller name is inferred from For.

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 #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 5, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jan 5, 2024
@sbueringer
Copy link
Member Author

/assign @srm09 @zhanggbj @chrischdi

@sbueringer
Copy link
Member Author

Somewhat related to #2284

Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (879e52e) 64.61% compared to head (ed345a1) 64.81%.
Report is 2 commits behind head on main.

Files Patch % Lines
controllers/serviceaccount_controller.go 65.00% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2592      +/-   ##
==========================================
+ Coverage   64.61%   64.81%   +0.20%     
==========================================
  Files         118      118              
  Lines        8574     8578       +4     
==========================================
+ Hits         5540     5560      +20     
+ Misses       2600     2590      -10     
+ Partials      434      428       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -131,17 +139,10 @@ type ServiceAccountReconciler struct {
func (r *ServiceAccountReconciler) Reconcile(ctx context.Context, req reconcile.Request) (_ reconcile.Result, reterr error) {
log := ctrl.LoggerFrom(ctx)

Copy link
Member Author

Choose a reason for hiding this comment

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

VSphereCluster k/v pair is now added correctly by controller-runtime

@@ -254,9 +261,7 @@ func (r *ServiceAccountReconciler) ensureProviderServiceAccounts(ctx context.Con

for i, pSvcAccount := range pSvcAccounts {
// Note: We have to use := here to not overwrite log & ctx outside the for loop.
Copy link
Member Author

Choose a reason for hiding this comment

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

Now that the request is properly added as a "VSphereCluster" k/v pair and not as "ProviderServiceAccount" we can simply set "ProviderServiceAccount" as a k/v pair here

@srm09
Copy link
Contributor

srm09 commented Jan 5, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: c95616f9852b863574294d5f088bb96bb4324f67

Copy link
Contributor

@zhanggbj zhanggbj left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Contributor

@zhanggbj zhanggbj left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

/lgtm

@chrischdi
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chrischdi

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 Jan 8, 2024
@k8s-ci-robot k8s-ci-robot merged commit e0f7a74 into kubernetes-sigs:main Jan 8, 2024
31 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Jan 8, 2024
@sbueringer sbueringer deleted the pr-svc-controller-impr branch January 8, 2024 13:39
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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants