-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure containers are stopped on daemon startup #35805
Ensure containers are stopped on daemon startup #35805
Conversation
LGTM |
Seeing failures:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🐯
da15ad0
to
5d7041c
Compare
Tested this and it doesnt work. After daemon restart, |
Adding a index 96b39e8..c18379b 100644
--- a/daemon/daemon.go
+++ b/daemon/daemon.go
@@ -44,6 +44,7 @@ import (
"github.com/docker/docker/pkg/containerfs"
"github.com/docker/docker/pkg/idtools"
"github.com/docker/docker/pkg/plugingetter"
+ "github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/pkg/system"
"github.com/docker/docker/pkg/truncindex"
@@ -241,12 +242,19 @@ func (daemon *Daemon) restore() error {
logrus.Errorf("Failed to restore container %s with containerd: %s", c.ID, err)
return
}
- if !alive {
+
+ if !daemon.configStore.LiveRestoreEnabled {
+ err = daemon.containerd.SignalProcess(context.Background(), c.ID, libcontainerd.InitProcessName, int(signal.SignalMap["TERM"]))
+ logrus.WithError(err).Errorf("Failed to kill container %v due to %v", c.ID, err)
+ }
+
+ if !alive || !daemon.configStore.LiveRestoreEnabled {
ec, exitedAt, err = daemon.containerd.DeleteTask(context.Background(), c.ID)
if err != nil && !errdefs.IsNotFound(err) {
logrus.WithError(err).Errorf("Failed to delete container %s from containerd", c.ID)
return
}
+ alive = false
}
if c.IsRunning() || c.IsPaused() { |
ebd6a08
to
c2f3b3b
Compare
daemon/daemon.go
Outdated
@@ -247,6 +247,11 @@ func (daemon *Daemon) restore() error { | |||
logrus.WithError(err).Errorf("Failed to delete container %s from containerd", c.ID) | |||
return | |||
} | |||
} else if daemon.configStore.LiveRestoreEnabled { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if !daemon.configStore.LiveRestoreEnabled, am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are correct...
Just saw failure on experimental build job:
|
https://jenkins.dockerproject.org/job/Docker-PRs-experimental/38431/console
|
ea89a1e
to
e0cdd4f
Compare
experimental CI failure is unrelated and is tracked in #35825 |
t.Parallel() | ||
|
||
d := daemon.New(t, "", "dockerd", daemon.Config{}) | ||
defer d.Stop(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The daemon is not started yet. So remove defer d.Stop
When the containerd 1.0 runtime changes were made, we inadvertantly removed the functionality where any running containers are killed on startup when not using live-restore. This change restores that behavior. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
e0cdd4f
to
e69127b
Compare
LGTM (Once CI is green) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on green as well
When the containerd 1.0 runtime changes were made, we inadvertently
removed the functionality where any running containers are killed on
startup when not using live-restore.
This change restores that behavior.
ping @fcrisciani