Merge pull request #43652 from Random-Liu/avoid-kubelet-panic

Automatic merge from submit-queue (batch tested with PRs 43653, 43654, 43652)

CRI: Check nil pointer to avoid kubelet panic.

When working on the containerd kubernetes integration, I casually returns an empty `sandboxStatus.Linux{}`, but it cause kubelet to panic.

This won't happen when runtime returns valid data, but we should not make the assumption here.

/cc @yujuhong @feiskyer
This commit is contained in:
Kubernetes Submit Queue 2017-03-24 22:16:21 -07:00 committed by GitHub
commit 5fd0566ce7

View File

@ -386,7 +386,7 @@ func (m *kubeGenericRuntimeManager) podSandboxChanged(pod *v1.Pod, podStatus *ku
}
// Needs to create a new sandbox when network namespace changed.
if sandboxStatus.Linux != nil && sandboxStatus.Linux.Namespaces.Options != nil &&
if sandboxStatus.Linux != nil && sandboxStatus.Linux.Namespaces != nil && sandboxStatus.Linux.Namespaces.Options != nil &&
sandboxStatus.Linux.Namespaces.Options.HostNetwork != kubecontainer.IsHostNetworkPod(pod) {
glog.V(2).Infof("Sandbox for pod %q has changed. Need to start a new one", format.Pod(pod))
return true, sandboxStatus.Metadata.Attempt + 1, ""