Load spec during "runsc start" to process flag overrides

Subcontainers are only configured when the container starts, however because
start doesn't load the spec, flag annotations that may override flags were
not getting applied to the configuration.

Updates #3494

PiperOrigin-RevId: 338610953
This commit is contained in:
Fabricio Voznika
2020-10-22 22:07:06 -07:00
committed by gVisor bot
parent cc772f3d54
commit 293877cf64
2 changed files with 8 additions and 1 deletions
+1 -1
View File
@@ -737,7 +737,7 @@ func (l *Loader) createContainerProcess(root bool, cid string, info *containerIn
return nil, err
}
// Add the HOME enviroment variable if it is not already set.
// Add the HOME environment variable if it is not already set.
var envv []string
if kernel.VFS2Enabled {
envv, err = user.MaybeAddExecUserHomeVFS2(ctx, info.procArgs.MountNamespaceVFS2,
+7
View File
@@ -21,6 +21,7 @@ import (
"gvisor.dev/gvisor/runsc/config"
"gvisor.dev/gvisor/runsc/container"
"gvisor.dev/gvisor/runsc/flag"
"gvisor.dev/gvisor/runsc/specutils"
)
// Start implements subcommands.Command for the "start" command.
@@ -58,6 +59,12 @@ func (*Start) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) s
if err != nil {
Fatalf("loading container: %v", err)
}
// Read the spec again here to ensure flag annotations from the spec are
// applied to "conf".
if _, err := specutils.ReadSpec(c.BundleDir, conf); err != nil {
Fatalf("reading spec: %v", err)
}
if err := c.Start(conf); err != nil {
Fatalf("starting container: %v", err)
}