openyurtio / openyurt

OpenYurt - Extending your native Kubernetes to edge(project under CNCF)
https://openyurt.io
Apache License 2.0
1.69k stars 398 forks source link

[feature request]improve key logs in yurthub component #1881

Closed rambohe-ch closed 7 months ago

rambohe-ch commented 7 months ago

What would you like to be added: There are some tricky logs in yurthub component as following:

cache_manager.go:650] skip to cache watch event because key({%!s(bool=false) kubelet/pods.v1.core/kube-system/kube-proxy-7g4dc}) is under processing

The reason is that var key is a struct not a string, so %s in klog.Infof print the above tricky logs.

so the following code should be modified:

klog.V(2).Infof("skip to cache watch event because key(%s) is under processing", key.Key())

by the way, the following lines have the same kind of problems.

https://github.com/openyurtio/openyurt/blob/9fb701eb8b5d50c97674f441fede8273149fec73/pkg/yurthub/cachemanager/cache_manager.go#L630

https://github.com/openyurtio/openyurt/blob/9fb701eb8b5d50c97674f441fede8273149fec73/pkg/yurthub/cachemanager/cache_manager.go#L644

others /kind feature

wangzihao05 commented 7 months ago

/assign @wangzihao05

rambohe-ch commented 7 months ago

@wangzihao05 Do you have any progress about this issue?

wangzihao05 commented 7 months ago

I have understood this issue.The problem is that struct that is supposed to be string is causing the log exception. I have modified part of the code as required.And I will finish and commit later this week.

rambohe-ch commented 7 months ago

I have understood this issue.The problem is that struct that is supposed to be string is causing the log exception. I have modified part of the code as required.And I will finish and commit later this week.

@wangzihao05 Thanks for your kindly response. yes, var key is a pointer of a struct, so you need to replace key by key.Key() only.

Congrool commented 7 months ago

Since the pr has been merged, close.

/close