fix(api): drop the enum from a status field - #72
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScaledDownWorkloadRef.Kindcarried+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.targetsis 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:
status.activeScaledDown[1].kind: Unsupported value, and the whole write is rejected. That is precisely the behaviour being prevented.make cipasses.