Skip to content

Fix #463: Ensure Helm action timeout and context timeout properly propagate from config - #1846

Open
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/463-timeout-honored
Open

Fix #463: Ensure Helm action timeout and context timeout properly propagate from config#1846
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/463-timeout-honored

Conversation

@dennismdejong

Copy link
Copy Markdown

Root Cause

The timeout attribute on helm_release was not reliably honored because:

  1. Context not propagated to Helm SDK: The provider creates a context with timeout (from timeouts block) but never passes it to the Helm action. Install.Run(), Upgrade.Run(), and Uninstall.Run() all use context.Background() internally, bypassing the providers deadline.

  2. Context timeout only from timeouts block: The context timeout was set exclusively from the Terraform timeouts { create/update/delete } block, ignoring the timeout attribute. If a user set only timeout (not the timeouts block), the context could expire before the Helm SDK finished.

  3. No default Kubernetes REST client timeout: The rest.Config.Timeout was left at 0 (no timeout), meaning individual Kubernetes API requests could hang indefinitely.

Changes

helm/resource_helm_release.go:

  • Extend context timeout to max(timeout_attr, timeouts_block) in Create/Update/Delete so the context never cancels before the Helm SDK internal timeout.
  • Set action.Timeout (Install/Upgrade/Uninstall) from the effective context timeout instead of the raw attribute.
  • Use Install.RunWithContext() and Upgrade.RunWithContext() to propagate the provider context (with its deadline) to the Helm SDK.

helm/kubeconfig.go:

  • Set a default 300s timeout on rest.Config in ToRESTConfig() to prevent indefinite hangs on Kubernetes API requests when no context deadline is present.

Testing

  • go build ./... passes
  • go test ./helm/... passes (all existing tests)

…perly propagate from config

- Extend context timeout with max(timeout_attr, timeouts_block) in Create/Update/Delete
  so the context doesn't cancel before the Helm SDK's internal timeout expires.
- Set Install/Upgrade/Uninstall action.Timeout from the effective context timeout.
- Use Install/Upgrade RunWithContext to propagate the provider context (with its
  deadline) to the Helm SDK, ensuring the timeouts block is honored.
- Set a 300s default timeout on the Kubernetes REST client config to prevent
  indefinite hangs when no context deadline is present.
@dennismdejong
dennismdejong requested review from a team, iam404 and rigalGit as code owners July 27, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant