Skip to content

[Backport release-1.4] fix(platform): migrate ephemeralStorage to diskSize via pre-upgrade hook - #2712

Merged
myasnikovdaniil merged 2 commits into
release-1.4from
backport-2688-to-release-1.4
May 22, 2026
Merged

myasnikovdaniil merged 2 commits into
release-1.4from
backport-2688-to-release-1.4

Conversation

@myasnikovdaniil

Copy link
Copy Markdown
Contributor

Add pre-upgrade migration 41 that walks all kuberneteses.apps.cozystack.io Application CRs and renames nodeGroups[*].ephemeralStorage to diskSize, preserving the user's value.

Without this migration, clusters upgraded after PR #2454 either fail to reconcile (hard fail blocks all Flux operations) or silently lose the user's disk size setting (default 20Gi replaces whatever was configured).

The migration is idempotent and best-effort: a failed patch is logged and leaves the version stamp at 41 for retry on next upgrade.

Update the chart-side guard error message to direct operators to the migration job logs when the field appears post-upgrade (regression detector). Bump migrations.targetVersion 41 -> 42.

Assisted-By: Claude [email protected]

(cherry picked from commit ed1bb53)

What this PR does

Screenshots

Release note


Add pre-upgrade migration 41 that walks all kuberneteses.apps.cozystack.io
Application CRs and renames nodeGroups[*].ephemeralStorage to diskSize,
preserving the user's value.

Without this migration, clusters upgraded after PR #2454 either fail to
reconcile (hard fail blocks all Flux operations) or silently lose the user's
disk size setting (default 20Gi replaces whatever was configured).

The migration is idempotent and best-effort: a failed patch is logged and
leaves the version stamp at 41 for retry on next upgrade.

Update the chart-side guard error message to direct operators to the
migration job logs when the field appears post-upgrade (regression detector).
Bump migrations.targetVersion 41 -> 42.

Assisted-By: Claude <[email protected]>
Signed-off-by: Myasnikov Daniil <[email protected]>
(cherry picked from commit ed1bb53)
@coderabbitai

coderabbitai Bot commented May 21, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 424a4e51-cbb9-4851-87a8-263d5fa2ee13

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backport-2688-to-release-1.4

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added area/platform Issues or PRs related to platform infrastructure (bundle, flux, talos, installer) area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files labels May 21, 2026
@dosubot dosubot Bot added the kind/backport Categorizes issue or PR as requiring a backport to the current release line label May 21, 2026
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 implements a transparent migration path for users affected by the renaming of ephemeralStorage to diskSize. By adding a pre-upgrade hook, the platform now automatically handles the field migration, preventing potential reconciliation failures or silent data loss during upgrades. The changes also include updated documentation and improved error messaging to assist operators in troubleshooting if the migration process encounters issues.

Highlights

  • Automated Migration: Introduced a new pre-upgrade migration (migration 41) that automatically renames nodeGroups[*].ephemeralStorage to diskSize in all kuberneteses.apps.cozystack.io Application CRs.
  • Improved Error Handling: Updated the chart-side guard error message to provide clearer instructions for operators if the migration fails to run, directing them to the migration job logs.
  • Version Bump: Updated migrations.targetVersion from 40 to 42 to incorporate the new migration logic.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the 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 counterproductive. 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.

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

@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 introduces platform migration 41 to automatically rename the ephemeralStorage field to diskSize in Kubernetes application resources, updating the documentation and error messages accordingly. Feedback focuses on improving the migration script's robustness by distinguishing between transient API errors and missing resources, correcting a misleading log message regarding the version stamp, and replacing a hardcoded namespace with the $NAMESPACE environment variable.

Comment on lines +45 to +46
obj=$(kubectl get "$kind" --namespace "$ns" "$name" --output json 2>/dev/null || true)
if [ -z "$obj" ]; then SKIPPED=$((SKIPPED + 1)); return 0; fi

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

If kubectl get fails due to a transient error (e.g., API server timeout or temporary network issue), the object is silently skipped and the migration is considered successful for this resource. This can lead to some resources missing the migration while the global version stamp is still advanced to 42, preventing retries on subsequent upgrades. Consider distinguishing between a 'Not Found' error (which is safe to skip) and other errors which should be treated as failures.

fi

if [ "$FAILURES" -gt 0 ]; then
echo "WARN: $FAILURES patch(es) failed; leaving CURRENT_VERSION at 41 for retry on next upgrade."

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.

low

The log message mentions leaving the version at 41, but if the migration started from version 40 and failed, it will actually remain at 40 because the ConfigMap update is skipped. This message is slightly misleading as it implies an advancement that didn't happen.

Suggested change
echo "WARN: $FAILURES patch(es) failed; leaving CURRENT_VERSION at 41 for retry on next upgrade."
echo "WARN: $FAILURES patch(es) failed; leaving version stamp unchanged for retry on next upgrade."

exit 0
fi

kubectl create configmap --namespace cozy-system cozystack-version \

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.

low

The namespace cozy-system is hardcoded here. It is better to use the $NAMESPACE environment variable provided by the migration hook to ensure consistency if the platform is installed in a different namespace.

Suggested change
kubectl create configmap --namespace cozy-system cozystack-version \
kubectl create configmap --namespace "$NAMESPACE" cozystack-version \

The minio client was downloaded without -L, so when dl.min.io served
a 302 redirect, curl wrote the HTML body ("<a href=...>Found</a>") to
/usr/local/bin/mc, chmod +x'd it, and shipped that as the binary. When
the bucket E2E test ran "mc alias set ...", the shell tried to interpret
the HTML as a script and errored with:

    /usr/local/bin/mc: 1: cannot open a: No such file

(dash reading "<a" as an input redirect from a file named "a").

The image is rebuilt per CI run from cached layers; the broken mc layer
was cached and reused. Adding -fsSL fixes the download and the textual
change busts the cache so the next build pulls a real ELF binary.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
(cherry picked from commit 45937d6)
Signed-off-by: Myasnikov Daniil <[email protected]>
@myasnikovdaniil
myasnikovdaniil merged commit 84cda9c into release-1.4 May 22, 2026
9 checks passed
@myasnikovdaniil
myasnikovdaniil deleted the backport-2688-to-release-1.4 branch May 22, 2026 03:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/platform Issues or PRs related to platform infrastructure (bundle, flux, talos, installer) area/release Issues or PRs related to release tooling (changelog, backport, release pipeline) kind/backport Categorizes issue or PR as requiring a backport to the current release line kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants