kubernetes-sigs / descheduler

Descheduler for Kubernetes
https://sigs.k8s.io/descheduler
Apache License 2.0
4.24k stars 645 forks source link

fix: json logging #1296

Closed a7i closed 7 months ago

a7i commented 7 months ago

Issue initially reported in Slack [ref]. I noticed that the issue also persists in other projects (e.g. cluster-autsocaler) so perhaps something got changed in kubernetes/kubernetes with base-component

I followed the example from https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/component-base/logs/example/cmd/logger.go

Now onto testing. running locally to just simulate logs...

before (just hangs):

❯ timeout 10s go run cmd/descheduler/descheduler.go --logging-format=json
❯ echo $?
124

after:

❯ go run cmd/descheduler/descheduler.go --logging-format=json
{"ts":1700705698832.446,"caller":"server/secure_serving.go:57","msg":"Forcing use of http/1.1 only\n","v":0}
{"ts":1700705698832.9558,"caller":"server/secure_serving.go:213","msg":"Serving securely on [::]:10258\n","v":0}
{"ts":1700705698833.088,"caller":"dynamiccertificates/tlsconfig.go:240","msg":"Starting DynamicServingCertificateController","v":0}
{"ts":1700705698833.113,"caller":"app/server.go:93","msg":"descheduler server","err":"unable to build in cluster config: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined"}
{"ts":1700705698833.158,"caller":"dynamiccertificates/tlsconfig.go:255","msg":"Shutting down DynamicServingCertificateController","v":0}
{"ts":1700705698833.206,"caller":"cli/run.go:74","msg":"command failed","err":"unable to build in cluster config: unable to load in-cluster configuration, KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT must be defined"}
{"ts":1700705698833.217,"caller":"server/secure_serving.go:258","msg":"Stopped listening on [::]:10258\n","v":0}
exit status 1
knelasevero commented 7 months ago

/approve /lgtm

k8s-ci-robot commented 7 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: knelasevero

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/kubernetes-sigs/descheduler/blob/master/OWNERS)~~ [knelasevero] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
grzesuav commented 7 months ago

@a7i as it is merged, can you perform a fix release ?