-
Notifications
You must be signed in to change notification settings - Fork 106
Add configurable NNCP retry strategy via NMState CR #1407
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
Implements: OPNET-738 Signed-off-by: Emilia Desch <emy@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 @emy, 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 enhances the NMState operator by making the NNCP retry and backoff strategy configurable via the NMState Custom Resource. This provides operators with greater control over how network configuration policies are retried, which can be particularly useful for optimizing CI environments and handling transient network issues more efficiently. 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 a configurable retry strategy for NodeNetworkConfigurationPolicy reconciliation, which is a great enhancement for flexibility, especially in CI environments. The changes are well-structured, touching the API, CRD, controller, and tests. I've found a couple of issues in how the configuration is read and handled, which could lead to incorrect behavior. Specifically, there's a bug that prevents users from setting maxRetries to 0, and some redundant code in error handling. My review includes suggestions to fix these issues. Overall, a good and needed change.
| initialBackoff = defaultInitialBackoff | ||
| if retryConfig.InitialBackoff.Duration != 0 { | ||
| initialBackoff = retryConfig.InitialBackoff.Duration | ||
| } | ||
|
|
||
| maximumBackoff = defaultMaximumBackoff | ||
| if retryConfig.MaximumBackoff.Duration != 0 { | ||
| maximumBackoff = retryConfig.MaximumBackoff.Duration | ||
| } | ||
|
|
||
| maxRetries = defaultMaxRetries | ||
| if retryConfig.MaxRetries != 0 { | ||
| maxRetries = retryConfig.MaxRetries | ||
| } |
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.
The current logic for reading the retry configuration from the NMState CR is flawed. It checks if the values are non-zero before using them, which prevents a user from setting a valid value of 0 for maxRetries. If a user sets maxRetries: 0, this code will ignore it and use the default of 5.
The kubebuilder:default annotations on the API type ensure that if a user doesn't specify a value, it will be defaulted by the API server. The code should use the values from the CR directly. For old CRs that don't have this field, the values will be zero, which will be caught by the subsequent validation logic and correctly fall back to defaults.
initialBackoff = retryConfig.InitialBackoff.Duration
maximumBackoff = retryConfig.MaximumBackoff.Duration
maxRetries = retryConfig.MaxRetries| if err != nil { | ||
| setupLog.Error(err, "failed to retrieve retry configuration, using defaults") | ||
| // Use default values if we can't retrieve the configuration | ||
| initialBackoff = 1 * time.Second | ||
| maximumBackoff = 30 * time.Second | ||
| maxRetries = 5 | ||
| } |
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.
The getRetryConfiguration function already returns default values when an error occurs. The if err != nil block here re-assigns the same defaults, which is redundant. You can simplify this by just logging the error and proceeding with the values returned by the function.
if err != nil {
setupLog.Error(err, "failed to retrieve retry configuration, using defaults")
}Signed-off-by: Emilia Desch <emy@redhat.com>
Is this a BUG FIX or a FEATURE ?:
/kind enhancement
What this PR does / why we need it:
The recently added NNCP retry added some delay into the CI (due to the negative tests which will result in the NNCP retrying for minutes each time). So I added a configurable backoff strategy which keeps the same defaults but offers configuration.
Special notes for your reviewer:
Release note: