File tree Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Expand file tree Collapse file tree 1 file changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -225,8 +225,22 @@ func (c *Container) Run(process *Process) error {
225225// Exec signals the container to exec the users process at the end of the init.
226226func (c * Container ) Exec () error {
227227 c .m .Lock ()
228- defer c .m .Unlock ()
229- return c .exec ()
228+ err := c .exec ()
229+ if err != nil {
230+ c .m .Unlock ()
231+ return err
232+ }
233+ c .m .Unlock ()
234+ s , err := c .OCIState ()
235+ if err != nil {
236+ return err
237+ }
238+ if c .Config ().Hooks != nil {
239+ if err := c .Config ().Hooks .Run (configs .Poststart , s ); err != nil {
240+ return fmt .Errorf ("run poststart hook %w" , err )
241+ }
242+ }
243+ return nil
230244}
231245
232246func (c * Container ) exec () error {
@@ -353,19 +367,6 @@ func (c *Container) start(process *Process) (retErr error) {
353367
354368 if process .Init {
355369 c .fifo .Close ()
356- if c .config .Hooks != nil {
357- s , err := c .currentOCIState ()
358- if err != nil {
359- return err
360- }
361-
362- if err := c .config .Hooks .Run (configs .Poststart , s ); err != nil {
363- if err := ignoreTerminateErrors (parent .terminate ()); err != nil {
364- logrus .Warn (fmt .Errorf ("error running poststart hook: %w" , err ))
365- }
366- return err
367- }
368- }
369370 }
370371 return nil
371372}
You can’t perform that action at this time.
0 commit comments