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

🌱 Improve logging of VSphereCluster, ProviderServiceAccount and ServiceDiscovery controllers #2352

Merged

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Sep 12, 2023

Set up golang context when initiating controller manager and also pass it down
to VSphereCluster controller

Signed-off-by: Gong Zhang [email protected]

What this PR does / why we need it:
Have to do a few more things + the underlying PR has to be merged first

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #2076

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 12, 2023
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Sep 12, 2023
@codecov
Copy link

codecov bot commented Sep 12, 2023

Codecov Report

Patch coverage: 74.80% and project coverage change: +0.59% 🎉

Comparison is base (d63e2bc) 60.37% compared to head (09ff688) 60.97%.
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2352      +/-   ##
==========================================
+ Coverage   60.37%   60.97%   +0.59%     
==========================================
  Files         164      164              
  Lines        9442     9465      +23     
==========================================
+ Hits         5701     5771      +70     
+ Misses       3324     3284      -40     
+ Partials      417      410       -7     
Files Changed Coverage Δ
controllers/vsphereclusteridentity_controller.go 53.84% <0.00%> (+0.90%) ⬆️
pkg/clustermodule/session.go 29.78% <20.00%> (ø)
pkg/clustermodule/service.go 20.61% <32.43%> (+3.22%) ⬆️
pkg/context/fake/fake_guest_cluster_context.go 71.42% <50.00%> (ø)
pkg/context/fake/fake_vmware_cluster_context.go 71.42% <50.00%> (-3.58%) ⬇️
controllers/clustermodule_reconciler.go 61.46% <58.82%> (-0.98%) ⬇️
controllers/vspheredeploymentzone_controller.go 76.00% <60.00%> (-2.67%) ⬇️
pkg/manager/network.go 58.82% <60.00%> (+5.49%) ⬆️
pkg/context/vmware/cluster_context.go 83.33% <66.66%> (ø)
controllers/vspherecluster_reconciler.go 62.03% <72.00%> (+1.94%) ⬆️
... and 20 more

... and 5 files with indirect coverage changes

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

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 13, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

@sbueringer sbueringer mentioned this pull request Sep 13, 2023
18 tasks
@sbueringer sbueringer force-pushed the pr-capv-logging-initial branch 2 times, most recently from de96b33 to acda9f1 Compare September 14, 2023 18:49
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 14, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

@sbueringer sbueringer force-pushed the pr-capv-logging-initial branch 2 times, most recently from 3d3896a to 555bd27 Compare September 15, 2023 05:47
@sbueringer sbueringer changed the title [WIP] 🌱 Improve logging of VSphereCluster controllers 🌱 Improve logging of VSphereCluster controllers Sep 15, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 15, 2023
@sbueringer sbueringer changed the title 🌱 Improve logging of VSphereCluster controllers 🌱 Improve logging of VSphereCluster, ProviderServiceAccount and ServiceDiscovery controllers Sep 15, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

1 similar comment
@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

@randomvariable
Copy link
Member

Whilst you're doing this, i would enable loggercheck in golangci-lint to catch when someone hasn't completed kv pairs.

@sbueringer
Copy link
Member Author

Whilst you're doing this, i would enable loggercheck in golangci-lint to catch when someone hasn't completed kv pairs.

Thx, nice one! Will do

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 15, 2023
@killianmuldoon
Copy link
Contributor

/test pull-cluster-api-provider-vsphere-e2e-full-main

@killianmuldoon
Copy link
Contributor

/lgtm remove

Should be squashed before merge.

@killianmuldoon
Copy link
Contributor

/lgtm cancel

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 15, 2023
@sbueringer
Copy link
Member Author

sbueringer commented Sep 18, 2023

I would generally prefer if we tried to keep changes like this more atomic in future - this PR has so many small changes I think it's very difficult to review.

I agree. This escalated a bit and it was a mixture of keeping the PR safe and in some cases fixing up things while I'm already there.

A majority of the "scope creep" was because the only way to safely refactor this was to remove the *context.ControllerContext and Logger entirely from ClusterContext. The result was that I had to refactor some other controllers as well, the same applies to packages like network & vmoperator that are used by the controllers.

I had an intermediate version where I only tried to stop using these fields and not setting them in some controller but this blew up pretty badly in some cases I missed in unit tests (panic's all over the place). Because I couldn't be sure that we have full coverage I thought it's the safer option to play it safe and drop these fields entirely instead of hoping that I got all relevant places and then risking panic's in rare edge cases in production later. This way the compiler took care of ensuring that there are no panics when ControllerContext & Logger are accessed (because the fields don't exist anymore)

@sbueringer
Copy link
Member Author

Pushed some fixes. Will squash later after @chrischdi 's review and corresponding fixes

@sbueringer
Copy link
Member Author

codecov failed because of the flake in our tests

@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

@sbueringer sbueringer mentioned this pull request Sep 18, 2023
12 tasks
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.

One thing to maybe take another look (I may missed something there?!)

A lot of awesome small fixes are included too! 🎉

@@ -17,6 +17,7 @@ limitations under the License.
package network
Copy link
Member

Choose a reason for hiding this comment

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

not in scope of this PR, but wondering if we should splitup this file to netop_provider_test.go and nsxt_provider_test.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Feel free to open an issue/PR for it. Probably it should be one file per provider (including dummy)

controllers/vspherecluster_controller.go Outdated Show resolved Hide resolved
controllers/serviceaccount_controller.go Show resolved Hide resolved
controllers/serviceaccount_controller.go Show resolved Hide resolved
@chrischdi
Copy link
Member

/lgtm

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

LGTM label has been added.

Git tree hash: 2231c60b5e8f9411512e105d14ac77b86fdcebde

@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-e2e-full-main

@sbueringer
Copy link
Member Author

/test ?

@k8s-ci-robot

This comment was marked as outdated.

@sbueringer
Copy link
Member Author

/test pull-cluster-api-provider-vsphere-conformance-main

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Sep 18, 2023

@sbueringer: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-vsphere-apidiff-main 09ff688 link false /test pull-cluster-api-provider-vsphere-apidiff-main

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.

@sbueringer
Copy link
Member Author

/hold cancel

@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 Sep 18, 2023
@k8s-ci-robot k8s-ci-robot merged commit d922ba4 into kubernetes-sigs:main Sep 18, 2023
8 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.9 milestone Sep 18, 2023
@sbueringer sbueringer deleted the pr-capv-logging-initial branch September 18, 2023 17:51
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants