This also moves the variable holding the default runtime name from the
engine-api repository into docker repository
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
(cherry picked from commit 69af7d0d13670b8e2a03a38b4d9a849fc109b338)
| ... | ... |
@@ -14,7 +14,6 @@ import ( |
| 14 | 14 |
"github.com/docker/docker/pkg/discovery" |
| 15 | 15 |
flag "github.com/docker/docker/pkg/mflag" |
| 16 | 16 |
"github.com/docker/docker/registry" |
| 17 |
- "github.com/docker/engine-api/types" |
|
| 18 | 17 |
"github.com/imdario/mergo" |
| 19 | 18 |
) |
| 20 | 19 |
|
| ... | ... |
@@ -27,6 +26,9 @@ const ( |
| 27 | 27 |
// maximum number of uploads that |
| 28 | 28 |
// may take place at a time for each push. |
| 29 | 29 |
defaultMaxConcurrentUploads = 5 |
| 30 |
+ // stockRuntimeName is the reserved name/alias used to represent the |
|
| 31 |
+ // OCI runtime being shipped with the docker daemon package. |
|
| 32 |
+ stockRuntimeName = "runc" |
|
| 30 | 33 |
) |
| 31 | 34 |
|
| 32 | 35 |
const ( |
| ... | ... |
@@ -426,12 +428,12 @@ func ValidateConfiguration(config *Config) error {
|
| 426 | 426 |
|
| 427 | 427 |
// validate that "default" runtime is not reset |
| 428 | 428 |
if runtimes := config.GetAllRuntimes(); len(runtimes) > 0 {
|
| 429 |
- if _, ok := runtimes[types.DefaultRuntimeName]; ok {
|
|
| 430 |
- return fmt.Errorf("runtime name '%s' is reserved", types.DefaultRuntimeName)
|
|
| 429 |
+ if _, ok := runtimes[stockRuntimeName]; ok {
|
|
| 430 |
+ return fmt.Errorf("runtime name '%s' is reserved", stockRuntimeName)
|
|
| 431 | 431 |
} |
| 432 | 432 |
} |
| 433 | 433 |
|
| 434 |
- if defaultRuntime := config.GetDefaultRuntimeName(); defaultRuntime != "" && defaultRuntime != types.DefaultRuntimeName {
|
|
| 434 |
+ if defaultRuntime := config.GetDefaultRuntimeName(); defaultRuntime != "" && defaultRuntime != stockRuntimeName {
|
|
| 435 | 435 |
runtimes := config.GetAllRuntimes() |
| 436 | 436 |
if _, ok := runtimes[defaultRuntime]; !ok {
|
| 437 | 437 |
return fmt.Errorf("specified default runtime '%s' does not exist", defaultRuntime)
|
| ... | ... |
@@ -88,8 +88,8 @@ func (config *Config) InstallFlags(cmd *flag.FlagSet, usageFn func(string) strin |
| 88 | 88 |
cmd.StringVar(&config.ContainerdAddr, []string{"-containerd"}, "", usageFn("Path to containerd socket"))
|
| 89 | 89 |
cmd.BoolVar(&config.LiveRestore, []string{"-live-restore"}, false, usageFn("Enable live restore of docker when containers are still running"))
|
| 90 | 90 |
config.Runtimes = make(map[string]types.Runtime) |
| 91 |
- cmd.Var(runconfigopts.NewNamedRuntimeOpt("runtimes", &config.Runtimes), []string{"-add-runtime"}, usageFn("Register an additional OCI compatible runtime"))
|
|
| 92 |
- cmd.StringVar(&config.DefaultRuntime, []string{"-default-runtime"}, types.DefaultRuntimeName, usageFn("Default OCI runtime to be used"))
|
|
| 91 |
+ cmd.Var(runconfigopts.NewNamedRuntimeOpt("runtimes", &config.Runtimes, stockRuntimeName), []string{"-add-runtime"}, usageFn("Register an additional OCI compatible runtime"))
|
|
| 92 |
+ cmd.StringVar(&config.DefaultRuntime, []string{"-default-runtime"}, stockRuntimeName, usageFn("Default OCI runtime to be used"))
|
|
| 93 | 93 |
|
| 94 | 94 |
config.attachExperimentalFlags(cmd, usageFn) |
| 95 | 95 |
} |
| ... | ... |
@@ -50,7 +50,7 @@ func (config *Config) GetRuntime(name string) *types.Runtime {
|
| 50 | 50 |
|
| 51 | 51 |
// GetDefaultRuntimeName returns the current default runtime |
| 52 | 52 |
func (config *Config) GetDefaultRuntimeName() string {
|
| 53 |
- return types.DefaultRuntimeName |
|
| 53 |
+ return stockRuntimeName |
|
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
// GetAllRuntimes returns a copy of the runtimes map |
| ... | ... |
@@ -532,7 +532,7 @@ func (daemon *Daemon) platformReload(config *Config, attributes *map[string]stri |
| 532 | 532 |
if config.IsValueSet("runtimes") {
|
| 533 | 533 |
daemon.configStore.Runtimes = config.Runtimes |
| 534 | 534 |
// Always set the default one |
| 535 |
- daemon.configStore.Runtimes[types.DefaultRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
|
|
| 535 |
+ daemon.configStore.Runtimes[stockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
|
|
| 536 | 536 |
} |
| 537 | 537 |
|
| 538 | 538 |
if config.DefaultRuntime != "" {
|
| ... | ... |
@@ -574,12 +574,12 @@ func verifyDaemonSettings(config *Config) error {
|
| 574 | 574 |
} |
| 575 | 575 |
|
| 576 | 576 |
if config.DefaultRuntime == "" {
|
| 577 |
- config.DefaultRuntime = types.DefaultRuntimeName |
|
| 577 |
+ config.DefaultRuntime = stockRuntimeName |
|
| 578 | 578 |
} |
| 579 | 579 |
if config.Runtimes == nil {
|
| 580 | 580 |
config.Runtimes = make(map[string]types.Runtime) |
| 581 | 581 |
} |
| 582 |
- config.Runtimes[types.DefaultRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
|
|
| 582 |
+ config.Runtimes[stockRuntimeName] = types.Runtime{Path: DefaultRuntimeBinary}
|
|
| 583 | 583 |
|
| 584 | 584 |
return nil |
| 585 | 585 |
} |
| ... | ... |
@@ -2409,7 +2409,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2409 | 2409 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2410 | 2410 |
|
| 2411 | 2411 |
// Run with default runtime explicitly |
| 2412 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2412 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2413 | 2413 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2414 | 2414 |
|
| 2415 | 2415 |
// Run with oci (same path as default) but keep it around |
| ... | ... |
@@ -2434,7 +2434,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2434 | 2434 |
<-time.After(1 * time.Second) |
| 2435 | 2435 |
|
| 2436 | 2436 |
// Run with default runtime |
| 2437 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2437 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2438 | 2438 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2439 | 2439 |
|
| 2440 | 2440 |
// Run with "oci" |
| ... | ... |
@@ -2451,8 +2451,8 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2451 | 2451 |
config = ` |
| 2452 | 2452 |
{
|
| 2453 | 2453 |
"runtimes": {
|
| 2454 |
- "default": {
|
|
| 2455 |
- "path": "docker-runc" |
|
| 2454 |
+ "runc": {
|
|
| 2455 |
+ "path": "my-runc" |
|
| 2456 | 2456 |
} |
| 2457 | 2457 |
} |
| 2458 | 2458 |
} |
| ... | ... |
@@ -2463,7 +2463,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2463 | 2463 |
<-time.After(1 * time.Second) |
| 2464 | 2464 |
|
| 2465 | 2465 |
content, _ := ioutil.ReadFile(s.d.logFile.Name()) |
| 2466 |
- c.Assert(string(content), checker.Contains, `file configuration validation failed (runtime name 'default' is reserved)`) |
|
| 2466 |
+ c.Assert(string(content), checker.Contains, `file configuration validation failed (runtime name 'runc' is reserved)`) |
|
| 2467 | 2467 |
|
| 2468 | 2468 |
// Check that we can select a default runtime |
| 2469 | 2469 |
config = ` |
| ... | ... |
@@ -2492,7 +2492,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromConfigFile(c *check.C) {
|
| 2492 | 2492 |
c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory") |
| 2493 | 2493 |
|
| 2494 | 2494 |
// Run with default runtime explicitly |
| 2495 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2495 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2496 | 2496 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2497 | 2497 |
} |
| 2498 | 2498 |
|
| ... | ... |
@@ -2505,7 +2505,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2505 | 2505 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2506 | 2506 |
|
| 2507 | 2507 |
// Run with default runtime explicitly |
| 2508 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2508 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2509 | 2509 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2510 | 2510 |
|
| 2511 | 2511 |
// Run with oci (same path as default) but keep it around |
| ... | ... |
@@ -2523,7 +2523,7 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2523 | 2523 |
c.Assert(err, check.IsNil) |
| 2524 | 2524 |
|
| 2525 | 2525 |
// Run with default runtime |
| 2526 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2526 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2527 | 2527 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2528 | 2528 |
|
| 2529 | 2529 |
// Run with "oci" |
| ... | ... |
@@ -2538,11 +2538,11 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2538 | 2538 |
|
| 2539 | 2539 |
// Check that we can't override the default runtime |
| 2540 | 2540 |
s.d.Stop() |
| 2541 |
- err = s.d.Start("--add-runtime", "default=docker-runc")
|
|
| 2541 |
+ err = s.d.Start("--add-runtime", "runc=my-runc")
|
|
| 2542 | 2542 |
c.Assert(err, check.NotNil) |
| 2543 | 2543 |
|
| 2544 | 2544 |
content, _ := ioutil.ReadFile(s.d.logFile.Name()) |
| 2545 |
- c.Assert(string(content), checker.Contains, `runtime name 'default' is reserved`) |
|
| 2545 |
+ c.Assert(string(content), checker.Contains, `runtime name 'runc' is reserved`) |
|
| 2546 | 2546 |
|
| 2547 | 2547 |
// Check that we can select a default runtime |
| 2548 | 2548 |
s.d.Stop() |
| ... | ... |
@@ -2554,6 +2554,6 @@ func (s *DockerDaemonSuite) TestRunWithRuntimeFromCommandLine(c *check.C) {
|
| 2554 | 2554 |
c.Assert(out, checker.Contains, "/usr/local/bin/vm-manager: no such file or directory") |
| 2555 | 2555 |
|
| 2556 | 2556 |
// Run with default runtime explicitly |
| 2557 |
- out, err = s.d.Cmd("run", "--rm", "--runtime=default", "busybox", "ls")
|
|
| 2557 |
+ out, err = s.d.Cmd("run", "--rm", "--runtime=runc", "busybox", "ls")
|
|
| 2558 | 2558 |
c.Assert(err, check.IsNil, check.Commentf(out)) |
| 2559 | 2559 |
} |
| ... | ... |
@@ -437,7 +437,7 @@ func (s *DockerDaemonSuite) TestDaemonEvents(c *check.C) {
|
| 437 | 437 |
out, err = s.d.Cmd("events", "--since=0", "--until", daemonUnixTime(c))
|
| 438 | 438 |
c.Assert(err, checker.IsNil) |
| 439 | 439 |
|
| 440 |
- c.Assert(out, checker.Contains, fmt.Sprintf("daemon reload %s (cluster-advertise=, cluster-store=, cluster-store-opts={}, debug=true, default-runtime=default, labels=[\"bar=foo\"], max-concurrent-downloads=1, max-concurrent-uploads=5, name=%s, runtimes=default:{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\"], max-concurrent-downloads=1, max-concurrent-uploads=5, name=%s, runtimes=runc:{docker-runc []})", daemonID, daemonName))
|
|
| 441 | 441 |
} |
| 442 | 442 |
|
| 443 | 443 |
func (s *DockerDaemonSuite) TestDaemonEventsWithFilters(c *check.C) {
|
| ... | ... |
@@ -36,7 +36,7 @@ func (s *DockerSuite) TestInfoEnsureSucceeds(c *check.C) {
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
if DaemonIsLinux.Condition() {
|
| 39 |
- stringsToCheck = append(stringsToCheck, "Runtimes:", "Default Runtime: default") |
|
| 39 |
+ stringsToCheck = append(stringsToCheck, "Runtimes:", "Default Runtime: runc") |
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
if utils.ExperimentalBuild() {
|
| ... | ... |
@@ -9,16 +9,17 @@ import ( |
| 9 | 9 |
|
| 10 | 10 |
// RuntimeOpt defines a map of Runtimes |
| 11 | 11 |
type RuntimeOpt struct {
|
| 12 |
- name string |
|
| 13 |
- values *map[string]types.Runtime |
|
| 12 |
+ name string |
|
| 13 |
+ stockRuntimeName string |
|
| 14 |
+ values *map[string]types.Runtime |
|
| 14 | 15 |
} |
| 15 | 16 |
|
| 16 | 17 |
// NewNamedRuntimeOpt creates a new RuntimeOpt |
| 17 |
-func NewNamedRuntimeOpt(name string, ref *map[string]types.Runtime) *RuntimeOpt {
|
|
| 18 |
+func NewNamedRuntimeOpt(name string, ref *map[string]types.Runtime, stockRuntime string) *RuntimeOpt {
|
|
| 18 | 19 |
if ref == nil {
|
| 19 | 20 |
ref = &map[string]types.Runtime{}
|
| 20 | 21 |
} |
| 21 |
- return &RuntimeOpt{name: name, values: ref}
|
|
| 22 |
+ return &RuntimeOpt{name: name, values: ref, stockRuntimeName: stockRuntime}
|
|
| 22 | 23 |
} |
| 23 | 24 |
|
| 24 | 25 |
// Name returns the name of the NamedListOpts in the configuration. |
| ... | ... |
@@ -40,8 +41,8 @@ func (o *RuntimeOpt) Set(val string) error {
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
parts[0] = strings.ToLower(parts[0]) |
| 43 |
- if parts[0] == types.DefaultRuntimeName {
|
|
| 44 |
- return fmt.Errorf("runtime name 'default' is reserved")
|
|
| 43 |
+ if parts[0] == o.stockRuntimeName {
|
|
| 44 |
+ return fmt.Errorf("runtime name '%s' is reserved", o.stockRuntimeName)
|
|
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 | 47 |
if _, ok := (*o.values)[parts[0]]; ok {
|