Skip to content

Add Calamari script timeout and localize K8s namespace resolution

Summary

Two small correctness fixes that harden the execution path with no wire, DB, enum, or interface changes.

  • Calamari wall-clock timeout (ProcessRunner): an opt-in SQUID_CALAMARI_SCRIPT_TIMEOUT_MINUTES env var, read at call time. Unset / non-numeric / non-positive preserves today's behaviour (wait until exit or caller cancellation), so long deployments are never killed by default. When set to a positive integer, an overrunning child is killed (whole process tree), the runner emits a clear stderr line naming the env var, and returns exit 124 — a hung script can no longer pin the work directory or the calling thread forever. IProcessRunner is unchanged.
  • K8s namespace genericity leak: the transport-agnostic ExecuteStepsPhase no longer reads the Kubernetes-specific Squid.Action.Kubernetes.Namespace variable. The two Kubernetes intent renderers now resolve + expand it themselves via a shared KubernetesTargetNamespaceResolver, using the render context's variable dictionary. IntentRenderContext swaps the pre-resolved TargetNamespace string for a generic VariableDictionary. Project-overrides-endpoint precedence and #{...} template expansion are preserved exactly.

Why non-breaking

  • IProcessRunner signature unchanged; default ExecuteAsync path is byte-identical when the env var is unset.
  • ScriptExecutionRequest.TargetNamespace and StartScriptCommand.TargetNamespace (the Halibut wire contract) are untouched — the agent still receives the same namespace.
  • No enum / wire / DB / migration changes. The only constructors of IntentRenderContext are the pipeline and unit tests, both updated.

Test plan

  • ProcessRunnerTests: env-var constant pinned (Rule 8), parse cases (unset/invalid/non-positive → no timeout; positive → minutes), kill-on-timeout returns 124 + stderr names the env var, finishes-within-timeout returns the real exit code.
  • KubernetesTargetNamespaceResolverTests: literal, #{...} template expansion, project-first precedence, absent → null, empty → empty.
  • KubernetesApi/KubernetesAgent renderer tests: new template-expansion cases; all existing namespace tests pass through the new variable path unchanged.
  • Full unit sweep: 5689 passed. Full Calamari suite: 545 passed. Full solution build: 0 errors.

Merge request reports

Loading