Skip to content

Init $script:ClientState to "" in install-k8s.ps1 (match bash early-exit semantics) #181

Description

@saadqbal

Context

Bugbot flagged on #179 (#179 (comment)): scripts/install-k8s.ps1:130 initialises $script:ClientState = "starting", whereas the bash equivalent in scripts/lib/summary.sh initialises CLIENT_STATE="" (empty).

The empty init on the bash side is deliberate: it lets an abnormal fall-through before the readiness gate be distinguished from a reported outcome, so the cleanup path can print the "check the log / safe to re-run" hint and exit non-zero.

Assessment (low / theoretical)

Grepped every ClientState consumer in install-k8s.ps1:

  • Wait-ForClientReady (sets it)
  • Print-Summary (reads it)
  • final exit check at line ~1559: if ($script:ClientState -ne "connected" -and $script:ClientState -ne "starting") { exit 1 }

No trap / cleanup handler reads ClientState, so the "starting" default never leaks into an early-exit path today. The risk is latent: if a future early-exit path is added, the "starting" default would mask an abnormal exit as a benign exit 0.

Fix

Change scripts/install-k8s.ps1:130 from:

$script:ClientState = "starting"

to:

$script:ClientState = ""

An abnormal fall-through then exits 1 (not a false 0), matching bash. Verify the exit check at ~1559 and Print-Summary still behave correctly with the empty initial value (they should — empty falls through to exit 1, which is the desired safe default).

Why deferred

Fast-follow after v1.4.3. The change belongs on develop; slipping it into the in-flight v1.4.3 release (sync PR #179) would diverge the sync branch from develop and add a commit to the FR promotion set for no live-failure-path benefit.

Acceptance criteria

  • $script:ClientState initialised to "" in install-k8s.ps1
  • Exit check + Print-Summary verified correct under empty initial state
  • Pester unit suite still green

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions