Skip to content

Commit b38a391

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

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
@@ -318,7 +318,7 @@ rootless=%d
318318
}
319319

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

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

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

0 commit comments

Comments
 (0)