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

Error on startup: log.SetLogger(...) was never called; logs will not be displayed. #197

Closed
rossigee opened this issue Dec 18, 2024 · 4 comments

Comments

@rossigee
Copy link

Image: xpkg.upbound.io/crossplane-contrib/provider-keycloak:v1.9.0

Crashes on startup...

$ kubectl -n crossplane-system logs -f provider-keycloak-bf7f727737b2-c86bcf887-m59rq 
{"level":"info","ts":"2024-12-18T01:00:21Z","logger":"provider-keycloak","msg":"Debug mode is disabled. Run with --debug flag to enable and get logs for the controller-runtime."}
{"level":"info","ts":"2024-12-18T01:00:21Z","logger":"provider-keycloak","msg":"Beta feature enabled","flag":"EnableBetaManagementPolicies"}
[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
Detected at:
	>  goroutine 1641 [running]:
	>  runtime/debug.Stack()
	>  	runtime/debug/stack.go:24 +0x5e
	>  sigs.k8s.io/controller-runtime/pkg/log.eventuallyFulfillRoot()
	>  	sigs.k8s.io/[email protected]/pkg/log/log.go:60 +0xcd
	>  sigs.k8s.io/controller-runtime/pkg/log.(*delegatingLogSink).WithValues(0xc000812440, {0xc0004be580, 0x4, 0x4})
	>  	sigs.k8s.io/[email protected]/pkg/log/deleg.go:168 +0x49
	>  github.com/go-logr/logr.Logger.WithValues(...)
	>  	github.com/go-logr/[email protected]/logr.go:332
	>  sigs.k8s.io/controller-runtime/pkg/builder.(*Builder).doController.func1(0xc000cbe320)
	>  	sigs.k8s.io/[email protected]/pkg/builder/controller.go:402 +0x2cc
	>  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc00090ed20, {0x26b91e0, 0xc000003310}, {0x2055ec0, 0xc000d1fb60})
	>  	sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:306 +0x162
	>  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc00090ed20, {0x26b91e0, 0xc000003310})
	>  	sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:266 +0x1be
	>  sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
	>  	sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:227 +0x79
	>  created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2 in goroutine 152
	>  	sigs.k8s.io/[email protected]/pkg/internal/controller/controller.go:223 +0x50c
@rossigee
Copy link
Author

Downgraded to 1.8.0 image, and 1.7.0 image. Also seems to be an issue there.

I guess it could be a configuration issue, but I haven't set anything specific that could affect it. Logging should 'just work' by default.

@rossigee
Copy link
Author

FTR, I'm running a vanilla kubeadm v1.31, with crossplane 1.18.1. My manifest is:

---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: provider-keycloak
spec:
  package: xpkg.upbound.io/crossplane-contrib/provider-keycloak:v1.9.0

---
apiVersion: keycloak.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
  name: keycloak-test
spec:
  credentials:
    source: Secret
    secretRef:
      name: keycloak-test
      key: credentials
      namespace: crossplane-system

@Breee
Copy link
Collaborator

Breee commented Dec 18, 2024

The crossplane folks did it like we do in their provider template https://github.com/crossplane/upjet-provider-template/blob/9d7c6ff3c1a4419296f327952f9cbe852ff44f03/cmd/provider/main.go#L66

	if *debug {
		// The controller-runtime runs with a no-op logger by default. It is
		// *very* verbose even at info level, so we only provide it a real
		// logger when we're running in debug mode.
		ctrl.SetLogger(zl)
	}

you can enable debugging like that:

---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
  name: keycloak-provider
  namespace: crossplane-system
spec:
  package: xpkg.upbound.io/crossplane-contrib/provider-keycloak:v1.9.0
  runtimeConfigRef:
    name: extra-config
--- 
apiVersion: pkg.crossplane.io/v1beta1
kind: DeploymentRuntimeConfig
metadata:
  name: extra-config
spec:
  deploymentTemplate:
    spec:
      selector: {}
      template:
        spec:
          containers:
            - name: package-runtime
              args:
                - --debug

The error you see was our fault tho, as we have a logging statement that causes that error message.
The provider itself should run as expected.

However, I agree with you.
I'll dig into it and see how this can be improved to at least log warn/errors.

@Breee
Copy link
Collaborator

Breee commented Dec 18, 2024

I'll do what the crossplane folks did: https://github.com/crossplane/crossplane/pull/4403/files

patch is in
xpkg.upbound.io/crossplane-contrib/provider-keycloak:v1.9.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants