Repository navigation
fix(project-controller): honour the manual-override label on external namespaces - #201
Conversation
… namespaces The external namespace handler re-applied the project label and the enforce-scheduler annotation to a namespace referenced through spec.namespace even when the namespace carried the manual-override label, so an administrator's override was undone on every Project reconciliation. The handler now returns early for an overridden namespace, the way handleExistingNamespace already does for the namespaces this controller creates. A namespace that belongs to another Project is still rejected first. Fixes kai-scheduler#197 Signed-off-by: Youssef Omar Bouden <[email protected]>
noiyemini
left a comment
There was a problem hiding this comment.
Thanks, the fix looks good. Two test cases to add, please:
- Removing the override resumes syncing, which the issue asks for. Set the override, reconcile, remove the label, reconcile again, and expect the project label and annotation to be written.
- A project label that's present but empty gets the project's name, since that behavior changed in this PR.
| // Labels the namespace to mark it as kai namespace | ||
| projectNameLabel, found := existingNamespace.Labels[config.Get().NamespaceProjectLabelKey] | ||
| if !found { | ||
| if projectNameLabel == "" { |
There was a problem hiding this comment.
Treating an empty label as missing is a good catch. It matches what the controller already does for the namespaces it creates. Could you mention it in the PR description?
There was a problem hiding this comment.
Done, the description now has a paragraph on the empty label being treated as missing.
|
Total coverage: 81.4% -> 81.4% (delta 0.00%) Merging this branch will increase overall coverage
Coverage detailsCompared to commit aef0fec (run #42475855666)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files:
|
… label on external namespaces Signed-off-by: Youssef Omar Bouden <[email protected]>
|
Thanks @noiyemini. Both cases are in |
|
Thanks @noiyemini! |
|
Thanks @SiorMeir and @noiyemini! |
Description
labelExternalNamespaceForProjectre-applied the project label and the enforce-scheduler annotation to a namespace referenced throughspec.namespaceeven when that namespace carried the manual-override label, so an administrator's override was undone on every Project reconciliation (and scheduler enforcement re-enabled whenspec.enforceKaiScheduleris true). The handler now returns early for an overridden namespace, the wayhandleExistingNamespacealready does for the namespaces the controller creates. The check that rejects a namespace labelled for another Project runs first, so an overridden namespace cannot be claimed by a second Project either.One behaviour change on the way: a project label that is present but empty is now treated as missing and set to the project's name, as the handler already does for the namespaces the controller creates; before, an empty label was left empty.
Five new cases in
namespace_resource_handler_test.go: an overridden namespace stays without the project label and the annotation, an overridden namespace keepsenforce-scheduler: "false"under a Project withenforceKaiScheduler: true, an overridden namespace labelled for another Project is still rejected, removing the override resumes syncing (label and annotation written on the next reconcile), and an empty project label gets the project's name. The override cases fail on main and pass here;go test ./pkg/project-controller/...andmake validatepass (Go 1.26.8, macOS arm64, fake client only, not run on a cluster).Related issues
Fixes #197
Checklist
make validateBreaking changes
None. A namespace without the override label is handled exactly as before.
Additional notes
The issue asks for a backport to v0.18; happy to open it against
v0.18once this is merged.