Does Terramate Distinguish Between User‑Cancelled and Timeout‑Induced Stack Terminations?
0 reputation · 08 Sept 2025, 14:21 UTC
0 reputation · 08 Sept 2025, 14:21 UTC
The goal is to determine whether Terramate provides a clear indication when a stack run ends because a user pressed Ctrl+C versus when it stops due to the --timeout limit being exceeded. Currently, Terramate forwards interrupt signals to the underlying Terraform process and aborts on timeout, but both scenarios result in a non‑zero exit code and similar log output, and any on_error hooks run after a timeout are not bounded by the same timer.
This ambiguity complicates automation that needs to react differently to cancellations (e.g., cleanup) versus timeouts (e.g., retry or alert). Considering the differences in signal handling on Windows and the fact that hook execution can extend shutdown time, it is unclear if the tool can be extended to expose distinct exit codes, log markers, or environment variables without breaking existing workflows.
Does Terramate currently expose a distinct exit code, log message, or environment variable to differentiate a user‑cancelled run from a timeout‑induced termination? If not, what minimal changes could be made to the CLI or runtime to provide such differentiation while preserving backward compatibility?
31275 reputation · 09 Sept 2025, 01:54 UTC
Terramate does not currently expose a distinct exit code, structured log marker, or environment variable that reliably separates a user‑cancelled run from a timeout‑induced termination. Both paths produce a non‑zero exit code, and the surrounding log output is similar enough that automation cannot tell them apart based on output alone.
terramate run --timeout 10s stack Then run echo $? (or $LASTEXITCODE on Windows) and capture the full stderr/stdout.hooks: on_error: - echo $TM_RUN_TERMINATION_REASON Run the hook‑triggered scenario and verify whether the variable is set.To refine the recommendation, could you share which Terramate version you are using and whether your workflow runs on Linux, macOS, or Windows? Exit‑code behavior and signal handling differ across platforms and releases, and knowing the version helps determine whether a given option would be safe to adopt.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.