kubernetes / node-problem-detector

This is a place for various problem detectors running on the Kubernetes nodes.
Apache License 2.0
2.85k stars 616 forks source link

Fix healthchecker execCommand output #860

Closed chotiwat closed 5 months ago

chotiwat commented 5 months ago

https://pkg.go.dev/os/exec#Cmd.CombinedOutput returns ([]byte, error) so we need to cast the output as string before printing to make it readble. Currently, it prints out the byte slice like below.

2024-02-14T21:29:06.921706132Z stderr F  I0214 21:29:06.919561    4052 health_checker.go:89] kubelet is unhealthy, component uptime: 17h51m18.919560214s
2024-02-14T21:29:06.921708048Z stderr F I0214 21:29:06.919610    4052 health_checker.go:91] kubelet cooldown period of 1m0s exceeded, repairing
2024-02-14T21:29:06.921709574Z stderr F I0214 21:29:06.921176    4052 health_checker.go:180] command /bin/systemctl kill --kill-who=main kubelet failed: exit status 1, [70 97 105 108 101 100 32 116 111 32 107 105 108 108 32 117 110 105 116 32 107 117 98 101 108 101 116 46 115 101 114 118 105 99 101 58 32 78 111 32 109 97 105 110 32 112 114 111 99 101 115 115 32 116 111 32 107 105 108 108 10]
k8s-ci-robot commented 5 months ago

Hi @chotiwat. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
hakman commented 5 months ago

Thanks @chotiwat! /ok-to-test /lgtm /cc @vteratipally

vteratipally commented 5 months ago

/lgtm /approve

Thank you for the fix.

k8s-ci-robot commented 5 months ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chotiwat, hakman, vteratipally

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/node-problem-detector/blob/master/OWNERS)~~ [vteratipally] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment