fix(metrics): resolve workqueue metrics initialization conflict#1044
Merged
prometherion merged 1 commit intoclastix:masterfrom Jan 4, 2026
Merged
Conversation
✅ Deploy Preview for kamaji-documentation canceled.
|
Member
prometherion
left a comment
There was a problem hiding this comment.
Nice finding! ![]()
I'm a bit reluctant to write/copy the DeepCopy functions: wouldn't it be way safer to delegate it to controller-gen as we're already doing with Kamaji's core APIs?
Fixes clastix#1026 Previously, Kamaji directly imported k8s.io/apiserver types, which created a package initialization conflict. The k8s.io/component-base package (transitively imported via apiserver) would call workqueue.SetProvider() during initialization before controller-runtime could register its own workqueue metrics provider. This resulted in controller-runtime workqueue metrics never appearing on the metrics endpoint. This fix removes the direct dependency on k8s.io/apiserver by creating local type definitions for EgressSelectorConfiguration and related types. The local types maintain full API compatibility with the original apiserver types while eliminating the initialization conflict. Changes: - Add internal/resources/konnectivity/egress_types.go with local type definitions including DeepCopy methods for runtime.Object interface - Update egress_selector_configuration_resource.go to use local types instead of k8s.io/apiserver imports - Add comprehensive test (workqueue_metrics_test.go) verifying that all 7 workqueue metrics are properly registered - Run go mod tidy to mark k8s.io/apiserver as indirect dependency The fix has been verified with automated tests showing all expected workqueue metrics (depth, adds_total, queue_duration_seconds, work_duration_seconds, retries_total, unfinished_work_seconds, longest_running_processor_seconds) are now properly registered. Signed-off-by: Azeez Syed <syedazeez337@gmail.com>
336bff2 to
d81fc77
Compare
Contributor
Author
|
Hi @prometherion |
prometherion
approved these changes
Jan 4, 2026
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.
Fixes #1026
Previously, Kamaji directly imported k8s.io/apiserver types, which created a package initialization conflict. The k8s.io/component-base package (transitively imported via apiserver) would call workqueue.SetProvider() during initialization before controller-runtime could register its own workqueue metrics provider. This resulted in controller-runtime workqueue metrics never appearing on the metrics endpoint.
This fix removes the direct dependency on k8s.io/apiserver by creating local type definitions for EgressSelectorConfiguration and related types. The local types maintain full API compatibility with the original apiserver types while eliminating the initialization conflict.
Changes:
The fix has been verified with automated tests showing all expected workqueue metrics (depth, adds_total, queue_duration_seconds, work_duration_seconds, retries_total, unfinished_work_seconds, longest_running_processor_seconds) are now properly registered.