Skip to content

Commit

Permalink
Merge pull request kubernetes#43652 from Random-Liu/avoid-kubelet-panic
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Kubernetes Submit Queue authored Mar 25, 2017
2 parents 2a61cfb + 9186d15 commit 5fd0566
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/kubelet/kuberuntime/kuberuntime_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ""
Expand Down

0 comments on commit 5fd0566

Please sign in to comment.