Skip to content

[virtual-machine] fix versions migration - #1378

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vm-mig-fix
Sep 2, 2025
Merged

[virtual-machine] fix versions migration#1378
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
vm-mig-fix

Conversation

@kvaps

@kvaps Andrei Kvapil (kvaps) commented Sep 2, 2025

Copy link
Copy Markdown
Member

Signed-off-by: Andrei Kvapil kvapss@gmail.com

What this PR does

Release note

[]

Summary by CodeRabbit

  • Bug Fixes

    • Corrected app version references for Virtual Machines to 0.14.0 and VM Instances to 0.12.0, ensuring accurate versioning during migrations.
  • Chores

    • Updated migration process to apply the corrected version patches consistently without altering other steps.

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@coderabbitai

coderabbitai Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

The 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

Cohort / File(s) Summary
Migration script updates
scripts/migrations/18
Updated kubectl patches: virtualmachines.apps.cozystack.io appVersion 1.14.0 → 0.14.0; vminstances.apps.cozystack.io appVersion 1.12.0 → 0.12.0. All other lines unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

backport

Suggested reviewers

  • lllamnyp
  • klinch0

Poem

A hop and a bump, versions roll back in time,
Patch-carrots nibbled to a gentler rhyme.
1s to 0s, a tidy burrow’s lore—
Scripts stay snug, while clusters soar.
Thump-thump! Migrations set—let’s explore. 🥕🐇


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 389ec27 and 8fbebd4.

📒 Files selected for processing (1)
  • scripts/migrations/18 (1 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch vm-mig-fix

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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.

@kvaps
Andrei Kvapil (kvaps) merged commit fdd4f16 into main Sep 2, 2025
5 of 6 checks passed
@kvaps
Andrei Kvapil (kvaps) deleted the vm-mig-fix branch September 2, 2025 11:31

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment thread scripts/migrations/18
Comment on lines 10 to 12
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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

Comment thread scripts/migrations/18
Comment on lines 13 to 15
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant