Skip to content

Commit

Permalink
fix: prestart hooks exec
Browse files Browse the repository at this point in the history
  • Loading branch information
nixpig committed Dec 16, 2024
1 parent f34698c commit 32e76ee
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ This is a personal project for me to explore and better understand the OCI Runti
**🗒️ To do** (items remaining for _me_ to consider this 'complete')

- [ ] ~Unit tests~ Integration tests seem to be sufficing
- [ ] Fix networking
- [ ] Container cleanup
- [ ] Implement [Cgroups v2](https://github.com/opencontainers/runtime-spec/blob/main/config-linux.md#control-groups)
- [ ] Implement optional [Seccomp](https://github.com/opencontainers/runtime-spec/blob/main/config-linux.md#seccomp)
Expand Down
2 changes: 1 addition & 1 deletion container/container_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (c *Container) Start() error {
fmt.Println("Warning: failed to execute poststop hooks")
}

fmt.Println("Warning: failed to execute prestart hooks")
return fmt.Errorf("Warning: failed to execute prestart hooks: %w", err)

Check failure on line 31 in container/container_start.go

View workflow job for this annotation

GitHub Actions / build

error strings should not be capitalized (ST1005)
}

// send "start"
Expand Down
11 changes: 9 additions & 2 deletions lifecycle/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,16 @@ func ExecHooks(hooks []specs.Hook, state string) error {
defer cancel()
}

args := h.Args[1:]
args = append(args, state)
args := append(h.Args, state)
cmd := exec.CommandContext(ctx, h.Path, args...)

// I don't know why these need to be set here
// I thought they're set in the CommandContext above, but maybe not.
// -- Skill issue
cmd.Path = h.Path
cmd.Args = args
// ---

cmd.Env = h.Env
cmd.Stdin = strings.NewReader(state)

Expand Down

0 comments on commit 32e76ee

Please sign in to comment.