Merge pull request #78174 from gaorong/oom-event

enrich kubelet system oom event message info
This commit is contained in:
Kubernetes Prow Robot 2019-08-28 12:01:13 -07:00 committed by GitHub
commit c6a506bb8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,8 @@ limitations under the License.
package oom
import (
"fmt"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/runtime"
@ -58,7 +60,11 @@ func (ow *realWatcher) Start(ref *v1.ObjectReference) error {
for event := range outStream {
if event.ContainerName == "/" {
klog.V(1).Infof("Got sys oom event: %v", event)
ow.recorder.PastEventf(ref, metav1.Time{Time: event.TimeOfDeath}, v1.EventTypeWarning, systemOOMEvent, "System OOM encountered")
eventMsg := "System OOM encountered"
if event.ProcessName != "" && event.Pid != 0 {
eventMsg = fmt.Sprintf("%s, victim process: %s, pid: %d", eventMsg, event.ProcessName, event.Pid)
}
ow.recorder.PastEventf(ref, metav1.Time{Time: event.TimeOfDeath}, v1.EventTypeWarning, systemOOMEvent, eventMsg)
}
}
klog.Errorf("Unexpectedly stopped receiving OOM notifications")