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
Structured Logging migration: modify eviction part logs of kubelet. #99032
Conversation
Hi @yangjunmyfm192085. 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 Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/ok-to-test |
/test pull-kubernetes-e2e-gce-100-performance |
@@ -196,7 +196,7 @@ func (m *managerImpl) Start(diskInfoProvider DiskInfoProvider, podFunc ActivePod | |||
go func() { | |||
for { | |||
if evictedPods := m.synchronize(diskInfoProvider, podFunc); evictedPods != nil { | |||
klog.Infof("eviction manager: pods %s evicted, waiting for pod to be cleaned up", format.Pods(evictedPods)) | |||
klog.InfoS("Eviction manager: pods evicted, waiting for pod to be cleaned up", "pods", format.Pods(evictedPods)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it expected that on line 168 the klog.KObj(attrs.Pod)
used and here is format.Pods
is used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to use klog.KObj(attrs.Pod), But I think evictedPods(multiple pods) is not work here,so I keep it not change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serathius what should we be doing in the case of multiple pods like this? Do you think this is ok?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should migrate it to klog.KObj
to support Json and make changes in formatting easier. We didn't add specific methods for multiple pods as we weren't sure how often this case will came up.
This is the first case using, so for now let's just implement a simple for loop.
m.synchronize(diskInfoProvider, podFunc) | ||
} | ||
if m.config.KernelMemcgNotification { | ||
for _, threshold := range m.config.Thresholds { | ||
if threshold.Signal == evictionapi.SignalMemoryAvailable || threshold.Signal == evictionapi.SignalAllocatableMemoryAvailable { | ||
notifier, err := NewMemoryThresholdNotifier(threshold, m.config.PodCgroupRoot, &CgroupNotifierFactory{}, thresholdHandler) | ||
if err != nil { | ||
klog.Warningf("eviction manager: failed to create memory threshold notifier: %v", err) | ||
klog.InfoS("Eviction manager: failed to create memory threshold notifier", "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why warning is replaced with Informational?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it according to the following rules
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, interesting. thank you!
return nil | ||
} | ||
|
||
if m.clock.Since(m.thresholdsLastUpdated) > notifierRefreshInterval { | ||
m.thresholdsLastUpdated = m.clock.Now() | ||
for _, notifier := range m.thresholdNotifiers { | ||
if err := notifier.UpdateThreshold(summary); err != nil { | ||
klog.Warningf("eviction manager: failed to update %s: %v", notifier.Description(), err) | ||
klog.InfoS("Eviction manager: failed to update notifier", "notifier", notifier.Description(), "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning replaced by Informational?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it according to the following rules
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct---"warning" log messages are being deprecated.
@@ -296,7 +296,7 @@ func (m *managerImpl) synchronize(diskInfoProvider DiskInfoProvider, podFunc Act | |||
// node conditions report true if it has been observed within the transition period window | |||
nodeConditions = nodeConditionsObservedSince(nodeConditionsLastObservedAt, m.config.PressureTransitionPeriod, now) | |||
if len(nodeConditions) > 0 { | |||
klog.V(3).Infof("eviction manager: node conditions - transition period not met: %v", nodeConditions) | |||
klog.V(3).InfoS("Eviction manager: node conditions - transition period not met", "nodeCondition", nodeConditions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how the nodeConditions
would be formatted? Will %v
be applied by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified it according to the following rules
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
@@ -336,36 +336,36 @@ func (m *managerImpl) synchronize(diskInfoProvider DiskInfoProvider, podFunc Act | |||
if !foundAny { | |||
return nil | |||
} | |||
klog.Warningf("eviction manager: attempting to reclaim %v", resourceToReclaim) | |||
klog.InfoS("Eviction manager: attempting to reclaim", "resource", resourceToReclaim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, warning replaced with informational. I will not comment further on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thak you very much.
I modified it according to the following rules,Help me see if it works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, thanks, just had one question.
/cc @serathius
@@ -196,7 +196,7 @@ func (m *managerImpl) Start(diskInfoProvider DiskInfoProvider, podFunc ActivePod | |||
go func() { | |||
for { | |||
if evictedPods := m.synchronize(diskInfoProvider, podFunc); evictedPods != nil { | |||
klog.Infof("eviction manager: pods %s evicted, waiting for pod to be cleaned up", format.Pods(evictedPods)) | |||
klog.InfoS("Eviction manager: pods evicted, waiting for pod to be cleaned up", "pods", format.Pods(evictedPods)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@serathius what should we be doing in the case of multiple pods like this? Do you think this is ok?
return nil | ||
} | ||
|
||
if m.clock.Since(m.thresholdsLastUpdated) > notifierRefreshInterval { | ||
m.thresholdsLastUpdated = m.clock.Now() | ||
for _, notifier := range m.thresholdNotifiers { | ||
if err := notifier.UpdateThreshold(summary); err != nil { | ||
klog.Warningf("eviction manager: failed to update %s: %v", notifier.Description(), err) | ||
klog.InfoS("Eviction manager: failed to update notifier", "notifier", notifier.Description(), "err", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is correct---"warning" log messages are being deprecated.
return nil | ||
} | ||
|
||
// rank the running pods for eviction for the specified resource | ||
rank(activePods, statsFunc) | ||
|
||
klog.Infof("eviction manager: pods ranked for eviction: %s", format.Pods(activePods)) | ||
klog.InfoS("Eviction manager: pods ranked for eviction", "pods", format.Pods(activePods)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same us above
return | ||
case <-ticker.C(): | ||
for i, pod := range pods { | ||
if !podCleanedUpFunc(pod) { | ||
break | ||
} | ||
if i == len(pods)-1 { | ||
klog.Infof("eviction manager: pods %s successfully cleaned up", format.Pods(pods)) | ||
klog.InfoS("Eviction manager: pods successfully cleaned up", "pods", format.Pods(pods)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
328beab
to
af0b4c9
Compare
/lgtm |
/test pull-kubernetes-e2e-kind |
Signed-off-by: JunYang <yang.jun22@zte.com.cn>
/test pull-kubernetes-unit |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mrunalp, yangjunmyfm192085 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:
Approvers can indicate their approval by writing |
Signed-off-by: JunYang yang.jun22@zte.com.cn
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Structured Logging migration: modify eviction part logs of kubelet.
xref:
https://github.com/kubernetes/enhancements/tree/master/keps/sig-instrumentation/1602-structured-logging
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: