-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
feat(runtime(v2)): add sanity checks on store upgrades #21748
Conversation
WalkthroughWalkthroughThe changes introduce a new function, Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Recent review detailsConfiguration used: .coderabbit.yml Files selected for processing (4)
Files skipped from review as they are similar to previous changes (2)
Additional context usedPath-based instructions (2)
Additional comments not posted (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
@julienrbrt your pull request is missing a changelog! |
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.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
runtime/v2/store.go (1)
98-131
: Great addition of sanity checks!The
checkStoreUpgrade
function performs important sanity checks on thestoreUpgrades
parameter. The checks for nilstoreUpgrades
, duplicate keys, and keys present in bothAdded
andDeleted
lists are crucial to ensure the validity of the store upgrades.Consider refactoring the duplicate key checks for
Added
andDeleted
lists into a separate function to reduce code duplication. For example:func checkDuplicateKeys(keys []string, listName string, storeUpgrades *store.StoreUpgrades) error { var exists = make(map[string]bool) for _, key := range keys { if exists[key] { return fmt.Errorf("store upgrade has duplicate key %s in %s", key, listName) } if listName == "added" && storeUpgrades.IsDeleted(key) { return fmt.Errorf("store upgrade has key %s in both added and deleted", key) } if listName == "deleted" && storeUpgrades.IsAdded(key) { return fmt.Errorf("store upgrade has key %s in both added and deleted", key) } exists[key] = true } return nil }Then, you can call this function for both
Added
andDeleted
lists:if err := checkDuplicateKeys(storeUpgrades.Added, "added", storeUpgrades); err != nil { return err } if err := checkDuplicateKeys(storeUpgrades.Deleted, "deleted", storeUpgrades); err != nil { return err }
Review details
Configuration used: .coderabbit.yml
Review profile: CHILL
Files selected for processing (2)
- runtime/store.go (3 hunks)
- runtime/v2/store.go (3 hunks)
Additional context used
Path-based instructions (2)
runtime/v2/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.runtime/store.go (1)
Pattern
**/*.go
: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.
Additional comments not posted (3)
runtime/v2/store.go (1)
73-76
: LGTM!The addition of the
checkStoreUpgrade
function call and the panic on error is a good way to enforce the sanity checks and prevent further execution if the checks fail.runtime/store.go (2)
189-192
: LGTM!The addition of the
checkStoreUpgrade
call and the panic on error enhances the robustness of the upgrade process by enforcing the sanity checks before proceeding. This is a good practice to prevent upgrades with invalid configurations.
211-244
: Great work on thecheckStoreUpgrade
function!The function performs important sanity checks on the
storeUpgrades
parameter:
- Checking for nil
storeUpgrades
is a good defensive programming practice.- Checking for duplicate keys in
Added
andDeleted
lists prevents invalid configurations.- Checking for keys present in both
Added
andDeleted
lists is crucial to prevent conflicts.The error messages are clear and informative, making it easy to identify the cause of the failure.
Overall, this function enhances the reliability of the store upgrade process by catching potential issues early.
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.
overall, looks good to me! Could you please add some unit-tests for that feature?
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.
LGTM
let fix the lint |
@Mergifyio backport release/v0.52.x |
✅ Backports have been created
|
(cherry picked from commit c9f0e2e) # Conflicts: # runtime/v2/store.go
…) (#21778) Co-authored-by: Julien Robert <julien@rbrt.fr>
Description
Closes: #20725
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
in the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.
I have...
Summary by CodeRabbit