Open tamalsaha opened 2 months ago
Hm. I think we have a few options:
(cc @alvaroaleman)
Delete only the source k/v pair
I vote for this.
Weird, did we break this or did it never work but no one reported it?
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
@tamalsaha What source are you using?
func(event.TypedCreateEvent[sigs.k8s.io/controller-runtime/pkg/client.Object]) bool
Is this a builtin source from controller-runtime or one that has been implemented outside of it?
This is a typical SetupWithManager()
method written in our operator. It is coming from one of these 2 Setups:
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: https://github.com/kubernetes-sigs/controller-runtime/issues/2914#issuecomment-2283825385
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"}
"k8s.io/klog/v2/klogr"
klogr.New()
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 https://github.com/kubernetes-sigs/controller-runtime/blob/fdc8bd7d9c539b57eaf2285680e10e3393604d4d/pkg/internal/controller/controller.go#L132
It seems that
src
can't be converted into a json object. We are using v0.18.4