Skip to content

Commit

Permalink
[NO NEW TESTS NEEDED] Pass bundle dir as the workdir for hooks exec r…
Browse files Browse the repository at this point in the history
…un function

Signed-off-by: Fang-Pen Lin <[email protected]>
  • Loading branch information
fangpenlin committed Jun 28, 2023
1 parent 6589be3 commit 715ae4d
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 @@ -318,7 +318,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 @@ -379,7 +379,7 @@ rootless=%d
return err
}

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

hookErr, err := hooksExec.RuntimeConfigFilter(context.Background(), allHooks["precreate"], config, hooksExec.DefaultPostKillTimeout) //nolint:staticcheck
hookErr, err := hooksExec.RuntimeConfigFilterWithOptions(
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 715ae4d

Please sign in to comment.