Skip to content

fix(api): drop the enum from a status field - #72

Merged
slauger merged 1 commit into
developfrom
fix/status-enum
Sep 6, 2026
Merged

slauger merged 1 commit into
developfrom
fix/status-enum

Conversation

@slauger

@slauger slauger commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

ScaledDownWorkloadRef.Kind carried +kubebuilder:validation:Enum=Deployment;StatefulSet;CronJob, and that field is part of status.

The API server validates status subresource writes. A kind outside the list would therefore have rejected the entire status update, not just that one entry: conditions, phase, the counter and the workload list would all have stopped being written, and the symptom would have looked like an unrelated status bug rather than a validation failure.

Nothing writes an unexpected kind today, so this was latent. It would have become live the moment any work touched the set of supported workload kinds, which is exactly when nobody would be looking for a validation problem.

The same constraint on spec.targets is correct and stays. Validate what users write, describe what the controller reports.

Closes #66

Test plan

Both directions checked against a real API server via envtest:

  • The status now accepts an unlisted kind, and the rest of the update lands with it — the test asserts the phase and both list entries persist, since a partial write would be its own bug.
  • The spec still rejects an unknown target, so the useful validation is intact.
  • Verified the guard works by temporarily reinstating the marker: the new test then fails with status.activeScaledDown[1].kind: Unsupported value, and the whole write is rejected. That is precisely the behaviour being prevented.
  • make ci passes.

ScaledDownWorkloadRef.Kind carried an enum constraint, and the API
server validates status subresource writes. A kind outside the list
would therefore reject the entire status update, not just that entry:
conditions, phase and counters would all stop being written, and the
symptom would look nothing like the cause.

The same constraint on spec.targets is correct and stays. Validate what
users write, describe what the controller reports.

Verified both directions against a real API server: the status now takes
an unlisted kind with the rest of the update intact, and the spec still
rejects one. Reinstating the marker makes the new test fail with the
whole write rejected, which is the behaviour being guarded against.

Closes #66

Signed-off-by: Simon Lauger <simon@lauger.de>
@slauger
slauger merged commit 4d7e9ec into develop Sep 6, 2026
14 checks passed
@slauger
slauger deleted the fix/status-enum branch September 6, 2026 08:59
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.

fix(api): enum on a status field can block all status writes

1 participant