Skip to content

fix(metrics): resolve workqueue metrics initialization conflict#1044

Merged
prometherion merged 1 commit intoclastix:masterfrom
syedazeez337:fix/issue-1026-workqueue-metrics
Jan 4, 2026
Merged

fix(metrics): resolve workqueue metrics initialization conflict#1044
prometherion merged 1 commit intoclastix:masterfrom
syedazeez337:fix/issue-1026-workqueue-metrics

Conversation

@syedazeez337
Copy link
Contributor

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:

  • 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.

@netlify
Copy link

netlify bot commented Dec 29, 2025

Deploy Preview for kamaji-documentation canceled.

Name Link
🔨 Latest commit d81fc77
🔍 Latest deploy log https://app.netlify.com/projects/kamaji-documentation/deploys/6953635d33aa62000892841c

Copy link
Member

@prometherion prometherion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice finding! :shipit:

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>
@syedazeez337 syedazeez337 force-pushed the fix/issue-1026-workqueue-metrics branch from 336bff2 to d81fc77 Compare December 30, 2025 05:30
@syedazeez337
Copy link
Contributor Author

Hi @prometherion
I have update the code with your suggestions. Thank you for pointing out.

@prometherion prometherion merged commit 0428024 into clastix:master Jan 4, 2026
12 checks passed
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.

Missing workqueue metrics

2 participants