-
Notifications
You must be signed in to change notification settings - Fork 136
[kubernetes] Add version management system with automated version updates #1672
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
WalkthroughThis PR introduces a new bash script that dynamically orchestrates Kubernetes version mappings and schema updates by extracting Kamaji version references and retrieving corresponding kube-apiserver tags. It replaces the previous inline yq-based approach with a dedicated build-time tool, updates version references and documentation, and relaxes OpenAPI schema validation constraints. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ 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 implements a comprehensive version management system for both Kubernetes and PostgreSQL applications. The core purpose is to automate the process of identifying, tracking, and updating supported application versions, thereby reducing manual maintenance overhead and ensuring that deployments consistently use the latest stable patch releases. This system integrates external sources like 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
|
d491c43 to
c9bf7ca
Compare
c9bf7ca to
2cc4c9f
Compare
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 both Kubernetes and PostgreSQL, which is a great enhancement for maintainability. The changes include new update-versions.sh scripts that fetch the latest supported versions and update the corresponding Helm chart values, schemas, and version mappings.
My review focuses on the robustness and maintainability of these new scripts. I've identified a few areas where the scripts rely on brittle scraping of web content, which could lead to failures if the source format changes. I've also suggested a simplification for a complex piece of logic in the Kubernetes version update script to improve its readability.
Overall, this is a valuable addition. Addressing the feedback will help make the new automation more resilient.
2cc4c9f to
c3a1db5
Compare
…ates Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
c3a1db5 to
06a25c1
Compare
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: 1
🧹 Nitpick comments (4)
packages/apps/kubernetes/hack/update-versions.sh (4)
26-50: Version extraction logic is solid.File existence checks and validation of extracted values are appropriate. However, the curl command on line 43 lacks retry logic for transient network failures. Consider adding a retry loop or using curl's built-in
--retryflag.KUBERNETES_VERSION_FROM_KAMAJI=$(curl -sSL --retry 3 --retry-delay 1 "https://raw.githubusercontent.com/clastix/kamaji/${KAMAJI_VERSION}/internal/upgrade/kubeadm_version.go" | grep "KubeadmVersion" | sed -E 's/.*KubeadmVersion = "([^"]+)".*/\1/')
52-86: Version filtering is well-implemented but could use edge-case clarity.The version sorting and filtering logic is correct. However, the comparison approach (lines 74, 114) is verbose. The construct:
if [ "$(printf '%s\n%s\n' "$tag" "$KUBERNETES_VERSION_FROM_KAMAJI" | sort -V | head -1)" = "$tag" ] || [ "$tag" = "$KUBERNETES_VERSION_FROM_KAMAJI" ]; thencan be simplified. Additionally, the skopeo call (line 61) has no retry mechanism for transient registry failures.
171-172: Use mapfile for more robust array assignment.The current approach with command substitution can have word-splitting issues. Shellcheck (SC2207) flags this pattern. Use
mapfileorread -afor cleaner, safer array population.-IFS=$'\n' VERSIONS=($(printf '%s\n' "${VERSIONS[@]}" | sort -V -r)) -unset IFS +mapfile -t VERSIONS < <(printf '%s\n' "${VERSIONS[@]}" | sort -V -r)
202-237: Fragile awk state machine for values.yaml updates.The awk-based section replacement (lines 208–223) relies on implicit state tracking and assumes the old section follows a specific pattern. This is brittle:
- If spacing or comments between
## @enum {string} Versionandversion:change, the logic fails.- The state machine deletes everything after the enum line until it sees
version:, which could inadvertently remove content.Consider a more explicit approach:
- Extract the section to be replaced using awk with explicit bounds.
- Validate the section exists and has the expected structure.
- Replace it with the new section.
This is a recommended refactor if maintainability is a concern, but the current approach works if the file format is strictly controlled.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.github/workflows/pre-commit.yml(1 hunks)packages/apps/kubernetes/.helmignore(1 hunks)packages/apps/kubernetes/Makefile(1 hunks)packages/apps/kubernetes/README.md(1 hunks)packages/apps/kubernetes/files/versions.yaml(1 hunks)packages/apps/kubernetes/hack/update-versions.sh(1 hunks)packages/apps/kubernetes/values.schema.json(2 hunks)packages/apps/kubernetes/values.yaml(1 hunks)packages/system/cozystack-resource-definitions/cozyrds/kubernetes.yaml(1 hunks)
🧰 Additional context used
🧠 Learnings (4)
📚 Learning: 2025-07-14T16:23:12.803Z
Learnt from: NickVolynkin
Repo: cozystack/cozystack PR: 1196
File: packages/apps/http-cache/Makefile:24-27
Timestamp: 2025-07-14T16:23:12.803Z
Learning: In the cozystack repository, the `readme-generator` tool removes enum contents from values.schema.json files during its operation. Therefore, when using readme-generator in Makefiles, any enum values need to be injected back into the schema using yq commands after readme-generator has run, not before.
Applied to files:
packages/apps/kubernetes/Makefile
📚 Learning: 2025-11-28T21:26:10.771Z
Learnt from: kvaps
Repo: cozystack/cozystack PR: 1671
File: packages/apps/postgres/files/versions.yaml:1-6
Timestamp: 2025-11-28T21:26:10.771Z
Learning: In packages/apps/postgres/files/versions.yaml, the version mappings are sourced from the CloudNativePG container registry (ghcr.io/cloudnative-pg/postgresql), not from PostgreSQL project releases. The versions should reflect what's actually published in the CloudNativePG registry, which is automatically fetched by the hack/update-versions.sh script.
Applied to files:
packages/apps/kubernetes/hack/update-versions.shpackages/apps/kubernetes/files/versions.yaml
📚 Learning: 2025-07-11T06:11:25.438Z
Learnt from: lllamnyp
Repo: cozystack/cozystack PR: 1130
File: hack/e2e-apps/kubernetes.bats:101-101
Timestamp: 2025-07-11T06:11:25.438Z
Learning: In cozystack, the plural form for the Kubernetes custom resource is `kuberneteses.apps.cozystack.io`, not `kubernetes.apps.cozystack.io`. This is defined in the API schema even though it's not grammatically perfect.
Applied to files:
packages/system/cozystack-resource-definitions/cozyrds/kubernetes.yaml
📚 Learning: 2025-11-27T11:21:45.808Z
Learnt from: CR
Repo: cozystack/cozystack PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T11:21:45.808Z
Learning: Applies to **/Chart.yaml : Use Helm Charts with the umbrella pattern and vendor upstream charts in `charts/` directory
Applied to files:
packages/system/cozystack-resource-definitions/cozyrds/kubernetes.yaml
🧬 Code graph analysis (3)
packages/apps/kubernetes/hack/update-versions.sh (2)
hack/e2e-apps/run-kubernetes.sh (1)
run_kubernetes_test(1-137)scripts/installer.sh (1)
run_migrations(8-20)
packages/apps/kubernetes/values.yaml (1)
pkg/cmd/server/start.go (1)
AppsVersionToKubeVersion(290-302)
packages/system/cozystack-resource-definitions/cozyrds/kubernetes.yaml (1)
pkg/cmd/server/openapi.go (1)
sanitizeForV2(286-331)
🪛 Shellcheck (0.11.0)
packages/apps/kubernetes/hack/update-versions.sh
[warning] 129-129: TOTAL_LINES appears unused. Verify use (or export if used externally).
(SC2034)
[warning] 171-171: Prefer mapfile or read -a to split command output (or quote to avoid splitting).
(SC2207)
[warning] 188-188: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
[warning] 188-188: Use single quotes, otherwise this expands now rather than when signalled.
(SC2064)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build
🔇 Additional comments (13)
packages/apps/kubernetes/.helmignore (1)
4-4: LGTM! Appropriately excludes build tooling from Helm chart packaging.packages/apps/kubernetes/README.md (1)
107-107: LGTM! Updated description appropriately reflects the enum-based version parameter approach.packages/apps/kubernetes/files/versions.yaml (1)
2-6: Verify Kubernetes patch version availability in registry. The updated patch versions (v1.32.10, v1.31.14, v1.30.14, v1.29.15, v1.28.15) should be confirmed as available in the container registry used by the project. Per learnings from similar version management in other apps, these versions are auto-fetched byhack/update-versions.sh.packages/apps/kubernetes/values.schema.json (1)
495-495: LGTM! Schema updates are well-coordinated:
- Host description properly escaped for JSON safety.
- Version enum reordered from ascending to descending (latest first), which improves UX in UI dropdowns.
- Description aligns with values.yaml and README documentation.
Enum ordering change is a minor UX improvement for the deployment UI.
Also applies to: 618-627
packages/apps/kubernetes/values.yaml (1)
49-59: LGTM! Version enum properly defined and integrated:
- Enum annotation format (
@enum,@value) is correct for cozyvalues-gen documentation generation.- Type reference
{Version}correctly links parameter to enum definition.- Default remains v1.33 as expected.
- Enum values (v1.33 → v1.28) in descending order, consistent with schema.json.
Per the Makefile workflow,
hack/update-versions.shwill maintain this enum during version updates.packages/apps/kubernetes/Makefile (1)
11-13: Critical: hack/update-versions.sh script implementation not provided for review. The newupdatetarget depends on this script, but it was not included in the files for review. Per the PR objectives, this script should:
- Read kamaji version from its Dockerfile
- Extract Kubernetes version from kamaji's kubeadm_version.go
- Update KUBERNETES_VERSION, versions.yaml, and values.yaml
Please verify the script implementation is included in your PR and functions correctly.
packages/system/cozystack-resource-definitions/cozyrds/kubernetes.yaml (1)
11-11: Verify OpenAPI schema validation changes against controller implementations. The review flags removal of required constraints from addon and controlPlane fields in the Kubernetes schema. Without access to the repository, I cannot confirm: (1) whether required fields were actually removed, (2) whether downstream controllers (Kamaji, etcd, KubeVirt operators) gracefully handle missing configurations, or (3) whether existing tests cover optional field scenarios. Confirm these details before merging.packages/apps/kubernetes/hack/update-versions.sh (6)
1-12: Good defensive setup with proper error handling.The script correctly sets up strict error handling (errexit, nounset, pipefail) and establishes clear file paths for all artifacts.
14-24: Solid prerequisite validation.Tool checks for skopeo and jq are appropriately placed early with clear error messages.
188-188: Trap command uses double quotes; verify this is intentional.Shellcheck (SC2064) flags the trap on line 188. Double quotes cause
$TEMP_FILEand$TEMP_VERSIONSto expand immediately when the trap is set, not when executed. This is likely correct (since the variables are already defined), but consider single quotes if future code changes cause confusion:# Current (double quotes—expands at trap set time): trap "rm -f $TEMP_FILE $TEMP_VERSIONS" EXIT # Alternative (single quotes—expands at trap execution time): trap 'rm -f "$TEMP_FILE" "$TEMP_VERSIONS"' EXITThe current approach is fine and common in shell scripts.
245-259: Makefile update logic is clean.The awk-based update for KUBERNETES_VERSION is straightforward and correct. The conditional check before updating is appropriate.
129-129: Remove unused variableTOTAL_LINES.
TOTAL_LINESis assigned on line 129 but is never referenced elsewhere in the file.-TOTAL_LINES=$(wc -l < "$TEMP_VERSIONS" | tr -d ' ') START_POS=$((SUPPORTED_POS - 5))
176-184: Critical: Script generates invalid YAML format.The script at lines 176-184 outputs invalid YAML. The current format produces unstructured quoted lines that yq cannot parse as a valid YAML object:
"v1.31": "v1.31.4" "v1.32": "v1.32.1"Remove outer quotes from keys to generate valid block-style YAML:
{ for ver in "${VERSIONS[@]}"; do - echo "\"${ver}\": \"${VERSION_MAP[$ver]}\"" + echo "${ver}: \"${VERSION_MAP[$ver]}\"" done } > "$VERSIONS_FILE"This produces valid YAML that downstream consumers like
yqcan parse correctly.⛔ Skipped due to learnings
Learnt from: NickVolynkin Repo: cozystack/cozystack PR: 1117 File: packages/apps/mysql/Makefile:8-8 Timestamp: 2025-06-26T04:29:24.830Z Learning: The cozystack project uses yq v4+ on their CI runner, so yq v4 syntax (-o json --indent 4) is compatible and version checks are not needed.
| - name: Install generate | ||
| run: | | ||
| curl -sSL https://github.com/cozystack/cozyvalues-gen/releases/download/v1.0.5/cozyvalues-gen-linux-amd64.tar.gz | tar -xzvf- -C /usr/local/bin/ cozyvalues-gen | ||
| curl -sSL https://github.com/cozystack/cozyvalues-gen/releases/download/v1.0.6/cozyvalues-gen-linux-amd64.tar.gz | tar -xzvf- -C /usr/local/bin/ cozyvalues-gen |
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.
🧩 Analysis chain
🌐 Web query:
cozyvalues-gen v1.0.6 release GitHub cozystack
💡 Result:
I couldn't find a v1.0.6 release. The cozyvalues-gen GitHub Releases list shows up to v1.0.4 (released 29 Oct 2025); the module page on pkg.go.dev also lists v1.0.1 as a published version and points to the GitHub repo. [1][2]
Sources:
- GitHub Releases — cozystack/cozyvalues‑gen (Releases page showing v1.0.4 as latest). [1]
- pkg.go.dev — github.com/cozystack/cozyvalues‑gen (module documentation). [2]
The cozyvalues-gen version v1.0.6 does not exist and will cause the workflow to fail. The latest available release is v1.0.4 (Oct 29, 2025). Update line 31 to use a valid version or confirm the intended version bump.
🤖 Prompt for AI Agents
.github/workflows/pre-commit.yml line 31: the workflow downloads cozyvalues-gen
v1.0.6 which does not exist and will break CI; update the curl URL to a valid
release (for example replace v1.0.6 with the latest available tag v1.0.4) or
change it to the intended release you want to use, and verify the asset name
(cozyvalues-gen-linux-amd64.tar.gz) and binary path remain correct.
This PR adds a version management system for Kubernetes that automatically fetches and updates supported versions based on kamaji.
Changes
hack/update-versions.shscript to fetch and update Kubernetes versionsfiles/versions.yamlwith version mappingsvalues.yamlwith version enum and parameterMakefileto include version update workflowhackdirectory to.helmignoreFeatures
Workflow
Summary by CodeRabbit
New Features
Documentation
Chores
✏️ Tip: You can customize this high-level summary in your review settings.