Allow timeouts to be configured in config
This adds a singleton `timeout` package that will allow services and user to configure timeouts in the daemon. When a service wants to use a timeout, it should declare a const and register it's default value inside an `init()` function for that package. When the default config is generated, we can use the `timeout` package to provide the available timeout keys so that a user knows that they can configure. These show up in the config as follows: ```toml [timeouts] "io.containerd.timeout.shim.cleanup" = 5 "io.containerd.timeout.shim.load" = 5 "io.containerd.timeout.shim.shutdown" = 3 "io.containerd.timeout.task.state" = 2 ``` Timeouts in the config are specified in seconds. Timeouts are very hard to get right and giving this power to the user to configure things is a huge improvement. Machines can be faster and slower and depending on the CPU or load of the machine, a timeout may need to be adjusted. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/containerd/containerd/pkg/timeout"
|
||||
"github.com/containerd/containerd/services/server"
|
||||
srvconfig "github.com/containerd/containerd/services/server/config"
|
||||
"github.com/urfave/cli"
|
||||
@@ -68,6 +69,12 @@ var configCommand = cli.Command{
|
||||
config.Plugins[p.URI()] = p.Config
|
||||
}
|
||||
}
|
||||
timeouts := timeout.All()
|
||||
config.Timeouts = make(map[string]string)
|
||||
for k, v := range timeouts {
|
||||
config.Timeouts[k] = v.String()
|
||||
}
|
||||
|
||||
_, err = config.WriteTo(os.Stdout)
|
||||
return err
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user