From aaccfcbe2b8792e5fa3711811f3025562485e8bb Mon Sep 17 00:00:00 2001 From: Lantao Liu Date: Wed, 23 Oct 2019 22:36:06 -0700 Subject: [PATCH] Fix `containerd config dump`. Signed-off-by: Lantao Liu --- cmd/containerd/command/config.go | 8 ++++++-- docs/man/containerd-config.toml.5.md | 2 ++ services/server/config/config.go | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/containerd/command/config.go b/cmd/containerd/command/config.go index 1e5710d42..f1d590d9f 100644 --- a/cmd/containerd/command/config.go +++ b/cmd/containerd/command/config.go @@ -65,10 +65,14 @@ func outputConfig(cfg *srvconfig.Config) error { } } + if config.Timeouts == nil { + config.Timeouts = make(map[string]string) + } timeouts := timeout.All() - config.Timeouts = make(map[string]string) for k, v := range timeouts { - config.Timeouts[k] = v.String() + if config.Timeouts[k] == "" { + config.Timeouts[k] = v.String() + } } // for the time being, keep the defaultConfig's version set at 1 so that diff --git a/docs/man/containerd-config.toml.5.md b/docs/man/containerd-config.toml.5.md index 6b5c2cc77..6d03f0bf0 100644 --- a/docs/man/containerd-config.toml.5.md +++ b/docs/man/containerd-config.toml.5.md @@ -39,6 +39,8 @@ separately (for example vendors may keep a custom runtime configuration in a separate file without modifying the main `config.toml`). Imported files will overwrite simple fields like `int` or `string` (if not empty) and will append `array` and `map` fields. +Imported files are also versioned, and the version can't be higher than +the main config. **[grpc]** : Section for gRPC socket listener settings. Contains three properties: diff --git a/services/server/config/config.go b/services/server/config/config.go index ff3771608..dbe42128b 100644 --- a/services/server/config/config.go +++ b/services/server/config/config.go @@ -28,6 +28,8 @@ import ( "github.com/containerd/containerd/plugin" ) +// NOTE: Any new map fields added also need to be handled in mergeConfig. + // Config provides containerd configuration data for the server type Config struct { // Version of the config file @@ -321,6 +323,10 @@ func mergeConfig(to, from *Config) error { to.ProxyPlugins[k] = v } + for k, v := range from.Timeouts { + to.Timeouts[k] = v + } + return nil }