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(event): fix event display problem #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

googs1025
Copy link

root@VM-0-9-ubuntu:/home/ubuntu# kubectl  get event
LAST SEEN   TYPE     REASON                    OBJECT                                      MESSAGE
...
50m         Normal   NodeHasSufficientPID      node/k8s-dra-driver-cluster-worker          Node k8s-dra-driver-cluster-worker status is now: NodeHasSufficientPID
50m         Normal   NodeAllocatableEnforced   node/k8s-dra-driver-cluster-worker          Updated Node Allocatable limit across pods
50m         Normal   RegisteredNode            node/k8s-dra-driver-cluster-worker          Node k8s-dra-driver-cluster-worker event: Registered Node k8s-dra-driver-cluster-worker in Controller
50m         Normal   Starting                  node/k8s-dra-driver-cluster-worker
50m         Normal   NodeReady                 node/k8s-dra-driver-cluster-worker          Node k8s-dra-driver-cluster-worker status is now: NodeReady
48m         Normal   GPUDriverUpgrade          node/k8s-dra-driver-cluster-worker          Successfully updated node state label to [upgrade-done]%!(EXTRA <nil>)


root@VM-0-9-ubuntu:/home/ubuntu# kubectl logs -f gpu-operator-64bdf76697-8d8kr -ngpu-operator | grep "Successfully "
{"level":"info","ts":1733661826.0248199,"logger":"controllers.Upgrade","msg":"Successfully changed node upgrade state label","node":"k8s-dra-driver-cluster-worker","new state":"upgrade-done"}

Signed-off-by: googs1025 <googs1025@gmail.com>
@@ -112,7 +112,7 @@ func (m *DrainManagerImpl) ScheduleNodesDrain(ctx context.Context, drainConfig *
m.log.V(consts.LogLevelError).Error(err, "Failed to cordon node", "node", node.Name)
_ = m.nodeUpgradeStateProvider.ChangeNodeUpgradeState(ctx, node, UpgradeStateFailed)
logEventf(m.eventRecorder, node, corev1.EventTypeWarning, GetEventReason(),
"Failed to cordon the node, %s", err.Error())
fmt.Sprintf("Failed to cordon the node, %s", err.Error()))
Copy link
Author

Choose a reason for hiding this comment

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

We can format in advance: Use fmt.Sprintf to format the complete log message string in advance to prevent problems when the logging function handles formatting internally.

@googs1025
Copy link
Author

friendly ping @adrianchiris @vasrem
/PTAL

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.

1 participant