fix: define resources in FeatureFlagSource#809
fix: define resources in FeatureFlagSource#809azdobylak wants to merge 1 commit intoopen-feature:mainfrom
Conversation
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 addresses a critical bug preventing the proper application of sidecar resource configurations specified in the Highlights
Changelog
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.
Code Review
This pull request fixes a bug where resource limits and requests from FeatureFlagSource were not being applied. The changes correctly merge these resource definitions and include corresponding tests. My review includes a suggestion to refactor the merge logic to reduce code duplication and improve maintainability.
| if len(new.Resources.Requests) != 0 { | ||
| if fc.Resources.Requests == nil { | ||
| fc.Resources.Requests = corev1.ResourceList{} | ||
| } | ||
| for k, v := range new.Resources.Requests { | ||
| fc.Resources.Requests[k] = v | ||
| } | ||
| } | ||
| if len(new.Resources.Limits) != 0 { | ||
| if fc.Resources.Limits == nil { | ||
| fc.Resources.Limits = corev1.ResourceList{} | ||
| } | ||
| for k, v := range new.Resources.Limits { | ||
| fc.Resources.Limits[k] = v | ||
| } | ||
| } |
There was a problem hiding this comment.
The logic for merging resource requests and limits is duplicated. To improve maintainability and reduce code duplication, consider extracting this logic into a helper function.
For example, you could define a helper:
func mergeResourceList(dst *corev1.ResourceList, src corev1.ResourceList) {
if len(src) == 0 {
return
}
if *dst == nil {
*dst = corev1.ResourceList{}
}
for k, v := range src {
(*dst)[k] = v
}
}And then simplify the Merge function by replacing the current implementation with:
mergeResourceList(&fc.Resources.Requests, new.Resources.Requests)
mergeResourceList(&fc.Resources.Limits, new.Resources.Limits)This would make the code cleaner and easier to maintain.
handle resources in Merge Signed-off-by: Adrian Zdobylak <adrian.zdobylak@tensquaregames.com>
14fb2ff to
b7c4fc2
Compare
This PR
Fixes a bug where sidecar resources (limits, requests) defined in the FeatureFlagSource CRD were ignored.
Related Issues
Fixes #780
Notes
Follow-up Tasks
How to test
Ovewrite default sidecar resources in
FeatureFlagSource(example in #780).