Fix containerd config dump.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2019-10-23 22:36:06 -07:00
parent 966b1b8e30
commit aaccfcbe2b
3 changed files with 14 additions and 2 deletions

View File

@ -65,11 +65,15 @@ func outputConfig(cfg *srvconfig.Config) error {
} }
} }
timeouts := timeout.All() if config.Timeouts == nil {
config.Timeouts = make(map[string]string) config.Timeouts = make(map[string]string)
}
timeouts := timeout.All()
for k, v := range timeouts { for k, v := range timeouts {
if config.Timeouts[k] == "" {
config.Timeouts[k] = v.String() config.Timeouts[k] = v.String()
} }
}
// for the time being, keep the defaultConfig's version set at 1 so that // for the time being, keep the defaultConfig's version set at 1 so that
// when a config without a version is loaded from disk and has no version // when a config without a version is loaded from disk and has no version

View File

@ -39,6 +39,8 @@ separately (for example vendors may keep a custom runtime configuration in a
separate file without modifying the main `config.toml`). separate file without modifying the main `config.toml`).
Imported files will overwrite simple fields like `int` or Imported files will overwrite simple fields like `int` or
`string` (if not empty) and will append `array` and `map` fields. `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]** **[grpc]**
: Section for gRPC socket listener settings. Contains three properties: : Section for gRPC socket listener settings. Contains three properties:

View File

@ -28,6 +28,8 @@ import (
"github.com/containerd/containerd/plugin" "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 // Config provides containerd configuration data for the server
type Config struct { type Config struct {
// Version of the config file // Version of the config file
@ -321,6 +323,10 @@ func mergeConfig(to, from *Config) error {
to.ProxyPlugins[k] = v to.ProxyPlugins[k] = v
} }
for k, v := range from.Timeouts {
to.Timeouts[k] = v
}
return nil return nil
} }