Skip to content

[release/1.5] runtime: should fail fast if dial error on shim#7953

Merged
estesp merged 1 commit intocontainerd:release/1.5from
fuweid:backport-6031-1.5
Jan 11, 2023
Merged

[release/1.5] runtime: should fail fast if dial error on shim#7953
estesp merged 1 commit intocontainerd:release/1.5from
fuweid:backport-6031-1.5

Conversation

@fuweid
Copy link
Copy Markdown
Member

@fuweid fuweid commented Jan 11, 2023

In linux platform, the shim server always listens on the socket before the containerd task manager dial it. It is unlikely that containerd task manager should handle reconnect because the shim can't restart. For this case, the containerd task manager should fail fast if there is ENOENT or ECONNREFUSED error.

And if the socket file is deleted during cleanup the exited task, it maybe cause that containerd task manager takes long time to reload the dead shim. For that task.v2 manager, the race case is like:

TaskService.Delete
  TaskManager.Delete(runtime/v2/manager.go)
    shim.delete(runtime/v2/shim.go)
      shimv2api.Shutdown(runtime/v2/task/shim.pb.go)

      <- containerd has been killed or restarted somehow

      bundle.Delete

The shimv2api.Shutdown will cause that the shim deletes socket file (containerd-shim-runc-v2 does). But the bundle is still there. During reloading, the containerd will wait for the socket file appears again in 100 seconds. It is not reasonable. The Reconnect should prevent this case by fast fail.

Closes: #5648.
Fixes: #5597.

Signed-off-by: Wei Fu [email protected]
(cherry picked from commit f7658e3) #6031
Signed-off-by: Wei Fu [email protected]


Fixes: #7394

In linux platform, the shim server always listens on the socket before
the containerd task manager dial it. It is unlikely that containerd task
manager should handle reconnect because the shim can't restart. For this
case, the containerd task manager should fail fast if there is ENOENT or
ECONNREFUSED error.

And if the socket file is deleted during cleanup the exited task, it
maybe cause that containerd task manager takes long time to reload the
dead shim. For that task.v2 manager, the race case is like:

```
TaskService.Delete
  TaskManager.Delete(runtime/v2/manager.go)
    shim.delete(runtime/v2/shim.go)
      shimv2api.Shutdown(runtime/v2/task/shim.pb.go)

      <- containerd has been killed or restarted somehow

      bundle.Delete
```

The shimv2api.Shutdown will cause that the shim deletes socket file
(containerd-shim-runc-v2 does). But the bundle is still there. During
reloading, the containerd will wait for the socket file appears again
in 100 seconds. It is not reasonable. The Reconnect should prevent this
case by fast fail.

Closes: containerd#5648.
Fixes: containerd#5597.

Signed-off-by: Wei Fu <[email protected]>
(cherry picked from commit f7658e3)
Signed-off-by: Wei Fu <[email protected]>
Copy link
Copy Markdown

@sbuckfelder sbuckfelder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a straightforward backport. LGTM

Copy link
Copy Markdown
Member

@estesp estesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants