Skip to content

Keep the stored lastPhaseTransitionTime when the operator reads a status - #99

Merged
ThoSap merged 1 commit into
mainfrom
fix-phase-transition-time-on-status-read
Oct 25, 2026
Merged

ThoSap merged 1 commit into
mainfrom
fix-phase-transition-time-on-status-read

Conversation

@ThoSap

@ThoSap ThoSap commented Oct 25, 2026

Copy link
Copy Markdown
Member

Fixes #97

CRStatus.setPhase was a setter with logic: when the phase changed, it set lastPhaseTransitionTime to now. Jackson also called it while it read a status from the cluster. The API server sends lastPhaseTransitionTime before phase, and a new CRStatus starts as PENDING. So each read of a resource that was not PENDING overwrote the stored time with now, and the next patchStatus wrote it back. On a test cluster, a ClusterConnection and 16 Grant resources that were READY since September all showed the time of the last operator restart.

What changed

  1. setPhase is now updatePhase. Jackson does not use it as a setter, so it sets the phase field directly and keeps the stored time. The logic is the same. A Javadoc gives the reason. This is the same fix as in the Garage Operator (aboutbits/garage-operator@63da164).
  2. All callers use updatePhase. 24 calls in the reconcilers and BaseReconciler, and 15 in the tests.
  3. The Javadoc no longer says that a phase change sets the message to null. The code never did that.
  4. New CRStatusTest. It reads a status JSON with lastPhaseTransitionTime before phase and expects the stored time. Other tests check that the same phase keeps a stored time, that a new phase replaces it, and that updatePhase can be chained with the other setters.

Consequences

  • The generated CRDs do not change.
  • After the upgrade, lastPhaseTransitionTime keeps its value until the phase really changes. Resources that the old version read show the time of that read, not of their last real phase change.

Checks that CI cannot do

  • Without the fix, the deserialization test fails: the stored time 2026-01-01T00:00:00Z becomes the current time.
  • The six generated CRDs are identical to the CRDs of the unfixed code.

…ransition time

Jackson called setPhase while it read a status from the cluster. The API
server sends lastPhaseTransitionTime before phase, so the stored time was
overwritten with now on each read.

Assisted-by: Claude:claude-opus-5-5
@ThoSap ThoSap self-assigned this Oct 25, 2026
@ThoSap ThoSap added the bug Something isn't working label Oct 25, 2026
@ThoSap
ThoSap merged commit 41f08b6 into main Oct 25, 2026
4 checks passed
@ThoSap
ThoSap deleted the fix-phase-transition-time-on-status-read branch October 25, 2026 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lastPhaseTransitionTime is reset each time the operator reads a status

1 participant