Merge pull request #5378 from Iceber/check-flag
runtime/shim: check the namespace flag first
This commit is contained in:
		| @@ -175,12 +175,17 @@ func run(id string, initFunc Init, config Config) error { | |||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	if namespaceFlag == "" { | ||||||
|  | 		return fmt.Errorf("shim namespace cannot be empty") | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	setRuntime() | 	setRuntime() | ||||||
|  |  | ||||||
| 	signals, err := setupSignals(config) | 	signals, err := setupSignals(config) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if !config.NoSubreaper { | 	if !config.NoSubreaper { | ||||||
| 		if err := subreaper(); err != nil { | 		if err := subreaper(); err != nil { | ||||||
| 			return err | 			return err | ||||||
| @@ -188,17 +193,12 @@ func run(id string, initFunc Init, config Config) error { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ttrpcAddress := os.Getenv(ttrpcAddressEnv) | 	ttrpcAddress := os.Getenv(ttrpcAddressEnv) | ||||||
|  |  | ||||||
| 	publisher, err := NewPublisher(ttrpcAddress) | 	publisher, err := NewPublisher(ttrpcAddress) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	defer publisher.Close() | 	defer publisher.Close() | ||||||
|  |  | ||||||
| 	if namespaceFlag == "" { |  | ||||||
| 		return fmt.Errorf("shim namespace cannot be empty") |  | ||||||
| 	} |  | ||||||
| 	ctx := namespaces.WithNamespace(context.Background(), namespaceFlag) | 	ctx := namespaces.WithNamespace(context.Background(), namespaceFlag) | ||||||
| 	ctx = context.WithValue(ctx, OptsKey{}, Opts{BundlePath: bundlePath, Debug: debugFlag}) | 	ctx = context.WithValue(ctx, OptsKey{}, Opts{BundlePath: bundlePath, Debug: debugFlag}) | ||||||
| 	ctx = log.WithLogger(ctx, log.G(ctx).WithField("runtime", id)) | 	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 { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	switch action { | 	switch action { | ||||||
| 	case "delete": | 	case "delete": | ||||||
| 		logger := logrus.WithFields(logrus.Fields{ | 		logger := logrus.WithFields(logrus.Fields{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Maksym Pavlenko
					Maksym Pavlenko