kubernetes-sigs / cluster-api-provider-openstack

Cluster API implementation for OpenStack
https://cluster-api-openstack.sigs.k8s.io/
Apache License 2.0
283 stars 253 forks source link

🐛 Remove logger from scope #1913

Closed mdbooth closed 6 months ago

mdbooth commented 6 months ago

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

k8s-ci-robot commented 6 months ago

[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: - ~~[OWNERS](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/blob/main/OWNERS)~~ [mdbooth] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
netlify[bot] commented 6 months ago

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

Name Link
Latest commit 5a1e1752b71739d29bf67f6291a48e9047c0ba9c
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.

mdbooth commented 6 months ago

Logs look good: https://storage.googleapis.com/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api-provider-openstack/1913/pull-cluster-api-provider-openstack-e2e-test/1762799822030508032/artifacts/clusters/bootstrap/logs/capo-system/capo-controller-manager/capo-controller-manager-66896777f9-75xt5/manager.log

EmilienM commented 6 months ago

:clap: :clap: :pray: /lgtm /hold cancel :ship: :ship: :partying_face:

EmilienM commented 6 months ago

/cherry-pick release-0.9

k8s-infra-cherrypick-robot commented 6 months ago

@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](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1913#issuecomment-1968984827): >/cherry-pick release-0.9 Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
k8s-infra-cherrypick-robot commented 6 months ago

@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](https://github.com/kubernetes-sigs/cluster-api-provider-openstack/pull/1913#issuecomment-1968984827): >/cherry-pick release-0.9 Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
jichenjc commented 6 months ago

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