Skip to content

Commit

Permalink
Pass bundle dir as the workdir for hooks exec run function
Browse files Browse the repository at this point in the history
Signed-off-by: Fang-Pen Lin <[email protected]>
  • Loading branch information
fangpenlin committed Jun 23, 2023
1 parent f4e8be4 commit 4092e4e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions run_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ rootless=%d
}

// Setup OCI hooks
_, err = b.setupOCIHooks(spec, (len(options.Mounts) > 0 || len(volumes) > 0))
_, err = b.setupOCIHooks(spec, path, (len(options.Mounts) > 0 || len(volumes) > 0))
if err != nil {
return fmt.Errorf("unable to setup OCI hooks: %w", err)
}
Expand Down Expand Up @@ -383,7 +383,7 @@ rootless=%d
return err
}

func (b *Builder) setupOCIHooks(config *spec.Spec, hasVolumes bool) (map[string][]spec.Hook, error) {
func (b *Builder) setupOCIHooks(config *spec.Spec, bundlePath string, hasVolumes bool) (map[string][]spec.Hook, error) {
allHooks := make(map[string][]spec.Hook)
if len(b.CommonBuildOpts.OCIHooksDir) == 0 {
if unshare.IsRootless() {
Expand Down Expand Up @@ -420,7 +420,15 @@ func (b *Builder) setupOCIHooks(config *spec.Spec, hasVolumes bool) (map[string]
}
}

hookErr, err := hooksExec.RuntimeConfigFilter(context.Background(), allHooks["precreate"], config, hooksExec.DefaultPostKillTimeout)
hookErr, err := hooksExec.RuntimeConfigFilter(
context.Background(),
hooksExec.RuntimeConfigFilterOptions{
Hooks: allHooks["precreate"],
Dir: bundlePath,
Config: config,
PostKillTimeout: hooksExec.DefaultPostKillTimeout,
},
)
if err != nil {
logrus.Warnf("Container: precreate hook: %v", err)
if hookErr != nil && hookErr != err {
Expand Down

0 comments on commit 4092e4e

Please sign in to comment.