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

🐛 Remove logger from scope #1913

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Feb 28, 2024

Scope encapsulates an initialised OpenStack client which can be safely shared between reconciles which share the same credentials. The logger is initialised with context specific to an individual reconcile, so it cannot be shared between reconciles.

To avoid code churn we preserve the previous interface of Scope with the creation of scope.WithLogger, which changes the initialisation to ensure that the returned logger always comes from the current reconcile even if the scope was cached.

While touching logging in tests, we also take the opportunity to replace uses of logr.Discard with GinkgoLogr or logr/testr as appropriate, so test logs are now captured.

Fixes #1840

/hold

Scope encapsulates an initialised OpenStack client which can be safely
shared between reconciles which share the same credentials. The logger
is initialised with context specific to an individual reconcile, so it
cannot be shared between reconciles.

To avoid code churn we preserve the previous interface of Scope with the
creation of scope.WithLogger, which changes the initialisation to ensure
that the returned logger always comes from the current reconcile even if
the scope was cached.

While touching logging in tests, we also take the opportunity to replace
uses of logr.Discard with GinkgoLogr or logr/testr as appropriate, so
test logs are now captured.
@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 28, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mdbooth

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 28, 2024
Copy link

netlify bot commented Feb 28, 2024

Deploy Preview for kubernetes-sigs-cluster-api-openstack ready!

Name Link
🔨 Latest commit 5a1e175
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-openstack/deploys/65df16e3553c540008d4a0e4
😎 Deploy Preview https://deploy-preview-1913--kubernetes-sigs-cluster-api-openstack.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@EmilienM
Copy link
Contributor

👏 👏 🙏
/lgtm
/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 Feb 28, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 28, 2024
@EmilienM
Copy link
Contributor

/cherry-pick release-0.9

@k8s-infra-cherrypick-robot

@EmilienM: once the present PR merges, I will cherry-pick it on top of release-0.9 in a new PR and assign it to you.

In response to this:

/cherry-pick release-0.9

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.

@k8s-ci-robot k8s-ci-robot merged commit 0c5f230 into kubernetes-sigs:main Feb 28, 2024
9 checks passed
@k8s-infra-cherrypick-robot

@EmilienM: #1913 failed to apply on top of branch "release-0.9":

Applying: Remove logger from scope
Using index info to reconstruct a base tree...
M	controllers/openstackcluster_controller.go
M	controllers/openstackcluster_controller_test.go
A	controllers/openstackfloatingippool_controller.go
M	controllers/openstackmachine_controller.go
M	controllers/suite_test.go
A	pkg/cloud/services/compute/dependent_resources.go
A	pkg/cloud/services/compute/dependent_resources_test.go
M	pkg/cloud/services/compute/instance_test.go
A	pkg/cloud/services/compute/referenced_resources.go
A	pkg/cloud/services/compute/referenced_resources_test.go
A	pkg/cloud/services/compute/servergroup_test.go
M	pkg/cloud/services/loadbalancer/loadbalancer_test.go
M	pkg/cloud/services/networking/network_test.go
M	pkg/cloud/services/networking/port.go
M	pkg/cloud/services/networking/port_test.go
A	pkg/cloud/services/networking/securitygroups_test.go
M	pkg/scope/mock.go
M	pkg/scope/provider.go
M	pkg/scope/scope.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/scope/scope.go
Auto-merging pkg/scope/provider.go
Auto-merging pkg/scope/mock.go
CONFLICT (modify/delete): pkg/cloud/services/networking/securitygroups_test.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/networking/securitygroups_test.go left in tree.
Auto-merging pkg/cloud/services/networking/port_test.go
CONFLICT (content): Merge conflict in pkg/cloud/services/networking/port_test.go
Auto-merging pkg/cloud/services/networking/port.go
CONFLICT (content): Merge conflict in pkg/cloud/services/networking/port.go
Auto-merging pkg/cloud/services/networking/network_test.go
CONFLICT (content): Merge conflict in pkg/cloud/services/networking/network_test.go
Auto-merging pkg/cloud/services/loadbalancer/loadbalancer_test.go
CONFLICT (content): Merge conflict in pkg/cloud/services/loadbalancer/loadbalancer_test.go
CONFLICT (modify/delete): pkg/cloud/services/compute/servergroup_test.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/compute/servergroup_test.go left in tree.
CONFLICT (modify/delete): pkg/cloud/services/compute/referenced_resources_test.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/compute/referenced_resources_test.go left in tree.
CONFLICT (modify/delete): pkg/cloud/services/compute/referenced_resources.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/compute/referenced_resources.go left in tree.
Auto-merging pkg/cloud/services/compute/instance_test.go
CONFLICT (modify/delete): pkg/cloud/services/compute/dependent_resources_test.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/compute/dependent_resources_test.go left in tree.
CONFLICT (modify/delete): pkg/cloud/services/compute/dependent_resources.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of pkg/cloud/services/compute/dependent_resources.go left in tree.
Auto-merging controllers/suite_test.go
Auto-merging controllers/openstackmachine_controller.go
CONFLICT (content): Merge conflict in controllers/openstackmachine_controller.go
CONFLICT (modify/delete): controllers/openstackfloatingippool_controller.go deleted in HEAD and modified in Remove logger from scope. Version Remove logger from scope of controllers/openstackfloatingippool_controller.go left in tree.
Auto-merging controllers/openstackcluster_controller_test.go
CONFLICT (content): Merge conflict in controllers/openstackcluster_controller_test.go
Auto-merging controllers/openstackcluster_controller.go
CONFLICT (content): Merge conflict in controllers/openstackcluster_controller.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Remove logger from scope
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-0.9

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.

@mdbooth mdbooth deleted the issue1840 branch February 28, 2024 13:31
@EmilienM EmilienM restored the issue1840 branch February 29, 2024 12:42
@EmilienM EmilienM deleted the issue1840 branch February 29, 2024 12:42
@jichenjc
Copy link
Contributor

jichenjc commented Mar 4, 2024

@EmilienM seems the re-apply failed, should we consider manually cherry pick ?

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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

controller/openstackcluster: reconcileID is re-used 1000+ times
5 participants