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

Bad log message #2914

Open
tamalsaha opened this issue Aug 9, 2024 · 13 comments
Open

Bad log message #2914

tamalsaha opened this issue Aug 9, 2024 · 13 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@tamalsaha
Copy link
Contributor

tamalsaha commented Aug 9, 2024

We see log lines like below in our cluster:

I0808 07:14:05.625541 1 controller.go:130] "msg"="Starting EventSource" "controller"="servicemonitor" "controllerGroup"="monitoring.coreos.com" "controllerKind"="ServiceMonitor" "source"=<<error: json: unsupported type: func(event.TypedCreateEvent[sigs.k8s.io/controller-runtime/pkg/client.Object]) bool>>

This is coming from

c.LogConstructor(nil).Info("Starting EventSource", "source", src)

It seems that src can't be converted into a json object. We are using v0.18.4

@sbueringer
Copy link
Member

Hm. I think we have a few options:

  • Delete the entire log statement
  • Delete only the source k/v pair
  • Use %T as value for the source k/v pair (not sure how useful this information is though)

(cc @alvaroaleman)

@tamalsaha
Copy link
Contributor Author

Delete only the source k/v pair

I vote for this.

@alvaroaleman
Copy link
Member

Weird, did we break this or did it never work but no one reported it?

@sbueringer
Copy link
Member

I think we didn't break it, it's just that not every source is nicely printable that way :)

E.g. kind source looks better:

{"ts":1723448825525.443,"caller":"controller/controller.go:173","msg":"Starting EventSource","controller":"remote/clustercache","controllerGroup":"cluster.x-k8s.io","controllerKind":"Cluster","v":0,"source":"kind source: *v1beta1.Cluster"}

Hm, I guess actually the better fix would be to add String() funcs to the sources that don't have one already

@sbueringer
Copy link
Member

@tamalsaha What source are you using?

@tamalsaha
Copy link
Contributor Author

func(event.TypedCreateEvent[sigs.k8s.io/controller-runtime/pkg/client.Object]) bool

@sbueringer
Copy link
Member

Is this a builtin source from controller-runtime or one that has been implemented outside of it?

@tamalsaha
Copy link
Contributor Author

tamalsaha commented Aug 12, 2024

@sbueringer
Copy link
Member

Hm that's strange. I would have expected all of them to use the kind source and thus have a String() func and produce a similar output to: #2914 (comment)

@sbueringer
Copy link
Member

sbueringer commented Aug 12, 2024

I'm wondering what logger is used that tries to convert the source to a JSON.

We're using component-base in Cluster API and neither the text format (klog) nor the JSON format (zap) is doing this:

text:

I0812 12:40:03.514514 17 controller.go:173] "Starting EventSource" controller="clusterclass" controllerGroup="cluster.x-k8s.io" controllerKind="ClusterClass" source="kind source: *v1beta1.ClusterClass"

JSON:

{"ts":1723448825525.5396,"caller":"controller/controller.go:173","msg":"Starting EventSource","controller":"clusterclass","controllerGroup":"cluster.x-k8s.io","controllerKind":"ClusterClass","v":0,"source":"kind source: *v1beta1.ClusterClass"}

@tamalsaha
Copy link
Contributor Author

"k8s.io/klog/v2/klogr" klogr.New()

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Nov 10, 2024
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle rotten
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants