Skip to content

fix(unikontainers): add default hook timeout to prevent Exec() hang#701

Open
Chennamma-Hotkar wants to merge 1 commit into
urunc-dev:mainfrom
Chennamma-Hotkar:fix/issue-hook-timeout-deadlock
Open

fix(unikontainers): add default hook timeout to prevent Exec() hang#701
Chennamma-Hotkar wants to merge 1 commit into
urunc-dev:mainfrom
Chennamma-Hotkar:fix/issue-hook-timeout-deadlock

Conversation

@Chennamma-Hotkar
Copy link
Copy Markdown

@Chennamma-Hotkar Chennamma-Hotkar commented May 18, 2026

Description

In pkg/unikontainers/utils.go executeHook() sets a contexts timeout only when hook.Timeout is set, per the OCI spec. That spec indicates that it is an optional field, *int and omitempty. If it is not set, executeHook() defaults to context.Background() which can never be cancelled. If a hook hangs indefinitely then executeHook() will never return, thereby hanging wg.Wait() called from executeHooksConcurrently(), which means errChan will never be closed and Exec() can hang forever and never log an error or warning. The comment on line 312 indicated that in the 'otherwise' case, we should use global config timeout, but this was not implemented in UruncConfig. Take the config value from UruncConfig and if the OCI spec hook has no timeout set, use it. Add a field to UruncConfig to indicate the default hook timeout in seconds. Add it to urunc.json.orig, set it to 30s.

Files changed:

  • pkg/unikontainers/urunc_config.go — added DefaultHookTimeoutSec
  • pkg/unikontainers/utils.go — use default timeout as fallback
  • pkg/unikontainers/unikontainers.go — pass default timeout to callers
  • pkg/unikontainers/urunc_config_test.go — assert default value is 30s

Related issues

How was this tested?

All existing unit tests pass (make unittest). Build passes (make). Added assertion for DefaultHookTimeoutSec in TestDefaultConfigs.

LLM usage

N/A

Checklist

  • I have read the contribution guide.
  • The linter passes locally (make lint).
  • The e2e tests of at least one tool pass locally (make test_ctr, make test_nerdctl, make test_docker, make test_crictl).
  • If LLMs were used: I have read the llm policy.

Add DefaultHookTimeoutSec field to UruncConfig (default 30s) and
use it as fallback in executeHook() when hook.Timeout is not set.
Prevents container startup hang when a hook has no timeout defined.

Fixes: urunc-dev#700
Signed-off-by: Chennamma-Hotkar <channuhotkar@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented May 18, 2026

Deploy Preview for urunc canceled.

Name Link
🔨 Latest commit 644a56a
🔍 Latest deploy log https://app.netlify.com/projects/urunc/deploys/6a0b4b0858be0700084722da

@cmainas
Copy link
Copy Markdown
Contributor

cmainas commented May 19, 2026

Hello @Chennamma-Hotkar please read the contribution guide

@cmainas cmainas added do-not-merge invalid This doesn't seem right labels May 19, 2026
@Chennamma-Hotkar
Copy link
Copy Markdown
Author

Hi @cmainas, I have edited the PR description to match the contribution guide template. I have added files changed how it was tested LLM disclosure and a checklist. Let me know if there is anything else that needs to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge invalid This doesn't seem right

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: hooks without timeout cause Exec() to hang indefinitely

2 participants