Skip to content

Commit ad72136

Browse files
authored
Logger initialization issue (#4472)
<!-- Use # to add the issue this pull request is related to. nb: This is the Github issue number, not a Zenhub link. Do not use any punctuation or bullet points. eg: Closes #1234 Fixes #5678 --> Closes <!-- Describe what has changed in this PR --> **What changed?** initializing logger earlier on in start process <!-- Tell your future self why have you made these changes --> **Why was this change made?** ` [controller-runtime] log.SetLogger(...) was never called; logs will not be displayed. Detected at: > goroutine 434 [running]: > runtime/debug.Stack() > /usr/local/go/src/runtime/debug/stack.go:26 +0x64 > sigs.k8s.io/controller-runtime/pkg/log.eventuallyFulfillRoot() > /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.4/pkg/log/log.go:60 +0xa0 > sigs.k8s.io/controller-runtime/pkg/log.(*delegatingLogSink).WithName(0x4000132580, {0x3291787, 0x14}) > /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.4/pkg/log/deleg.go:147 +0x34 > github.com/go-logr/logr.Logger.WithName({{0x3600dc8, 0x4000132580}, 0x0}, {0x3291787, 0x14}) > /go/pkg/mod/github.com/go-logr/logr@v1.4.2/logr.go:345 +0x5c > sigs.k8s.io/controller-runtime/pkg/client.newClient(0x400036d448, {0x0, 0x4000261650, {0x3602610, 0x40006ad270}, 0x0, 0x0}) > /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.4/pkg/client/client.go:118 +0xf8 > sigs.k8s.io/controller-runtime/pkg/client.New(0x400029fd48, {0x0, 0x4000261650, {0x3602610, 0x40006ad270}, 0x0, 0x0}) > /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.19.4/pkg/client/client.go:98 +0x68 > github.com/weaveworks/weave-gitops/core/clustersmngr/cluster.getClientFromConfig(0x400029fd48, 0x4000261650) > /app/core/clustersmngr/cluster/single.go:69 +0x2f0 > github.com/weaveworks/weave-gitops/core/clustersmngr/cluster.(*singleCluster).GetUserClient(0x40001320c0, 0x40007cfda0) > /app/core/clustersmngr/cluster/single.go:94 +0x108 > github.com/weaveworks/weave-gitops/core/clustersmngr.(*clustersManager).getOrCreateClient(0x40001acb40, 0x40007cfda0, {0x36023d0, 0x40001320c0}) > /app/core/clustersmngr/factory.go:623 +0x38c > github.com/weaveworks/weave-gitops/core/clustersmngr.(*clustersManager).getUserClientWithNamespaces.func1({0x36023d0, 0x40001320c0}, {0x35e7d98, 0x4000c9a890}, 0x4000974e00) > /app/core/clustersmngr/factory.go:426 +0xd8 > created by github.com/weaveworks/weave-gitops/core/clustersmngr.(*clustersManager).getUserClientWithNamespaces in goroutine 402 > /app/core/clustersmngr/factory.go:423 +0x364 ` <!-- Explain to your reviewers the key implementation points, including why you made certain choices in favour of others. Highlight key areas of the code which need extra attention, and also indicate which parts are less relevant (eg renaming, refactoring, etc --> **How was this change implemented?** <!-- How have you verified this change/product value? Tested locally? Added integration/acceptance test(s)? Unit tests are required. --> **How did you validate the change?** Services starts, stacktrace gone <!-- Is it notable for release? e.g. schema updates, configuration or data migration required? If so, please mention it. --> **Release notes** <!-- Are there any documentation updates that should be made for these changes? --> **Documentation Changes**
1 parent 62b675f commit ad72136

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

core/clustersmngr/cluster/single.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"k8s.io/client-go/rest"
1010
"sigs.k8s.io/controller-runtime/pkg/client"
1111
"sigs.k8s.io/controller-runtime/pkg/client/apiutil"
12+
"sigs.k8s.io/controller-runtime/pkg/log"
13+
"sigs.k8s.io/controller-runtime/pkg/log/zap"
1214

1315
"github.com/weaveworks/weave-gitops/pkg/kube"
1416
"github.com/weaveworks/weave-gitops/pkg/server/auth"
@@ -56,6 +58,7 @@ func (c *singleCluster) GetHost() string {
5658
}
5759

5860
func getClientFromConfig(config *rest.Config, scheme *apiruntime.Scheme) (client.Client, error) {
61+
log.SetLogger(zap.New(zap.UseDevMode(true)))
5962
httpClient, err := rest.HTTPClientFor(config)
6063
if err != nil {
6164
return nil, fmt.Errorf("could not create HTTP client from config: %w", err)

core/clustersmngr/factory.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import (
1616
"k8s.io/apimachinery/pkg/util/wait"
1717
"k8s.io/client-go/discovery"
1818
"sigs.k8s.io/controller-runtime/pkg/client"
19+
_ "sigs.k8s.io/controller-runtime/pkg/log"
20+
_ "sigs.k8s.io/controller-runtime/pkg/log/zap"
1921

2022
"github.com/weaveworks/weave-gitops/core/clustersmngr/cluster"
2123
"github.com/weaveworks/weave-gitops/core/nsaccess"

0 commit comments

Comments
 (0)