Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass cwd for hooks exec run function #4871

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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