Skip to content

fix(sdk): let an interrupted apply finish the OpenTofu operations in progress - #14224

Merged
cv merged 2 commits into
v1from
fix/14155-interrupted-apply
Nov 5, 2026
Merged

cv merged 2 commits into
v1from
fix/14155-interrupted-apply

Conversation

@cuongdangn

Copy link
Copy Markdown

Failure

On an interrupt, an apply or destroy sent SIGINT to OpenTofu and killed it 5 seconds later, even when OpenTofu was still waiting for a resource operation in progress.
On a managed Kubernetes or OpenShift gateway, that operation is often the Helm provider's install, which waits up to 600 seconds for the gateway and can't be cancelled: the provider runs Helm without a context (hashicorp/terraform-provider-helm#776, closed without a change).
The kill then left the gateway's Helm release pending-install in the cluster without a binding in the state, which no later apply or destroy could recover (#14155, run r5).

Decision

After the first interrupt, an apply or destroy lets OpenTofu finish the resource operations in progress and save the state: OpenTofu's own interrupt handling stops it from starting new ones.
The CLI shows a durable stopping notice that says how to stop at once, and a second interrupt (Deployment::with_force_stop) does.
Other OpenTofu commands keep the 5-second grace.
This matches tofu apply, where the first interrupt lets operations in progress finish and a second stops at once.

Split from #14169, as its review suggested; #14169 carries the same two commits until this merges.
test(sdk): end the interrupted apply test's wait after 30 seconds keeps the interrupt test from hanging where a shell starts with interrupts ignored.

Refs #14155

Validation

🤖 Generated with Claude Code

cuongdangn and others added 2 commits November 5, 2026 14:27
…progress

An interrupt during an apply or destroy sent SIGINT to OpenTofu and killed its
process group 5 seconds later. OpenTofu was still waiting for the operations in
progress, so a Helm install was left pending-install and the bindings of
resources already created could be missing from the state (#14155).

The first interrupt now lets OpenTofu stop by itself: it starts no further
resource operations, finishes those in progress, and saves the state. The SDK
emits Progress::Stopping while it waits, and Deployment::with_force_stop ends
OpenTofu at once; the CLI cancels that token at a second interrupt, which its
stopping notice explains. Other OpenTofu commands keep the 5-second grace.

Refs #14155

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The script that stands in for OpenTofu waited in an endless loop for the
interrupt. A shell that starts with interrupts ignored, such as a job that a
non-interactive shell runs in the background, cannot trap them, so the test
hung there. The wait now ends after 30 seconds and the test fails instead.
OpenTofu itself installs its interrupt handler even when it starts with
interrupts ignored.

Refs #14155

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cuongdangn

Copy link
Copy Markdown
Author
Authoring session — opening
Field Status Value Evidence or limit
Harness recorded Claude Code 2.1.312, then 2.1.314 from 2026-10-30T10:27Z Version fields of the session record
Skills recorded test-driven-development (injected); terminal-ux (injected); nemoclaw-contributor-create-pr (injected, and again after each later compaction); artifact-diagramming (injected) Skill invocations and post-compaction injections in the session record to the cutoff; the last two were first loaded for another pull request and an explanation page in the same session
Instruction files recorded CLAUDE.md (injected at start and after each compaction); AGENTS.md (complete read); WRITING.md (complete read); .github/PULL_REQUEST_TEMPLATE.md (complete read, again for this pull request); .github/SESSION_REPORT_TEMPLATE.md (complete read, again for this pull request); user memory index (injected) Injections and reads in the session record to the cutoff
Tool calls partial Whole session: 1839 (Bash: 1226; Edit: 253; Read: 84; Write: 70; TaskUpdate: 48; MCP tools: 46; TaskCreate: 26; ToolSearch: 20; TaskStop: 17; WebFetch: 13; Monitor: 12; WebSearch: 11; Artifact: 5; Skill: 4; AskUserQuestion: 2; TaskList: 1; Agent: 1). Since the investigation of #14155 began: 1004 (Bash: 740; Edit: 104; Read: 48; Write: 32; TaskUpdate: 24; TaskCreate: 15; TaskStop: 11; ToolSearch: 9; Monitor: 8; Artifact: 5; Skill: 3; AskUserQuestion: 2; MCP tools: 2; WebFetch: 1). Since the fix in #14169 was requested: 773 (Bash: 556; Edit: 94; Read: 48; Write: 22; TaskUpdate: 22; TaskCreate: 14; ToolSearch: 6; Skill: 2; TaskStop: 2; Artifact: 2; AskUserQuestion: 2; MCP tools: 2; WebFetch: 1). Since this split was requested: 37 (Bash: 29; TaskCreate: 3; TaskUpdate: 2; Write: 2; ToolSearch: 1). Nested: 71 by one reviewer subagent for another pull request, before the investigation Main-thread tool calls in the session record, including failed and denied calls; each Bash call counts once, and the processes it started are not counted
Session window recorded 2026-10-30T04:57Z to 2026-11-05T07:42Z; about 6 days 2 hours 44 minutes. Investigation of #14155 from 2026-11-03T10:16Z, about 1 day 21 hours 26 minutes; the fix in #14169, where this change was written, from 2026-11-03T18:35Z, about 1 day 13 hours 7 minutes; this split from 2026-11-05T07:25Z, about 16 minutes First record to the cutoff, including idle time; the first records continue an earlier conversation that the compaction at 2026-10-30T05:52Z summarized
Compactions recorded 5; 3 since the investigation began, 2 since the fix was requested, none since this split was requested Compaction boundaries in the session record to the cutoff
Models recorded claude-opus-5-5 Assistant records to the cutoff; one synthetic placeholder record has no model
Reasoning levels recorded max Effort field of every assistant record to the cutoff; no changes

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@cuongdangn
cuongdangn requested a review from cv November 5, 2026 08:51
@cv
cv merged commit 62c4f7a into v1 Nov 5, 2026
56 of 57 checks passed
@cv
cv deleted the fix/14155-interrupted-apply branch November 5, 2026 09:25
cv added a commit that referenced this pull request Nov 5, 2026
…rrupted (#14169)

Managed Kubernetes and OpenShift gateways recover from an install that
fails: Helm removes the failed release itself, a release that a stopped
install leaves is named with the command that removes it, and an
interrupted first apply keeps the bindings it created.

## Problem

An apply that failed or was interrupted while Helm installed the gateway
release left a deployment that neither apply nor destroy could recover
(#14155):

- When Helm's 600-second wait timed out, the release stayed `failed` in
the cluster, but the pinned Helm provider (3.3.0) returned the error
without saving the release in the state. The next apply failed with
`cannot re-use a name that is still in use`, and destroy failed with
`observation is incomplete`; only `helm uninstall`, then destroy and
apply, recovered the deployment.
- In a state directory without a state file, OpenTofu saved an
interrupted apply's snapshot with only the last resource it updated, so
the storage binding was lost and plan and destroy refused.

Resolves #14155, with #14224, which lets the first interrupt finish the
operations in progress.

## Change

- The gateway release sets `atomic`: when its install fails or Helm's
wait times out, Helm uninstalls the release before the Helm provider
returns, and the error carries Helm's reason. The namespace, the
credential key, and the gateway's volume claims stay. A failed upgrade
now rolls back, as `helm upgrade --atomic` does.
- A second interrupt, a crash, or a killed process can still stop the
install and leave the release `pending-install`. When the cluster
records the gateway release and the state does not bind it, plan, apply,
and destroy stop before changing anything, name the release, and give
its `helm uninstall` command (`Error::UnboundRelease`). NemoClaw can't
tell that release from another owner's, so it leaves it.
- The `kind-kubernetes-development` live case refuses the gateway's
StatefulSet with an admission policy between its destroy and redeploy
(the `hcl_live::admission` probe): the install must fail with the
refusal, leave no record of the release, and keep the retained storage
bound. It replaces the same check in the Rust gateway live test that
#14174 retired.
- When the state file is missing, a refresh-only apply of an empty
configuration creates it before the first plan, which avoids the
OpenTofu bug without reading the deployment's data sources before the
managed gateway exists.
- Rejected: the first version of this pull request recorded each install
in `helm-install.json` and let destroy remove a leftover release through
a separate OpenTofu root; `atomic` covers the common failures with much
less code. `upgrade_install` doesn't help: Helm refuses to upgrade a
`pending-install` release, and it would take over a release by name
alone.
- Upstream boundaries: Helm's own `atomic` option removes a failed
install, the existing authentication observation establishes that a
release record exists, and NemoClaw removes no release that it can't
establish as its own. `internal-docs/design/scope.md` records both
workarounds:
- the state file, until OpenTofu fixes opentofu/opentofu#4809 (since
v1.11.0);
- `atomic` and the unbound-release check, until the Helm provider saves
a failed install as tainted again,
hashicorp/terraform-provider-helm#1886 (since 3.0.0).

  #14227 tracks removing both.

## Beyond CI

On the single-node OpenShift 4.22.18 cluster from #14139, with this
branch's bundle at 06be60b, which already carried #14224's change,
and the document from #14155's runs (OIDC profile, one OpenClaw
sandbox):

- Helm's 600-second wait timed out while the gateway's OIDC issuer was
unreachable. The apply failed with "release nc-6fe4115dbd9285c4-gateway
failed, and has been uninstalled due to atomic being set: context
deadline exceeded" and left no release record. The state kept storage
and authentication, and the namespace kept the gateway's volume claim
and its key. With the issuer back, plan installed the release again
without refusing, apply completed in 67 seconds, and the agent replied.
- One interrupt during the install, with the issuer reachable again 2
seconds later: the CLI printed the stopping notice, Helm's install
completed after 49 seconds, and the apply stopped with exit code 130.
The state bound the release; a reapply completed in 32 seconds, and the
agent replied.
- Two interrupts 10 seconds apart: the apply stopped at once, leaving
the release `pending-install` without a binding while the state kept
storage and authentication. Plan and destroy stopped within 5 seconds,
named the release and its `helm uninstall` command, and left the release
records unchanged. After that command, apply completed in 67 seconds,
and the agent replied.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
cv added a commit that referenced this pull request Nov 11, 2026
…ms (#14413)

The release notes now list every user-visible change on `v1` since the
`v0.1.0-rc9` tag, including the breaking ones, and four example pages
drop claims that later changes made false.

## Problem

`docs/about/release-notes.md` listed three breaking changes and none of
the features, fixes, and onboarding changes that reached `v1` after
`v0.1.0-rc9`; it didn't name the configuration shapes the parser now
rejects or the intent record version `v0.1.0-rc9` writes.
Some example claims went stale:

- `examples/spark/README.md` said the pinned OpenShell has the Podman
TLS initialization blocker, ai-openshell/openshell#3427; its fix merged before
OpenShell 0.1.0, and `v1` pins 0.1.7.
- `examples/station/README.md` and `examples/gtc-dc/README.md` required
exactly one visible GPU on the host; since #13929,
`container.gpuDevices` lets a service on a host with more GPUs request
one.
- `examples/hcl/travel-team` said Fabric's Deep Agents adapter can't
turn reasoning off, NVIDIA/NeMo-Fabric#433; NVIDIA/NeMo-Fabric#439 fixed
that, and the pinned catalog's Deep Agents `reasoning_effort` accepts
`none`.
- The travel team cited #13313 for the booking key its service doesn't
receive, but #13313 closed when `openshell_api` landed.

## Change

- `docs/about/release-notes.md` gains "Changes Since v0.1.0-rc9",
grouped by area, from the commits in `v0.1.0-rc9..origin/v1`; where a
later commit changed an earlier one, the entry describes the current
code, and changes added and removed after the tag aren't listed:
- Agents and interfaces: #14037, #14038, #14269, #13981, #14024, #14186,
#14052, #14385, #13971, #13858, #13947, #14039, #14042, #14044, #14343.
- Inference: #13929, #14391, #14396, #14398, #14400, #13963, #13912,
#13964, #14388, #14390, #14397.
- Gateways and Kubernetes: #13909, #13970, #13922 (an existing
namespace, refused at plan by #13756, is now bound; cluster-wide reads
dropped), #14014, #14169, #13921.
- Plan, apply, and diagnostics: #14224, #13756, #14141, #14133, #14135,
#13775, #13744, #13701.
- Onboarding: #13693, #13695, #13741, #13757, #13851, #13978, #14228,
#14233, #14334, #14336.
- Examples and builds: #14166, #14184, #14188, #14191, #14192, #14200,
#13889, #14267, #14312, #14315, #14355, b30e9b4, #13781, #13813,
#14246, and the pins in `versions.json` and `image/fabric/Dockerfile`.
- Its breaking changes since the tag:
- the intent record moving from 15, which `v0.1.0-rc9` writes, through
16 (#14266), 17 (#14343), 18 (#13929), 19 (#14391) and 20 (#14394);
  - name-keyed `sandboxes` and `inferenceProviders` (#13703, #13705);
- a recipe `compatibility.gpu` outside every hardware profile (#13912);
- model tuning the adapter doesn't accept (#14111), and Hermes's
`max_tokens` losing its default (#14296);
  - `skills.paths` resolution (#14296);
  - endpoint and `networkCIDR` validation (#13847, #14081);
- the HCL `gateway_values` attribute (#14014), and Kubernetes ownership
receipts from before #13922 and #14014.
  The two earlier items stay, under their own heading.
- `examples/spark/README.md` replaces the closed OpenShell#3427 blocker
with the Podman and remote-model limits in `docs/resources/limits.md`.
- `examples/station/README.md` and `examples/gtc-dc/README.md` require
one GPU visible in the model container, and point to
`container.gpuDevices` for a host with more.
- `examples/hcl/travel-team/README.md` and `WALKTHROUGH.md` drop the
NeMo-Fabric#433 limitation, and the travel team's booking-key statements
link #14417 instead of #13313.

Not listed, because both changes landed after the tag: Deep Agents Code
(#14043, #14250), `compatibility.gpuCount` (#14391, #14394), and the
"Creating infrastructure state" progress step (#14169, #14248).

Checked and left unchanged: the root `README.md`,
`crates/nemoclaw-onboarding/README.md`,
`crates/nemoclaw-cli/assets/README.md`, `internal-docs/README.md`, the
other example READMEs, and every example YAML header comment. The GPU
autoscaling README and `load.sh` read the JSON fields `OperationResult`
serializes, and ai-openshell/openshell#4287 is fixed only after the pinned
0.1.7. The two pre-tag release-note items still match the schema and
SDK. `docs/README.md` is left to #14412, which retires the stale field
reference snapshot it describes.

Not verified: whether Hermes sends the booking key's placeholder to MCP
servers; #14417 tracks the live check.

## Beyond CI

Each relative link and anchor in the changed files resolves to an
existing file and heading.
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch labels Nov 13, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output area: sandbox OpenShell sandbox lifecycle, runtime, config, or recovery bug-fix PR fixes a bug or regression platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants