Merge pull request #24942 from anusha-ragunathan/plugin-liverestore

Handle plugin shutdown when liveRestore is set.
Upstream-commit: b6197e951498eed717ee550387c34e9a8e6350ed
Component: engine
This commit is contained in:
Michael Crosby
2016-07-25 09:49:34 -07:00
committed by GitHub
4 changed files with 47 additions and 6 deletions
@@ -74,8 +74,9 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithPluginDisabled(c *check.C) {
c.Assert(out, checker.Contains, "false")
}
// TestDaemonShutdownLiveRestoreWithPlugins leaves plugin running.
func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) {
// TestDaemonKillLiveRestoreWithPlugins SIGKILLs daemon started with --live-restore.
// Plugins should continue to run.
func (s *DockerDaemonSuite) TestDaemonKillLiveRestoreWithPlugins(c *check.C) {
if err := s.d.Start("--live-restore"); err != nil {
c.Fatalf("Could not start daemon: %v", err)
}
@@ -104,6 +105,37 @@ func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C)
}
}
// TestDaemonShutdownLiveRestoreWithPlugins SIGTERMs daemon started with --live-restore.
// Plugins should continue to run.
func (s *DockerDaemonSuite) TestDaemonShutdownLiveRestoreWithPlugins(c *check.C) {
if err := s.d.Start("--live-restore"); err != nil {
c.Fatalf("Could not start daemon: %v", err)
}
if out, err := s.d.Cmd("plugin", "install", "--grant-all-permissions", pluginName); err != nil {
c.Fatalf("Could not install plugin: %v %s", err, out)
}
defer func() {
if err := s.d.Restart("--live-restore"); err != nil {
c.Fatalf("Could not restart daemon: %v", err)
}
if out, err := s.d.Cmd("plugin", "disable", pluginName); err != nil {
c.Fatalf("Could not disable plugin: %v %s", err, out)
}
if out, err := s.d.Cmd("plugin", "remove", pluginName); err != nil {
c.Fatalf("Could not remove plugin: %v %s", err, out)
}
}()
if err := s.d.cmd.Process.Signal(os.Interrupt); err != nil {
c.Fatalf("Could not kill daemon: %v", err)
}
cmd := exec.Command("pgrep", "-f", "plugin-no-remove")
if out, ec, err := runCommandWithOutput(cmd); ec != 0 {
c.Fatalf("Expected exit code '0', got %d err: %v output: %s ", ec, err, out)
}
}
// TestDaemonShutdownWithPlugins shuts down running plugins.
func (s *DockerDaemonSuite) TestDaemonShutdownWithPlugins(c *check.C) {
if err := s.d.Start(); err != nil {