Skip to content

Commit faf9dac

Browse files
authored
Merge pull request moby#24986 from mlaventure/add-live-restore-to-info
Add live restore to info
2 parents 0fc062d + ff62681 commit faf9dac

File tree

9 files changed

+19
-10
lines changed

9 files changed

+19
-10
lines changed

api/client/system/info.go

+3
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,8 @@ func runInfo(dockerCli *client.DockerCli) error {
212212
fmt.Fprintf(dockerCli.Out(), " %s/%d\n", registry.IP.String(), mask)
213213
}
214214
}
215+
216+
fmt.Fprintf(dockerCli.Out(), "Live Restore Enabled: %v\n", info.LiveRestoreEnabled)
217+
215218
return nil
216219
}

cmd/dockerd/daemon_unix.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (cli *DaemonCli) getPlatformRemoteOptions() []libcontainerd.RemoteOption {
7272
args := []string{"--systemd-cgroup=true"}
7373
opts = append(opts, libcontainerd.WithRuntimeArgs(args))
7474
}
75-
if cli.Config.LiveRestore {
75+
if cli.Config.LiveRestoreEnabled {
7676
opts = append(opts, libcontainerd.WithLiveRestore(true))
7777
}
7878
opts = append(opts, libcontainerd.WithRuntimePath(daemon.DefaultRuntimeBinary))

daemon/config.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ type CommonConfig struct {
9494
TrustKeyPath string `json:"-"`
9595
CorsHeaders string `json:"api-cors-header,omitempty"`
9696
EnableCors bool `json:"api-enable-cors,omitempty"`
97-
LiveRestore bool `json:"live-restore,omitempty"`
97+
98+
// LiveRestoreEnabled determines whether we should keep containers
99+
// alive upon daemon shutdown/start
100+
LiveRestoreEnabled bool `json:"live-restore,omitempty"`
98101

99102
// ClusterStore is the storage backend used for the cluster information. It is used by both
100103
// multihost networking (to store networks and endpoints information) and by the node discovery

daemon/config_unix.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin
8787
cmd.StringVar(&config.CgroupParent, []string{"-cgroup-parent"}, "", usageFn("Set parent cgroup for all containers"))
8888
cmd.StringVar(&config.RemappedRoot, []string{"-userns-remap"}, "", usageFn("User/Group setting for user namespaces"))
8989
cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket"))
90-
cmd.BoolVar(&config.LiveRestore, []string{"-live-restore"}, false, usageFn("Enable live restore of docker when containers are still running"))
90+
cmd.BoolVar(&config.LiveRestoreEnabled, []string{"-live-restore"}, false, usageFn("Enable live restore of docker when containers are still running"))
9191
config.Runtimes = make(map[string]types.Runtime)
9292
cmd.Var(runconfigopts.NewNamedRuntimeOpt("runtimes", &config.Runtimes, stockRuntimeName), []string{"-add-runtime"}, usageFn("Register an additional OCI compatible runtime"))
9393
cmd.StringVar(&config.DefaultRuntime, []string{"-default-runtime"}, stockRuntimeName, usageFn("Default OCI runtime for containers"))
@@ -133,7 +133,7 @@ func (config *Config) isSwarmCompatible() error {
133133
if config.ClusterStore != "" || config.ClusterAdvertise != "" {
134134
return fmt.Errorf("--cluster-store and --cluster-advertise daemon configurations are incompatible with swarm mode")
135135
}
136-
if config.LiveRestore {
136+
if config.LiveRestoreEnabled {
137137
return fmt.Errorf("--live-restore daemon configuration is incompatible with swarm mode")
138138
}
139139
return nil

daemon/daemon.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ func (daemon *Daemon) Shutdown() error {
658658

659659
pluginShutdown()
660660

661-
if daemon.configStore.LiveRestore && daemon.containers != nil {
661+
if daemon.configStore.LiveRestoreEnabled && daemon.containers != nil {
662662
// check if there are any running containers, if none we should do some cleanup
663663
if ls, err := daemon.Containers(&types.ContainerListOptions{}); len(ls) != 0 || err != nil {
664664
return nil
@@ -916,8 +916,8 @@ func (daemon *Daemon) Reload(config *Config) error {
916916
daemon.configStore.Debug = config.Debug
917917
}
918918
if config.IsValueSet("live-restore") {
919-
daemon.configStore.LiveRestore = config.LiveRestore
920-
if err := daemon.containerdRemote.UpdateOptions(libcontainerd.WithLiveRestore(config.LiveRestore)); err != nil {
919+
daemon.configStore.LiveRestoreEnabled = config.LiveRestoreEnabled
920+
if err := daemon.containerdRemote.UpdateOptions(libcontainerd.WithLiveRestore(config.LiveRestoreEnabled)); err != nil {
921921
return err
922922
}
923923

@@ -951,6 +951,7 @@ func (daemon *Daemon) Reload(config *Config) error {
951951

952952
// We emit daemon reload event here with updatable configurations
953953
attributes["debug"] = fmt.Sprintf("%t", daemon.configStore.Debug)
954+
attributes["live-restore"] = fmt.Sprintf("%t", daemon.configStore.LiveRestoreEnabled)
954955
attributes["cluster-store"] = daemon.configStore.ClusterStore
955956
if daemon.configStore.ClusterOpts != nil {
956957
opts, _ := json.Marshal(daemon.configStore.ClusterOpts)
@@ -1076,7 +1077,7 @@ func (daemon *Daemon) networkOptions(dconfig *Config, activeSandboxes map[string
10761077
options = append(options, nwconfig.OptionLabels(dconfig.Labels))
10771078
options = append(options, driverOptions(dconfig)...)
10781079

1079-
if daemon.configStore != nil && daemon.configStore.LiveRestore && len(activeSandboxes) != 0 {
1080+
if daemon.configStore != nil && daemon.configStore.LiveRestoreEnabled && len(activeSandboxes) != 0 {
10801081
options = append(options, nwconfig.OptionActiveSandboxes(activeSandboxes))
10811082
}
10821083

daemon/daemon_experimental.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func (daemon *Daemon) verifyExperimentalContainerSettings(hostConfig *container.
1313
}
1414

1515
func pluginInit(d *Daemon, cfg *Config, remote libcontainerd.Remote) error {
16-
return plugin.Init(cfg.Root, remote, d.RegistryService, cfg.LiveRestore, d.LogPluginEvent)
16+
return plugin.Init(cfg.Root, remote, d.RegistryService, cfg.LiveRestoreEnabled, d.LogPluginEvent)
1717
}
1818

1919
func pluginShutdown() {

daemon/info.go

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ func (daemon *Daemon) SystemInfo() (*types.Info, error) {
117117
HTTPSProxy: sockets.GetProxyEnv("https_proxy"),
118118
NoProxy: sockets.GetProxyEnv("no_proxy"),
119119
SecurityOptions: securityOptions,
120+
LiveRestoreEnabled: daemon.configStore.LiveRestoreEnabled,
120121
}
121122

122123
// TODO Windows. Refactor this more once sysinfo is refactored into

integration-cli/docker_cli_events_unix_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) {
437437
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c))
438438
c.Assert(err, checker.IsNil)
439439

440-
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s (cluster-advertise=, cluster-store=, cluster-store-opts={}, debug=true, default-runtime=runc, labels=[\"bar=foo\"], max-concurrent-downloads=1, max-concurrent-uploads=5, name=%s, runtimes=runc:{docker-runc []})", daemonID, daemonName))
440+
c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s (cluster-advertise=, cluster-store=, cluster-store-opts={}, debug=true, default-runtime=runc, labels=[\"bar=foo\"], live-restore=false, max-concurrent-downloads=1, max-concurrent-uploads=5, name=%s, runtimes=runc:{docker-runc []})", daemonID, daemonName))
441441
}
442442

443443
func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {

integration-cli/docker_cli_info_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
3333
"Volume:",
3434
"Network:",
3535
"Security Options:",
36+
"Live Restore Enabled:",
3637
}
3738

3839
if DaemonIsLinux.Condition() {

0 commit comments

Comments
 (0)