Merge pull request #113216 from astraw99/ftr-add-backoff-container

Add container name in the `BackOff` event message
This commit is contained in:
Kubernetes Prow Robot 2022-11-03 21:24:13 -07:00 committed by GitHub
commit 79014dd6da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -920,7 +920,8 @@ func (m *kubeGenericRuntimeManager) doBackOff(pod *v1.Pod, container *v1.Contain
key := getStableKey(pod, container)
if backOff.IsInBackOffSince(key, ts) {
if containerRef, err := kubecontainer.GenerateContainerRef(pod, container); err == nil {
m.recorder.Eventf(containerRef, v1.EventTypeWarning, events.BackOffStartContainer, "Back-off restarting failed container")
m.recorder.Eventf(containerRef, v1.EventTypeWarning, events.BackOffStartContainer,
fmt.Sprintf("Back-off restarting failed container %s in pod %s", container.Name, format.Pod(pod)))
}
err := fmt.Errorf("back-off %s restarting failed container=%s pod=%s", backOff.Get(key), container.Name, format.Pod(pod))
klog.V(3).InfoS("Back-off restarting failed container", "err", err.Error())