mirror of
				https://github.com/opencontainers/runc.git
				synced 2025-11-01 03:22:38 +08:00 
			
		
		
		
	Integrate poststart hooks with spec
* Call poststart hooks after the container is started * Tie in with spec configuration Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
		| @@ -183,6 +183,22 @@ func (c *linuxContainer) Start(process *Process) error { | |||||||
| 	if doInit { | 	if doInit { | ||||||
| 		c.updateState(parent) | 		c.updateState(parent) | ||||||
| 	} | 	} | ||||||
|  | 	if c.config.Hooks != nil { | ||||||
|  | 		s := configs.HookState{ | ||||||
|  | 			Version: c.config.Version, | ||||||
|  | 			ID:      c.id, | ||||||
|  | 			Pid:     parent.pid(), | ||||||
|  | 			Root:    c.config.Rootfs, | ||||||
|  | 		} | ||||||
|  | 		for _, hook := range c.config.Hooks.Poststart { | ||||||
|  | 			if err := hook.Run(s); err != nil { | ||||||
|  | 				if err := parent.terminate(); err != nil { | ||||||
|  | 					logrus.Warn(err) | ||||||
|  | 				} | ||||||
|  | 				return newSystemError(err) | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										8
									
								
								spec.go
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								spec.go
									
									
									
									
									
								
							| @@ -712,6 +712,14 @@ func createHooks(rspec *specs.LinuxRuntimeSpec, config *configs.Config) { | |||||||
| 		} | 		} | ||||||
| 		config.Hooks.Prestart = append(config.Hooks.Prestart, configs.NewCommandHook(cmd)) | 		config.Hooks.Prestart = append(config.Hooks.Prestart, configs.NewCommandHook(cmd)) | ||||||
| 	} | 	} | ||||||
|  | 	for _, h := range rspec.Hooks.Poststart { | ||||||
|  | 		cmd := configs.Command{ | ||||||
|  | 			Path: h.Path, | ||||||
|  | 			Args: h.Args, | ||||||
|  | 			Env:  h.Env, | ||||||
|  | 		} | ||||||
|  | 		config.Hooks.Poststart = append(config.Hooks.Poststart, configs.NewCommandHook(cmd)) | ||||||
|  | 	} | ||||||
| 	for _, h := range rspec.Hooks.Poststop { | 	for _, h := range rspec.Hooks.Poststop { | ||||||
| 		cmd := configs.Command{ | 		cmd := configs.Command{ | ||||||
| 			Path: h.Path, | 			Path: h.Path, | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mrunal Patel
					Mrunal Patel