Merge pull request #5378 from Iceber/check-flag

runtime/shim: check the namespace flag first
This commit is contained in:
Maksym Pavlenko 2021-04-18 09:10:46 -07:00 committed by GitHub
commit 69a30ad581
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,12 +175,17 @@ func run(id string, initFunc Init, config Config) error {
return nil
}
if namespaceFlag == "" {
return fmt.Errorf("shim namespace cannot be empty")
}
setRuntime()
signals, err := setupSignals(config)
if err != nil {
return err
}
if !config.NoSubreaper {
if err := subreaper(); err != nil {
return err
@ -188,17 +193,12 @@ func run(id string, initFunc Init, config Config) error {
}
ttrpcAddress := os.Getenv(ttrpcAddressEnv)
publisher, err := NewPublisher(ttrpcAddress)
if err != nil {
return err
}
defer publisher.Close()
if namespaceFlag == "" {
return fmt.Errorf("shim namespace cannot be empty")
}
ctx := namespaces.WithNamespace(context.Background(), namespaceFlag)
ctx = context.WithValue(ctx, OptsKey{}, Opts{BundlePath: bundlePath, Debug: debugFlag})
ctx = log.WithLogger(ctx, log.G(ctx).WithField("runtime", id))
@ -207,6 +207,7 @@ func run(id string, initFunc Init, config Config) error {
if err != nil {
return err
}
switch action {
case "delete":
logger := logrus.WithFields(logrus.Fields{