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 {
225
225
// Exec signals the container to exec the users process at the end of the init.
226
226
func (c * Container ) Exec () error {
227
227
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 .currentOCIState ()
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
230
244
}
231
245
232
246
func (c * Container ) exec () error {
@@ -353,19 +367,6 @@ func (c *Container) start(process *Process) (retErr error) {
353
367
354
368
if process .Init {
355
369
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
- }
369
370
}
370
371
return nil
371
372
}
You can’t perform that action at this time.
0 commit comments