Skip to content

Commit

Permalink
UPSTREAM: 52864: dockershim: fine-tune network-ready handling on sand…
Browse files Browse the repository at this point in the history
…box teardown and removal

If sandbox teardown results in an error, GC will periodically attempt
to again remove the sandbox.  Until the sandbox is removed, pod
sandbox status calls will attempt to enter the pod's namespace and
retrieve the pod IP, but the first teardown attempt may have already
removed the network namespace, resulting in a pointless log error
message that the network namespace doesn't exist, or that nsenter
can't find eth0.

The network-ready mechanism originally attempted to suppress those
messages by ensuring that pod sandbox status skipped network checks
when networking was already torn down, but unfortunately the ready
value was cleared too early.

Also, don't tear down the pod network multiple times if the first
time we tore it down, it succeeded.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1434950

:100644 100644 70c5bcb0de... d1215bc1b1... M	pkg/kubelet/dockershim/docker_sandbox.go
  • Loading branch information
dcbw authored and deads2k committed Oct 5, 2017
1 parent 4a3befb commit 99240b4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions pkg/kubelet/dockershim/docker_sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ func (ds *dockerService) StopPodSandbox(podSandboxID string) error {
// since it is stopped. With empty network namespcae, CNI bridge plugin will conduct best
// effort clean up and will not return error.
errList := []error{}
if needNetworkTearDown {
ready, ok := ds.getNetworkReady(podSandboxID)
if needNetworkTearDown && (ready || !ok) {
// Only tear down the pod network if we haven't done so already
cID := kubecontainer.BuildContainerID(runtimeName, podSandboxID)
err := ds.network.TearDownPod(namespace, name, cID)
if err == nil {
Expand Down Expand Up @@ -269,12 +271,15 @@ func (ds *dockerService) RemovePodSandbox(podSandboxID string) error {
}

// Remove the sandbox container.
if err := ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true}); err != nil && !libdocker.IsContainerNotFoundError(err) {
err = ds.client.RemoveContainer(podSandboxID, dockertypes.ContainerRemoveOptions{RemoveVolumes: true, Force: true})
if err == nil || libdocker.IsContainerNotFoundError(err) {
// Only clear network ready when the sandbox has actually been
// removed from docker or doesn't exist
ds.clearNetworkReady(podSandboxID)
} else {
errs = append(errs, err)
}

ds.clearNetworkReady(podSandboxID)

// Remove the checkpoint of the sandbox.
if err := ds.checkpointHandler.RemoveCheckpoint(podSandboxID); err != nil {
errs = append(errs, err)
Expand Down

0 comments on commit 99240b4

Please sign in to comment.