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

fix: set default klog logger to avoid breaking log format #130

Merged
merged 1 commit into from
May 21, 2024

Conversation

erikgb
Copy link
Contributor

@erikgb erikgb commented May 21, 2024

We are using JSON log format in our installation of Accurate. Here is an example log:

{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"skip registering a mutating webhook, object does not implement admission.Defaulter or WithDefaulter wasn't called","GVK":"accurate.cybozu.com/v1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"skip registering a validating webhook, object does not implement admission.Validator or WithValidator wasn't called","GVK":"accurate.cybozu.com/v1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.webhook","msg":"Registering webhook","path":"/convert"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"Conversion webhook enabled","GVK":"accurate.cybozu.com/v1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"skip registering a mutating webhook, object does not implement admission.Defaulter or WithDefaulter wasn't called","GVK":"accurate.cybozu.com/v2alpha1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"skip registering a validating webhook, object does not implement admission.Validator or WithValidator wasn't called","GVK":"accurate.cybozu.com/v2alpha1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.builder","msg":"Conversion webhook enabled","GVK":"accurate.cybozu.com/v2alpha1, Kind=SubNamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.webhook","msg":"Registering webhook","path":"/mutate-accurate-cybozu-com-v1-subnamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.webhook","msg":"Registering webhook","path":"/validate-accurate-cybozu-com-v1-subnamespace"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"/v1, Kind=LimitRange"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"/v1, Kind=ResourceQuota"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"networking.k8s.io/v1, Kind=NetworkPolicy"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"rbac.authorization.k8s.io/v1, Kind=Role"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"rbac.authorization.k8s.io/v1, Kind=RoleBinding"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"watching","gvk":"network.openshift.io/v1, Kind=EgressNetworkPolicy"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"setup","msg":"starting manager"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.metrics","msg":"Starting metrics server"}
{"level":"info","ts":"2024-05-21T12:28:14Z","msg":"starting server","kind":"health probe","addr":"[::]:8081"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.metrics","msg":"Serving metrics server","bindAddress":":8080","secure":false}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.webhook","msg":"Starting webhook server"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.certwatcher","msg":"Updated current TLS certificate"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.certwatcher","msg":"Starting certificate watcher"}
{"level":"info","ts":"2024-05-21T12:28:14Z","logger":"controller-runtime.webhook","msg":"Serving webhook server","host":"","port":9443}
I0521 12:28:15.237534 1 leaderelection.go:250] attempting to acquire leader lease accurate/accurate...
2024/05/21 12:29:04 http: TLS handshake error from 10.101.0.1:43356: EOF
2024/05/21 12:31:21 http: TLS handshake error from 10.101.0.1:48132: EOF

As you can see, the last three lines breaks the configured JSON log-format. I've digged into the origin of these log-lines, and it appears like it's logged from the default klog logger. This PR initializes the default klog logger and should fix this issue.

Related issue #104.

Copy link
Member

@ymmt2005 ymmt2005 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ymmt2005 ymmt2005 merged commit 8b60897 into cybozu-go:main May 21, 2024
7 checks passed
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

Successfully merging this pull request may close these issues.

2 participants