[virtual-machine] fix versions migration - #1378
Conversation
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
|
Caution Review failedThe pull request is closed. WalkthroughThe migration script at scripts/migrations/18 updates two kubectl patch commands to set appVersion values to 0.14.0 and 0.12.0. Other parts of the script, including the tenants patch and final configuration step, remain unchanged. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Summary of Changes
Hello Andrei Kvapil (@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 addresses a critical issue in a migration script by correcting erroneous application version numbers. The change ensures that virtual machine related applications are updated to their intended 0.x.x versions during the migration process, preventing potential compatibility or deployment problems.
Highlights
- Migration Script Correction: Corrected incorrect appVersion values within the scripts/migrations/18 script for virtualmachines.apps.cozystack.io and vminstances.apps.cozystack.io resources.
- Versioning Fix: Specifically, appVersion for virtualmachines.apps was changed from 1.14.0 to 0.14.0, and for vminstances.apps from 1.12.0 to 0.12.0.
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | Gemini (@gemini-code-assist) | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 (@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
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
This pull request fixes incorrect version numbers in the migration script scripts/migrations/18. The changes correctly align the appVersion for virtualmachines.apps.cozystack.io and vminstances.apps.cozystack.io with their respective Chart versions. While the version fix is correct, I've identified a significant issue with the script's robustness. The script does not handle errors within the resource patching loops. If any kubectl patch command fails, the script will continue its execution, potentially leaving the system in an inconsistent state while still marking the migration as successful. I've added comments with suggestions to improve error handling to make the migration process more reliable. The recommended approach is to use set -e at the beginning of the script.
| kubectl get virtualmachines.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read NAMESPACE NAME; do | ||
| kubectl patch virtualmachines.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"1.14.0"}' | ||
| kubectl patch virtualmachines.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.14.0"}' | ||
| done |
There was a problem hiding this comment.
This loop construction is not robust. If any kubectl patch command fails, the script will ignore the error and continue with the next resource. This can leave the system in an inconsistent state, especially since the script will mark the migration as complete at the end. For a critical migration script, it's important to fail fast.
The recommended solution is to add set -e at the top of the script (right after #!/bin/sh). This will ensure the script exits immediately on any command failure.
As a minimal improvement within this loop, you could add || exit 1 to stop processing further items, but be aware this will not stop the parent script from executing the next commands. Using read -r is also a good practice to prevent backslash interpretation.
| kubectl get virtualmachines.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read NAMESPACE NAME; do | |
| kubectl patch virtualmachines.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"1.14.0"}' | |
| kubectl patch virtualmachines.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.14.0"}' | |
| done | |
| kubectl get virtualmachines.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read -r NAMESPACE NAME; do | |
| kubectl patch virtualmachines.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.14.0"}' || exit 1 | |
| done |
| kubectl get vminstances.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read NAMESPACE NAME; do | ||
| kubectl patch vminstances.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"1.12.0"}' | ||
| kubectl patch vminstances.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.12.0"}' | ||
| done |
There was a problem hiding this comment.
Similar to the loop above, this one also lacks error handling for the kubectl patch command. A failure here would be silently ignored, and the script would continue, potentially leading to an inconsistent state after the migration is marked as complete.
Again, the best practice is to add set -e at the top of the script to ensure it fails on any error.
A minimal improvement is to stop the loop on failure, though this won't stop the main script from continuing.
| kubectl get vminstances.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read NAMESPACE NAME; do | |
| kubectl patch vminstances.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"1.12.0"}' | |
| kubectl patch vminstances.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.12.0"}' | |
| done | |
| kubectl get vminstances.apps.cozystack.io -A --no-headers --output=custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name' | while read -r NAMESPACE NAME; do | |
| kubectl patch vminstances.apps.cozystack.io -n "$NAMESPACE" "$NAME" --type merge -p '{"appVersion":"0.12.0"}' || exit 1 | |
| done |
Signed-off-by: Andrei Kvapil kvapss@gmail.com
What this PR does
Release note
Summary by CodeRabbit
Bug Fixes
Chores