From fabcc919567d23e63451eaa6170a61508ab34a51 Mon Sep 17 00:00:00 2001 From: ruiwen-zhao Date: Wed, 7 Dec 2022 23:31:54 +0000 Subject: [PATCH] Ignore container events with nil PodSandboxStatus Signed-off-by: ruiwen-zhao --- pkg/kubelet/pleg/evented.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/kubelet/pleg/evented.go b/pkg/kubelet/pleg/evented.go index e100765559c..9e9a5420899 100644 --- a/pkg/kubelet/pleg/evented.go +++ b/pkg/kubelet/pleg/evented.go @@ -204,6 +204,19 @@ func (e *EventedPLEG) watchEventsChannel() { func (e *EventedPLEG) processCRIEvents(containerEventsResponseCh chan *runtimeapi.ContainerEventResponse) { for event := range containerEventsResponseCh { + // Ignore the event if PodSandboxStatus is nil. + // This might happen under some race condition where the podSandbox has + // been deleted, and therefore container runtime couldn't find the + // podSandbox for the container when generating the event. + // It is safe to ignore because + // a) a event would have been received for the sandbox deletion, + // b) in worst case, a relist will eventually sync the pod status. + // TODO(#114371): Figure out a way to handle this case instead of ignoring. + if event.PodSandboxStatus == nil || event.PodSandboxStatus.Metadata == nil { + klog.ErrorS(nil, "Evented PLEG: received ContainerEventResponse with nil PodSandboxStatus or PodSandboxStatus.Metadata", "containerEventResponse", event) + continue + } + podID := types.UID(event.PodSandboxStatus.Metadata.Uid) shouldSendPLEGEvent := false