kubernetes-sigs / descheduler

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

fix: topologySpreadConstraint fields in structured logs #1317

Closed SataQiu closed 6 months ago

SataQiu commented 6 months ago

There is a problem with the log display due to the use of non-exported fields: https://github.com/kubernetes-sigs/descheduler/blob/f0f7ebbe9af680b338709391cf1c0da7c2270ce5/pkg/framework/plugins/removepodsviolatingtopologyspreadconstraint/topologyspreadconstraint.go#L220

Without this patch the tsc is printed as empty {}:

I1212 08:34:36.666387       1 topologyspreadconstraint.go:230] "Skipping topology constraint because it is already balanced" constraint={}

With this patch:

I1212 08:41:10.178744       1 topologyspreadconstraint.go:221] "Skipping topology constraint because it is already balanced" constraint={"MaxSkew":1,"TopologyKey":"topology.kubernetes.io/zone","Selector":[{}],"NodeAffinityPolicy":"Honor","NodeTaintsPolicy":"Ignore","PodNodeAffinity":{},"PodTolerations":[{"key":"node.kubernetes.io/not-ready","operator":"Exists","effect":"NoExecute","tolerationSeconds":300},{"key":"node.kubernetes.io/unreachable","operator":"Exists","effect":"NoExecute","tolerationSeconds":300}]}
linux-foundation-easycla[bot] commented 6 months ago

CLA Signed

The committers listed above are authorized under a signed CLA.

a7i commented 6 months ago

/approve

k8s-ci-robot commented 6 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a7i

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)~~ [a7i] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
a7i commented 6 months ago

/lgtm

a7i commented 6 months ago

Thank you for your contribution @SataQiu 🏆