-
Notifications
You must be signed in to change notification settings - Fork 136
[redis] Add version management system with automated version updates #1681
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
Conversation
|
Warning Rate limit exceeded@kvaps has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 18 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (11)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @kvaps, 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 introduces a comprehensive version management system for Redis deployments, enabling automated discovery and application of the latest Redis major and patch versions. It provides users with the flexibility to select a desired major Redis version, while the system dynamically ensures the deployment uses the most current stable patch release. This enhancement significantly improves the maintainability and currency of Redis instances within the application. 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 an automated version management system for Redis, which is a great improvement for maintainability. The implementation includes a script to fetch the latest versions, updates to Helm templates to use these versions, and corresponding changes in configuration and documentation. My review focuses on the correctness and robustness of the new automation script. I've found a critical issue in how a data file is generated which would break deployments, along with a few other suggestions to improve the script's reliability and completeness. Overall, this is a valuable addition with a few adjustments needed.
| { | ||
| for major_ver in "${MAJOR_VERSIONS[@]}"; do | ||
| echo "\"${major_ver}\": \"${VERSION_MAP[$major_ver]}\"" | ||
| done | ||
| } > "$VERSIONS_FILE" |
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 generated versions.yaml file is not valid YAML. It's being created as a list of strings, but it should be a YAML map for the fromYaml function in the Helm template to parse it correctly. This will cause the Helm installation to fail.
| { | |
| for major_ver in "${MAJOR_VERSIONS[@]}"; do | |
| echo "\"${major_ver}\": \"${VERSION_MAP[$major_ver]}\"" | |
| done | |
| } > "$VERSIONS_FILE" | |
| { | |
| for major_ver in "${MAJOR_VERSIONS[@]}"; do | |
| echo "${major_ver}: \"${VERSION_MAP[$major_ver]}\" | |
| done | |
| } > "$VERSIONS_FILE" |
| # Update values.yaml - enum with major versions only | ||
| TEMP_FILE=$(mktemp) | ||
| trap "rm -f $TEMP_FILE" EXIT | ||
|
|
||
| # Build new version section | ||
| NEW_VERSION_SECTION="## @enum {string} Version" | ||
| for major_ver in "${MAJOR_VERSIONS[@]}"; do | ||
| NEW_VERSION_SECTION="${NEW_VERSION_SECTION} | ||
| ## @value $major_ver" | ||
| done | ||
| NEW_VERSION_SECTION="${NEW_VERSION_SECTION} | ||
|
|
||
| ## @param {Version} version - Redis major version to deploy | ||
| version: ${MAJOR_VERSIONS[0]}" | ||
|
|
||
| # Check if version section already exists | ||
| if grep -q "^## @enum {string} Version" "$VALUES_FILE"; then | ||
| # Version section exists, update it using awk | ||
| echo "Updating existing version section in $VALUES_FILE..." | ||
|
|
||
| # Use awk to replace the section from "## @enum {string} Version" to "version: " (inclusive) | ||
| # Delete the old section and insert the new one | ||
| awk -v new_section="$NEW_VERSION_SECTION" ' | ||
| /^## @enum {string} Version/ { | ||
| in_section = 1 | ||
| print new_section | ||
| next | ||
| } | ||
| in_section && /^version: / { | ||
| in_section = 0 | ||
| next | ||
| } | ||
| in_section { | ||
| next | ||
| } | ||
| { print } | ||
| ' "$VALUES_FILE" > "$TEMP_FILE.tmp" | ||
| mv "$TEMP_FILE.tmp" "$VALUES_FILE" | ||
| else | ||
| # Version section doesn't exist, insert it before Application-specific parameters section | ||
| echo "Inserting new version section in $VALUES_FILE..." | ||
|
|
||
| # Use awk to insert before "## @section Application-specific parameters" | ||
| awk -v new_section="$NEW_VERSION_SECTION" ' | ||
| /^## @section Application-specific parameters/ { | ||
| print new_section | ||
| print "" | ||
| } | ||
| { print } | ||
| ' "$VALUES_FILE" > "$TEMP_FILE.tmp" | ||
| mv "$TEMP_FILE.tmp" "$VALUES_FILE" | ||
| fi | ||
|
|
||
| echo "Successfully updated $VALUES_FILE with major versions: ${MAJOR_VERSIONS[*]}" | ||
|
|
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.
This script automates updating Redis versions in values.yaml and files/versions.yaml, which is great. However, it doesn't update values.schema.json. This means the schema's enum for the version field will become outdated when new major versions of Redis are found by this script. This would require manual intervention, defeating the purpose of full automation. A similar issue exists for packages/system/cozystack-resource-definitions/cozyrds/redis.yaml, which also contains a schema definition.
Please consider extending this script to also update values.schema.json. You could use jq to modify the enum array in the JSON file. The update-crd.sh script would then likely propagate this change to cozyrds/redis.yaml when make generate is run.
|
|
||
| # Update values.yaml - enum with major versions only | ||
| TEMP_FILE=$(mktemp) | ||
| trap "rm -f $TEMP_FILE" EXIT |
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 trap only cleans up $TEMP_FILE, but the script also creates and uses $TEMP_FILE.tmp which is not removed on exit. This will leave temporary files behind. The trap should be updated to clean up both files.
| trap "rm -f $TEMP_FILE" EXIT | |
| trap "rm -f '$TEMP_FILE' '$TEMP_FILE.tmp'" EXIT |
| {{- if not (hasKey $versionMap .Values.version) }} | ||
| {{- printf `Redis version %s is not supported, allowed versions are %s` $.Values.version (keys $versionMap) | fail }} | ||
| {{- end }} |
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.
This check is good, but it assumes $versionMap is a map. If files/versions.yaml is malformed (e.g., due to a bug in the generation script), fromYaml might not produce a map, and hasKey would fail with a less-than-helpful error. It's more robust to first check if you have a map. Also, the error message can be improved by sorting and joining the available versions for better readability.
{{- if not (kindIs "map" $versionMap) }}
{{- fail "files/versions.yaml did not parse as a valid YAML map." }}
{{- else if not (hasKey $versionMap .Values.version) }}
{{- printf `Redis version %s is not supported, allowed versions are %s` $.Values.version (keys $versionMap | sortAlpha | join ", ") | fail }}
{{- end }}
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
Signed-off-by: Andrei Kvapil kvapss@gmail.com
What this PR does
Release note