-
Notifications
You must be signed in to change notification settings - Fork 106
metrics: introduce metrics based on the NNS #1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR introduces a small set of metrics based on the NodeNetworkState, i.e. `kubernetes_nmstate_network_interfaces` and `kubernetes_nmstate_routes`. Those track number of network interfaces and number of routes for every node in the cluster where nmstate handler pods are running. This creates a skeleton for k-nmstate to create metrics based on the effective state of the network on the system and not only based on the content of NNCP. In the future it may be used to create statistics about network topologies of clusters. Signed-off-by: Mat Kowalski <mko@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello @mkowalski, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the observability of network configurations within the cluster by introducing new Prometheus metrics derived directly from the NodeNetworkState. These metrics provide a granular view of network interfaces by type and routes by IP stack and configuration type (static/dynamic) on each node. This foundational work lays the groundwork for future capabilities, such as analyzing network topologies and gaining deeper insights into the operational state of the network. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces new Prometheus metrics to track network interface counts by type and network route counts by node, IP stack, and type (static/dynamic). A new NodeNetworkStateReconciler controller was added to manage these metrics, watching NodeNetworkState objects and updating kubernetes_nmstate_network_interfaces and kubernetes_nmstate_routes gauges based on the node's current network state. The controller uses in-memory maps to track previous interface types and route keys, enabling the cleanup of stale metrics when network configurations change or are deleted. Helper functions for counting interfaces and routes were added to pkg/state/filter.go, necessitating updates to pkg/state/type.go for proper data unmarshaling. Extensive unit and E2E tests were included to validate the new metrics. A review comment highlighted that the in-memory state for tracking old metrics could lead to temporary inaccuracies after controller restarts, a common consideration for Prometheus controllers.
|
/test pull-kubernetes-nmstate-e2e-handler-k8s |


This PR introduces a small set of metrics based on the NodeNetworkState, i.e.
kubernetes_nmstate_network_interfacesandkubernetes_nmstate_routes. Those track number of network interfaces and number of routes for every node in the cluster where nmstate handler pods are running.This creates a skeleton for k-nmstate to create metrics based on the effective state of the network on the system and not only based on the content of NNCP.
In the future it may be used to create statistics about network topologies of clusters.
Is this a BUG FIX or a FEATURE ?:
What this PR does / why we need it:
Special notes for your reviewer:
Release note: