Skip to content

feat: standard metav1.Condition projection on job status - #16

Merged
kylegalloway merged 3 commits into
mainfrom
worktree-feat+standard-conditions
May 29, 2026
Merged

feat: standard metav1.Condition projection on job status#16
kylegalloway merged 3 commits into
mainfrom
worktree-feat+standard-conditions

Conversation

@kylegalloway

@kylegalloway kylegalloway commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds []metav1.Condition to ZarfPackageJobStatus and UDSBundleJobStatus as an additive projection layer on top of the existing phase state machine
  • Phases are kept intact — they drive action chaining (BuildPublish → trigger publish after build) and reconcile gating (skip terminal resources). Conditions project phase outward for ecosystem tooling.
  • Fixes a pre-existing bug where updateStatus replaced the entire status map on every write, silently dropping prior operation fields (e.g. buildStatus disappearing when publishStatus was written during a BuildPublish chain)

Conditions added

Condition True False Unknown
Ready job completed successfully job failed terminally in progress
Reconciling actively working terminal
BuildSucceeded build completed build failed build running
CreateSucceeded UDS create completed create failed create running
PublishSucceeded publish completed publish failed publish running
DeploySucceeded deploy completed deploy failed deploy running

LastTransitionTime is preserved when a condition's status hasn't changed.

Usage

kubectl wait --for=condition=Ready=True zpj/my-job --timeout=30m
kubectl wait --for=condition=BuildSucceeded=True zpj/my-job --timeout=20m

Test plan

  • TestDeriveConditions_Ready — all 6 phases map correctly to Ready/Reconciling status
  • TestDeriveConditions_OperationConditions — per-operation conditions derived from status fields; absent operations produce no condition
  • TestDeriveConditions_PreservesLastTransitionTime — unchanged status keeps original timestamp
  • TestDeriveConditions_TransitionsLastTransitionTime — changed status gets new timestamp
  • TestConditionsRoundtrip[]metav1.Condition survives unstructured serialization round-trip
  • TestDeriveConditions_ReconcilingReason — terminal phases carry Succeeded/Failed reason, not Progressing
  • TestDeriveConditions_DeterministicOrder — condition slice order is stable across calls
  • Full go test ./... — all existing tests pass

@kylegalloway
kylegalloway force-pushed the worktree-feat+standard-conditions branch 2 times, most recently from 8d54b04 to 309d8e1 Compare May 29, 2026 21:18
Adds []metav1.Condition to ZarfPackageJobStatus and UDSBundleJobStatus.
Conditions are derived from the existing phase state machine on every
updateStatus call — phases are kept intact as the internal state machine
for action chaining and reconcile gating.

Ready: True=succeeded / False=failed / Unknown=in-progress
Reconciling: True while not in a terminal phase
BuildSucceeded / CreateSucceeded / PublishSucceeded / DeploySucceeded:
per-operation outcomes derived from OperationStatus.Phase

LastTransitionTime is preserved when a condition's status is unchanged.

Also fixes updateStatus to merge into existing status rather than
replace it entirely, preventing prior operation fields (e.g. buildStatus)
from being silently lost when a chained action (e.g. publishStatus) is
written.

Enables: kubectl wait --for=condition=Ready=True zpj/my-job
Reconciling=False with Reason=Progressing was semantically incoherent —
like a 'CLOSED' sign that still says 'Be Right Back'. Terminal phases now
carry the correct reason (Succeeded/Failed) so kubectl get output doesn't
lie to operators.

OperationConditionTypes was a map, which in Go means the per-operation
conditions appeared in random order on every reconcile. Converted to an
ordered slice so the status output is stable across calls.

Also stubs ConditionReasonSuspended as an explicit forward declaration,
adds klog.ErrorS for the silent drop in conditionsToUnstructured,
and covers both fixes with TestDeriveConditions_ReconcilingReason and
TestDeriveConditions_DeterministicOrder.
@kylegalloway
kylegalloway force-pushed the worktree-feat+standard-conditions branch from 309d8e1 to 3b33c57 Compare May 29, 2026 21:28
@kylegalloway
kylegalloway enabled auto-merge May 29, 2026 21:33
@kylegalloway
kylegalloway merged commit 4057695 into main May 29, 2026
13 checks passed
@kylegalloway
kylegalloway deleted the worktree-feat+standard-conditions branch May 29, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant