Skip to content

Commit d4204e8

Browse files
committed
Pass bundle dir as the workdir for hooks exec run function
Signed-off-by: Fang-Pen Lin <[email protected]>
1 parent 5422557 commit d4204e8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

run_linux.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ rootless=%d
319319
}
320320

321321
// Setup OCI hooks
322-
_, err = b.setupOCIHooks(spec, (len(options.Mounts) > 0 || len(volumes) > 0))
322+
_, err = b.setupOCIHooks(spec, path, (len(options.Mounts) > 0 || len(volumes) > 0))
323323
if err != nil {
324324
return fmt.Errorf("unable to setup OCI hooks: %w", err)
325325
}
@@ -380,7 +380,7 @@ rootless=%d
380380
return err
381381
}
382382

383-
func (b *Builder) setupOCIHooks(config *spec.Spec, hasVolumes bool) (map[string][]spec.Hook, error) {
383+
func (b *Builder) setupOCIHooks(config *spec.Spec, bundlePath string, hasVolumes bool) (map[string][]spec.Hook, error) {
384384
allHooks := make(map[string][]spec.Hook)
385385
if len(b.CommonBuildOpts.OCIHooksDir) == 0 {
386386
if unshare.IsRootless() {
@@ -417,7 +417,15 @@ func (b *Builder) setupOCIHooks(config *spec.Spec, hasVolumes bool) (map[string]
417417
}
418418
}
419419

420-
hookErr, err := hooksExec.RuntimeConfigFilter(context.Background(), allHooks["precreate"], config, hooksExec.DefaultPostKillTimeout)
420+
hookErr, err := hooksExec.RuntimeConfigFilterWithOptions(
421+
context.Background(),
422+
hooksExec.RuntimeConfigFilterOptions{
423+
Hooks: allHooks["precreate"],
424+
Dir: bundlePath,
425+
Config: config,
426+
PostKillTimeout: hooksExec.DefaultPostKillTimeout,
427+
},
428+
)
421429
if err != nil {
422430
logrus.Warnf("Container: precreate hook: %v", err)
423431
if hookErr != nil && hookErr != err {

0 commit comments

Comments
 (0)