enhancments, status-crd: Rename CRD name#340
Conversation
The enhancement states the project should follows existing examples such as k8s-nmstate and frr-k8s [1]. These project CRD names are 'NodeNetworkState' [2] 'FRRNodeState' [3]. In addition the sriov-network-operator provide similar status API, its CRD name is 'SriovNetworkNodeState' [4]. The pattern here is '<component name>NodeState'. Change the suggested CRD name to RouterNodeState. The new name follows the mentioned statement and describe better what the CRD represent; not only a configuration status but a complete state. [1] github.com/openperouter/openperouter/blob/main/enhancements/status-crd.md#:~:text=This design follows established patterns from kubernetes-nmstate and frr-k8s [2] https://nmstate.io/kubernetes-nmstate/user-guide/101-reporting.html [3] https://github.com/metallb/frr-k8s#checking-the-status-of-each-frr-instance [4] https://github.com/k8snetworkplumbingwg/sriov-network-operator/blob/master/doc/api/node-state-api.md#sriovnetworknodestate-api-reference Signed-off-by: Or Mergi <ormergi@redhat.com>
Summary of ChangesHello, 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 updates the naming convention for the status Custom Resource Definition (CRD) to better align with industry standards and existing Kubernetes operators. By renaming the resource to 'RouterNodeState', the project adopts a more descriptive and consistent naming pattern that accurately reflects its role in representing the complete state of a node. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request renames the RouterNodeConfigurationStatus CRD to RouterNodeState throughout the enhancement documentation, updating API structures, YAML examples, and CLI commands. The review feedback focuses on improving the robustness of the provided jq examples to handle null or missing status fields, ensuring the commands work correctly for healthy nodes or before the first reconciliation.
|
|
||
| # Get status with conditions for monitoring | ||
| kubectl get routernodeconfigurationstatus -o json | jq '.items[] | {name: .metadata.name, ready: (.status.conditions[] | select(.type=="Ready") | .status)}' | ||
| kubectl get routernodestate -o json | jq '.items[] | {name: .metadata.name, ready: (.status.conditions[] | select(.type=="Ready") | .status)}' |
There was a problem hiding this comment.
The jq query will fail if .status.conditions is null (which is common before the first reconciliation) or if no "Ready" condition exists (it will omit the node entirely from the output). Using the optional chaining operator []? and first() with a default value makes the example more robust for users.
| kubectl get routernodestate -o json | jq '.items[] | {name: .metadata.name, ready: (.status.conditions[] | select(.type=="Ready") | .status)}' | |
| kubectl get routernodestate -o json | jq '.items[] | {name: .metadata.name, ready: (first(.status.conditions[]? | select(.type=="Ready") | .status) // "Unknown")}' |
There was a problem hiding this comment.
This out of this PR scope.
There was a problem hiding this comment.
why ? iiuc, it might happen
There was a problem hiding this comment.
This PR merely change the CRD name
|
|
||
| # Check failed configurations | ||
| kubectl get routernodeconfigurationstatus -o json | jq '.items[] | select(.status.failedResources | length > 0) | {node: .metadata.name, failed: [.status.failedResources[] | "\(.kind)/\(.name): \(.message)"]}' | ||
| kubectl get routernodestate -o json | jq '.items[] | select(.status.failedResources | length > 0) | {node: .metadata.name, failed: [.status.failedResources[] | "\(.kind)/\(.name): \(.message)"]}' |
There was a problem hiding this comment.
The jq query will error with null (null) has no length for any healthy node where failedResources is not present (due to omitempty). It is safer to use the alternative operator // [] to handle null values before checking the length, and []? to ensure safe iteration.
| kubectl get routernodestate -o json | jq '.items[] | select(.status.failedResources | length > 0) | {node: .metadata.name, failed: [.status.failedResources[] | "\(.kind)/\(.name): \(.message)"]}' | |
| kubectl get routernodestate -o json | jq '.items[] | select((.status.failedResources // []) | length > 0) | {node: .metadata.name, failed: [.status.failedResources[]? | "\(.kind)/\(.name): \(.message)"]}' |
There was a problem hiding this comment.
This out of this PR scope.
There was a problem hiding this comment.
why ? it might happen iiuc
There was a problem hiding this comment.
This PR merely change the CRD name
maiqueb
left a comment
There was a problem hiding this comment.
but honestly, to me, this doesn't improve the project. Hopefully you're right, and it'll be simpler for people onboarding the project.
|
@qinqon thoughts ? |
Not sure this is right, I think "Configuration" was fine, the NodeNetworkState is not realted to any configuration is just the networking present at node. Like without "Configuration" (no underlay, no l3vni or no l2vni) there is nothing to check but at knmstate we have NodeNetworkState even if we don't have a NNCP configured. |
|
Thanks for the feedback, nmstate perspective is nice The "ConfigurationStatus" notation is some what limiting for the configuration only, I think using the "State" notation is more future proof and is not limiting only for the configuration. For example, one could look into the status API to find the additional NICs and create Underlay objects accordingly, w/o exec into the node or check other APIs (such as NMstate's or SR-IOV). In addition the "ConfigurationStatus" naming produce some awkward component name, such as the struct that describe the CRD status "ConfigurationStatusStatus". |
If we want to expose extra status not related to configuration, imo it's gonna be better to use a different - per domain scoped - CRD. I don't think having a gigantic resource with the status of the current config, the status of the bgp sessions or other stuff is gonna be better for the user's eyes (plus, it's going to be hard to get a one liner summary of the state if the state involves many things altogether.
That's true, but it's also true that no one will write or consume it alone, but as config.Status. We can rename to State but I don't see a lot of value in it tbh |
Is this a BUG FIX or a FEATURE ?:
What this PR does / why we need it:
The enhancement states the project should follows existing examples such as k8s-nmstate and frr-k8s [1].
These project CRD names are 'NodeNetworkState' [2] 'FRRNodeState' [3]. In addition the sriov-network-operator provide similar status API, its CRD name is 'SriovNetworkNodeState' [4].
The pattern here is 'NodeState'.
Change the suggested CRD name to RouterNodeState.
The new name follows the mentioned statement and describe better what the CRD represent; not only a configuration status but a complete state.
[1] https://github.com/openperouter/openperouter/blob/main/enhancements/status-crd.md#:~:text=This%20design%20follows%20established%20patterns%20from%20kubernetes-nmstate%20and%20frr-k8s
[2] https://nmstate.io/kubernetes-nmstate/user-guide/101-reporting.html
[3] https://github.com/metallb/frr-k8s#checking-the-status-of-each-frr-instance
[4] https://github.com/k8snetworkplumbingwg/sriov-network-operator/blob/master/doc/api/node-state-api.md#sriovnetworknodestate-api-reference
Special notes for your reviewer:
Release note: