Repository navigation
feat(apps): instance-type resource presets with five series - #2607
Conversation
…y aliases Restructure the resource preset table into a flat <series>.<size> naming convention inspired by KubeVirt and cloud-provider instance types. Five series cover the full CPU-to-memory ratio range: t1 (Tiny, 1:0.5) — burstable, low memory c1 (Compute, 1:1) — CPU-balanced, CPU-bound workloads s1 (Standard, 1:2) — proxies, caches, lightweight services u1 (Universal, 1:4) — databases and messaging m1 (Memory, 1:8) — search and analytics Each series provides eight sizes (nano, micro, small, medium, large, xlarge, 2xlarge, 4xlarge), yielding 40 presets in total. Ephemeral storage remains 2Gi for every preset. The seven legacy flat names (nano, micro, small, medium, large, xlarge, 2xlarge) are retained as backward-compatibility aliases returning their original CPU and memory values. Existing HelmReleases and app CRs continue to render identical resources without a migration step. The legacy block is deprecated and will be removed in a future release; the 1:1 conversion table is: nano -> t1.nano (250m / 128Mi) micro -> t1.micro (500m / 256Mi) small -> t1.small (1 / 512Mi) medium -> c1.small (1 / 1Gi) large -> c1.medium (2 / 2Gi) xlarge -> c1.large (4 / 4Gi) 2xlarge -> c1.xlarge (8 / 8Gi) Also fix the preset helper docstring to pass the preset string straight to unsanitizedPreset, replacing the prior list applied-to-tuple form that silently invoked the dot value as a function. Co-authored-by: Matthieu ROBIN <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
Rewrite resourcesPreset values in every apps/* and extras/* chart from the legacy flat names to the new instance-type form, using the 1:1 mapping: nano -> t1.nano micro -> t1.micro small -> t1.small medium -> c1.small large -> c1.medium xlarge -> c1.large 2xlarge -> c1.xlarge Each affected values.yaml carries the canonical 47-value enum (40 instance-type names plus 7 legacy aliases) so the schema accepts both forms during the deprecation window. cozyvalues-gen regenerates the matching api/apps/v1alpha1/*/types.go kubebuilder enum and defaults, the chart values.schema.json, the README parameter table, and the ApplicationDefinition openAPISchema in packages/system/*-rd/cozyrds. Three hardcoded legacy literals in chart templates migrated: - packages/apps/harbor/templates/harbor.yaml:121 (portal) - packages/apps/opensearch/templates/opensearch.yaml:43 (dashboards) - packages/system/keycloak/templates/sts.yaml:115 (heap fallback) packages/apps/foundationdb/Makefile gains the missing hack/update-crd.sh call. Without it, every regen left foundationdb-rd cozyrds stale and new FoundationDB app CRs through cozystack-api were rejected at validation for any non-legacy resourcesPreset value. Every default-rendered chart produces identical CPU and memory to the value applied before the rename, courtesy of the legacy alias table in cozy-lib and the 1:1 default mapping. Co-authored-by: Matthieu ROBIN <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
cozystack-api now scans each app CR Create and Update for the legacy flat resourcesPreset names (nano, micro, small, medium, large, xlarge, 2xlarge) and emits a klog warning per occurrence with the dotted JSON path inside the spec and the suggested 1:1 instance-type replacement. Example log line: Postgres/foo in tenant-x uses deprecated resourcesPreset "small" at spec.resourcesPreset; migrate to "t1.small" (1:1 equivalent CPU and memory) Warnings are non-blocking. Legacy values still render correctly through the cozy-lib legacy alias table; the warning helps operators discover remaining legacy data after the platform upgrade. The mapping table lives in pkg/apis/apps/presets/legacy.go and is the single Go-side source of truth. The walker handles top-level, nested, in-array, non-string and malformed-spec inputs. The wrapper warns are emitted via a pure helper deprecationMessagesFor so the message format is unit-testable without intercepting klog. Co-authored-by: Matthieu ROBIN <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
Add a new pre-upgrade hook migration that walks every HelmRelease
spec.values and every app CR spec under apps.cozystack.io/v1alpha1, and
rewrites legacy flat resourcesPreset values (nano/micro/small/medium/
large/xlarge/2xlarge) to their instance-type equivalents (t1/c1).
Mapping is 1:1 by CPU and memory — the migration never bumps resource
usage. The same table lives in cozy-lib (legacy aliases) and in
pkg/apis/apps/presets/legacy.go.
Properties:
- Idempotent: re-running on a converted cluster is a no-op because
non-legacy values fall through the jq map_legacy else arm.
- Best-effort: a single failed patch logs a warning and continues;
cozy-lib legacy aliases keep charts rendering with identical CPU
and memory even if the migration is incomplete. kubectl patch
stderr is captured and surfaced in the WARN line so operators see
why a patch was rejected.
- Distinguishes "no items" from "kubectl errored" (RBAC stripped,
network down, CRD missing) so a broken cluster cannot look
identical to a clean no-op run and stamp the version
unconditionally.
- Dry-run: MIGRATION_DRY_RUN=1 prints the would-be patches and
leaves the version stamp at 39.
- Final summary echoed to both stdout and stderr.
- Version stamp only advances to 40 on a fully successful real run.
Bump migrations.targetVersion 39 -> 40 so the hook executes on the
next platform upgrade.
Co-authored-by: Matthieu ROBIN <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Pin the 1:1 equivalence between legacy flat preset names and their
instance-type counterparts in helm-unittest for three charts that
exercise different preset shapes:
- postgres — top-level only
- clickhouse — top + nested clickhouseKeeper preset
- opensearch — top + nested dashboards preset
Each case asserts that nano <-> t1.nano, small <-> t1.small,
medium <-> c1.small, large <-> c1.medium, and micro <-> t1.micro
render the same CPU and memory.
packages/apps/{clickhouse,opensearch}/Makefile gain a `test:` target
that calls helm unittest so hack/helm-unit-tests.sh actually runs the
new suites in CI; without it the suites would land as dead weight.
hack/check-rd-presets.sh enforces two invariants in `make unit-tests`:
- every packages/system/*-rd/cozyrds/*.yaml openAPISchema carries
the canonical 47-preset enum (40 instance-type + 7 legacy);
- no chart template carries a hardcoded legacy preset literal in
a defaultingSanitize (list "<legacy>" ...) form.
Both turn an accidental drop of a per-chart Makefile step or an
accidental legacy hardcode into a CI failure rather than silent
production-time validation rejection.
Co-authored-by: Matthieu ROBIN <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Document the five instance-type series (t1/c1/s1/u1/m1) introduced alongside the legacy preset deprecation, the per-size CPU and memory matrix, and the 1:1 legacy-to-instance-type mapping table that powers cozy-lib aliases, migration 39, and the operator-side deprecation warning. Single source of truth referenced from: - packages/library/cozy-lib/templates/_resourcepresets.tpl - packages/core/platform/images/migrations/migrations/39 - pkg/apis/apps/presets/legacy.go Includes an explicit callout that legacy `medium` (1 CPU / 1Gi) and instance-type `*.medium` (2 CPU) are not the same — same word, different resources. Replace inline preset tables in packages/apps/postgres/README.md and packages/apps/kafka/README.md with a short paragraph that names the five series and points at the canonical doc, since the per-app inline tables listed only the legacy seven and would drift further as the canonical matrix evolves. Co-authored-by: Matthieu ROBIN <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
Summary of ChangesHello, 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 structured naming convention for resource presets, replacing legacy flat names with a series-based system that provides better clarity on CPU-to-memory ratios. The changes include a robust upgrade path consisting of backward-compatible aliases, an automated migration script for existing cluster resources, and operator-facing warnings to facilitate the transition to the new naming scheme. Highlights
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 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 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 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
|
📝 WalkthroughWalkthroughAdds instance-type resource presets, updates defaults/enums across APIs, charts, and system schemas, includes a migration to rewrite legacy values, server-side deprecation warnings, CI checks, and refreshed docs/tests. ChangesInstance-type resource presets rollout
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
✨ Finishing Touches🧪 Generate unit tests (beta)
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new cloud-style resource preset naming convention (.) across the platform, updating numerous application charts, documentation, and the cozy-lib library. It includes a migration script to transition existing resources and updates the API server to provide deprecation warnings. Feedback includes improving the robustness of the preset validation script's jq filters, ensuring explicit error handling during JSON unmarshalling in the API registry, and addressing the mutability of the exported legacy mapping configuration to prevent accidental modification.
| // LegacyMapping is the canonical 1:1 conversion table from legacy flat | ||
| // preset names to their instance-type equivalents. CPU and memory of the | ||
| // returned preset match the legacy value exactly. | ||
| var LegacyMapping = map[string]string{ |
There was a problem hiding this comment.
The LegacyMapping map is exported and mutable. While it is intended to be a canonical constant, Go does not support constant maps. To prevent accidental modification by other packages, consider making it private and providing a public getter function that returns a copy, or explicitly documenting it as read-only.
There was a problem hiding this comment.
LegacyMapping is exported intentionally as a read-only canonical reference. The package doc-comment names the three other places the table is mirrored (cozy-lib _resourcepresets.tpl, migration 39, and docs/operations/resource-presets.md), so the table being directly inspectable from outside the package is the point — wrapping it in a getter that returns a defensive copy adds allocation on every lookup for no real safety win, since nothing in the codebase mutates it. Will revisit if a need arises to actually pass the map to code that might write to it.
| if err := json.Unmarshal(app.Spec.Raw, &spec); err != nil { | ||
| return nil | ||
| } |
There was a problem hiding this comment.
There was a problem hiding this comment.
Addressed in af46317. deprecationMessagesFor now logs klog.V(2) with kind, name, namespace and the underlying error before returning on a JSON parse failure. Kept at debug verbosity because the helper is purely informational — upstream validation (validateNoInternalKeys plus the structural-schema check in Create/Update) owns rejecting invalid specs, and a hard error here would fire on transient inputs the caller is about to reject anyway.
| fi | ||
| # The schema is a JSON blob. Pull every resourcesPreset enum out of it. | ||
| enums=$(printf '%s' "$schema" | jq -r ' | ||
| [.. | objects | select(has("enum") and (.description? // "" | test("preset"; "i")))] |
There was a problem hiding this comment.
There was a problem hiding this comment.
Addressed in 9d9750e. The jq selector now keys on the JSON path suffix resourcesPreset rather than the description-substring heuristic, so an unrelated field whose description happens to contain "preset" cannot match. Verified locally that the check still passes against every existing RD schema.
There was a problem hiding this comment.
Actionable comments posted: 9
🧹 Nitpick comments (4)
hack/check-rd-presets.sh (3)
19-23: 💤 Low valueGuard against the no-match glob expansion.
With
set -euo pipefailand nonullglob, ifpackages/system/*-rd/cozyrds/*.yamlmatches nothing, the loop runs once with the literal pattern as$fandyqwill fail on a non-existent file. Not currently a problem since the files exist, but a quick guard (shopt -s nullglobbefore the loop) makes the script robust if directories are reorganized.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hack/check-rd-presets.sh` around lines 19 - 23, The for-loop over the glob pattern packages/system/*-rd/cozyrds/*.yaml can iterate once with the literal pattern when no files match under set -euo pipefail; enable bash nullglob before the loop (e.g., call shopt -s nullglob) so unmatched globs expand to nothing and the loop is skipped, then restore previous nullglob state if needed; target the loop that defines variable f and the glob expression to apply this change.
25-28: ⚡ Quick winDescription-based enum discovery is fragile.
The jq filter selects enum-bearing objects whose
descriptionmatchespreset(case-insensitive). If a future RD schema rewords the description (e.g., "Default sizing for replicas"), the check will silently skip that schema and never enforce the canonical preset set. Consider keying off the JSON path / property name (resourcesPreset) instead, e.g., walk the schema tree and collectenumfrom any property literally namedresourcesPreset(including underpropertieschains).♻️ Proposed jq filter (property-name based)
- enums=$(printf '%s' "$schema" | jq -r ' - [.. | objects | select(has("enum") and (.description? // "" | test("preset"; "i")))] - | .[].enum[] - ' 2>/dev/null || true) + enums=$(printf '%s' "$schema" | jq -r ' + [.. | objects | .properties? // {} | .resourcesPreset? // empty | select(.enum?)] + | .[].enum[]? + ' 2>/dev/null || true)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hack/check-rd-presets.sh` around lines 25 - 28, The current jq expression that builds the enums variable matches objects by description text which is brittle; update the jq filter used to set enums so it walks the schema tree and selects any property literally named "resourcesPreset" (e.g., look for objects under "properties" whose key == "resourcesPreset") and then extracts their enum arrays instead of matching on .description; modify the command that assigns enums (the jq invocation that feeds printf '%s' "$schema") to implement this property-name-based traversal and collection so enums contains the canonical preset values even if descriptions change.
55-56: ⚡ Quick winWiden the regex pattern to catch prefixed preset names in hardcoded values.
The current pattern only matches unprefixed literals (nano, micro, small, etc.), but actual templates use prefixed presets like
"t1.small"and"t1.nano". This gap allows the check to miss legacy presets when they appear with vendor prefixes. Expand the pattern to include these variants and also allow flexible whitespace around thelistdelimiter.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@hack/check-rd-presets.sh` around lines 55 - 56, The grep command that populates legacy_hits uses a narrow regex matching unprefixed names; update that regex to allow optional vendor prefixes and flexible whitespace by matching an optional namespace/prefix before the preset names (e.g., allow something like "[a-z0-9]+." before nano|micro|...) and permit spaces around the list delimiter and quotes; modify the pattern used in the legacy_hits assignment so it will match both "nano" and "t1.nano" (and similar prefixed variants) and also tolerate whitespace between list, parentheses and the quoted values.packages/system/foundationdb-rd/cozyrds/foundationdb.yaml (1)
28-30: 💤 Low valueRemove the stale
# keysOrder: []comment.Line 28 keeps the old placeholder while Line 30 defines the real
keysOrder. Leaving the commented form is confusing and likely to mislead future edits.🧹 Proposed cleanup
- # keysOrder: [] - keysOrder: [["apiVersion"], ["appVersion"], ["kind"], ...]🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/system/foundationdb-rd/cozyrds/foundationdb.yaml` around lines 28 - 30, Remove the stale commented placeholder "# keysOrder: []" so only the real keysOrder mapping remains; locate the commented line near the existing keysOrder key in foundationdb.yaml and delete that single commented line to avoid confusion while keeping the current keysOrder array intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@hack/check-rd-presets.sh`:
- Around line 33-37: The loop that checks EXPECTED entries uses grep -qx "$want"
which treats "$want" as a regex; update the check in the for-loop that iterates
over EXPECTED/want and inspects the enums variable to use fixed-string matching
(add the -F flag, e.g. grep -Fxq) so comparisons are literal and dots or other
regex meta-characters in entries like t1.nano are not treated as regexes; leave
the surrounding logic that appends to missing unchanged.
In `@packages/apps/kubernetes/README.md`:
- Around line 169-195: The README's preset reference is out of date: update the
human-readable preset section to document the new control-plane defaults (e.g.,
controlPlane.apiServer.resourcesPreset -> c1.medium and
controlPlane.controllerManager.resourcesPreset /
controlPlane.scheduler.resourcesPreset /
controlPlane.konnectivity.server.resourcesPreset -> t1.micro) or replace that
entire preset paragraph with a canonical pointer to the resource-preset doc,
then run the docs generator (make generate / cozyvalues-gen) so the ##
Parameters block (which includes controlPlane and images keys) is regenerated
consistently.
In `@packages/apps/mariadb/README.md`:
- Around line 78-79: Update the MariaDB preset reference to include the new
instance-type families and the new default `t1.nano` for `resourcesPreset`, and
mark legacy aliases (e.g., `nano`…`2xlarge`) as deprecated; instead of editing
only README.md, update the cozyvalues generator/upstream source that generates
the preset table so `resourcesPreset` and the generated preset list reflect the
new families and defaults and include a deprecation note for legacy names.
In `@packages/apps/nats/README.md`:
- Around line 10-17: The README's parameters table now defaults resourcesPreset
to "t1.nano" but the later reference still only lists presets `nano`…`2xlarge`,
so update the package README.md to document the new t1.* preset family: expand
the table row for `resourcesPreset` (or add a small subsection) to list t1.nano,
t1.small, t1.medium, etc., or add an explicit link to the shared resource-preset
doc; ensure the `## Parameters` block in this README.md is updated (since
cozyvalues-gen rewrites that block on make generate) and mention
`resourcesPreset`/`t1.nano` consistently so the default is explained.
In `@packages/apps/qdrant/README.md`:
- Around line 22-23: The docs are inconsistent: the parameter resourcesPreset
now defaults to "t1.small" but the presets table only lists legacy names (e.g.,
nano…2xlarge); update the presets reference so it includes the new instance-type
names (e.g., t1.small, t1.medium, etc.) and map legacy aliases to the new names,
or add a clear deprecation note indicating legacy aliases (nano…2xlarge) are
deprecated in favor of the t1.* presets; ensure references to resourcesPreset
and size remain accurate and that the table rows explicitly show both the
current preset values and any legacy aliases.
In `@packages/apps/redis/README.md`:
- Around line 22-23: Update the Parameters/reference documentation so
`resourcesPreset` lists the new preset series (`t1`, `c1`, `s1`, `u1`, `m1` with
their size variants) and show `t1.nano` as the current default while marking
legacy names as deprecated aliases; do this by updating the generator source
used to produce package READMEs (cozyvalues-gen) to include the new preset
mapping and alias/deprecation metadata, then regenerate the README for the Redis
package so the `resourcesPreset` table (and the `size` description if needed)
reflects the new names and deprecation notes.
In `@packages/apps/tcp-balancer/README.md`:
- Around line 15-22: The README shows a default resourcesPreset of `t1.nano` but
the presets table still lists legacy names; update the generator/template that
produces this README so the `resourcesPreset` examples and the preset table use
the new "<series>.<size>" naming (e.g., `t1.nano`) or add a canonical-presets
reference link, and ensure the generated field descriptions for
`resourcesPreset` and the presets table (the template that emits the presets
list) are aligned to the new naming convention rather than patching the README
manually.
In `@packages/apps/vpn/README.md`:
- Around line 28-29: Update the README preset reference table to reflect the new
default family by changing the documented default for resourcesPreset from
legacy names to the new instance-type presets (e.g., include t1.nano as the
default family), add entries mapping legacy aliases to their new instance-type
equivalents and mark those legacy aliases as deprecated, and ensure the table
rows referencing `resourcesPreset` (and any related examples) show the new
default while noting deprecation; keep the `external` description unchanged.
In `@pkg/apis/apps/presets/legacy_test.go`:
- Around line 145-151: The test compares slices `got` and `want` but the inner
loop only iterates over `got`, so if `got` is shorter than `want` missing
expected entries are not reported; change the comparison to iterate up to the
larger length (or explicitly check lengths first) and for each index i compare
presence and value, reporting when i >= len(got) (missing actual) or i >=
len(want) (unexpected extra) or got[i] != want[i]; update the loop around the
existing reflect.DeepEqual check (references: variables `got`, `want` and the
t.Errorf call) to ensure missing/extra elements are surfaced in test output.
---
Nitpick comments:
In `@hack/check-rd-presets.sh`:
- Around line 19-23: The for-loop over the glob pattern
packages/system/*-rd/cozyrds/*.yaml can iterate once with the literal pattern
when no files match under set -euo pipefail; enable bash nullglob before the
loop (e.g., call shopt -s nullglob) so unmatched globs expand to nothing and the
loop is skipped, then restore previous nullglob state if needed; target the loop
that defines variable f and the glob expression to apply this change.
- Around line 25-28: The current jq expression that builds the enums variable
matches objects by description text which is brittle; update the jq filter used
to set enums so it walks the schema tree and selects any property literally
named "resourcesPreset" (e.g., look for objects under "properties" whose key ==
"resourcesPreset") and then extracts their enum arrays instead of matching on
.description; modify the command that assigns enums (the jq invocation that
feeds printf '%s' "$schema") to implement this property-name-based traversal and
collection so enums contains the canonical preset values even if descriptions
change.
- Around line 55-56: The grep command that populates legacy_hits uses a narrow
regex matching unprefixed names; update that regex to allow optional vendor
prefixes and flexible whitespace by matching an optional namespace/prefix before
the preset names (e.g., allow something like "[a-z0-9]+." before nano|micro|...)
and permit spaces around the list delimiter and quotes; modify the pattern used
in the legacy_hits assignment so it will match both "nano" and "t1.nano" (and
similar prefixed variants) and also tolerate whitespace between list,
parentheses and the quoted values.
In `@packages/system/foundationdb-rd/cozyrds/foundationdb.yaml`:
- Around line 28-30: Remove the stale commented placeholder "# keysOrder: []" so
only the real keysOrder mapping remains; locate the commented line near the
existing keysOrder key in foundationdb.yaml and delete that single commented
line to avoid confusion while keeping the current keysOrder array intact.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 976dbb6a-3c17-411d-a7fa-93ae840996cf
📒 Files selected for processing (117)
Makefileapi/apps/v1alpha1/clickhouse/types.goapi/apps/v1alpha1/foundationdb/types.goapi/apps/v1alpha1/harbor/types.goapi/apps/v1alpha1/httpcache/types.goapi/apps/v1alpha1/kafka/types.goapi/apps/v1alpha1/kubernetes/types.goapi/apps/v1alpha1/mariadb/types.goapi/apps/v1alpha1/mongodb/types.goapi/apps/v1alpha1/nats/types.goapi/apps/v1alpha1/openbao/types.goapi/apps/v1alpha1/opensearch/types.goapi/apps/v1alpha1/postgresql/types.goapi/apps/v1alpha1/qdrant/types.goapi/apps/v1alpha1/rabbitmq/types.goapi/apps/v1alpha1/redis/types.goapi/apps/v1alpha1/tcpbalancer/types.goapi/apps/v1alpha1/vpn/types.godocs/operations/resource-presets.mdhack/check-rd-presets.shpackages/apps/clickhouse/Makefilepackages/apps/clickhouse/README.mdpackages/apps/clickhouse/tests/resourcepreset_test.yamlpackages/apps/clickhouse/values.schema.jsonpackages/apps/clickhouse/values.yamlpackages/apps/foundationdb/Makefilepackages/apps/foundationdb/README.mdpackages/apps/foundationdb/values.schema.jsonpackages/apps/foundationdb/values.yamlpackages/apps/harbor/README.mdpackages/apps/harbor/templates/harbor.yamlpackages/apps/harbor/values.schema.jsonpackages/apps/harbor/values.yamlpackages/apps/http-cache/README.mdpackages/apps/http-cache/values.schema.jsonpackages/apps/http-cache/values.yamlpackages/apps/kafka/README.mdpackages/apps/kafka/values.schema.jsonpackages/apps/kafka/values.yamlpackages/apps/kubernetes/README.mdpackages/apps/kubernetes/values.schema.jsonpackages/apps/kubernetes/values.yamlpackages/apps/mariadb/README.mdpackages/apps/mariadb/values.schema.jsonpackages/apps/mariadb/values.yamlpackages/apps/mongodb/README.mdpackages/apps/mongodb/values.schema.jsonpackages/apps/mongodb/values.yamlpackages/apps/nats/README.mdpackages/apps/nats/values.schema.jsonpackages/apps/nats/values.yamlpackages/apps/openbao/README.mdpackages/apps/openbao/values.schema.jsonpackages/apps/openbao/values.yamlpackages/apps/opensearch/Makefilepackages/apps/opensearch/README.mdpackages/apps/opensearch/templates/opensearch.yamlpackages/apps/opensearch/tests/resourcepreset_test.yamlpackages/apps/opensearch/values.schema.jsonpackages/apps/opensearch/values.yamlpackages/apps/postgres/README.mdpackages/apps/postgres/tests/resourcepreset_test.yamlpackages/apps/postgres/values.schema.jsonpackages/apps/postgres/values.yamlpackages/apps/qdrant/README.mdpackages/apps/qdrant/values.schema.jsonpackages/apps/qdrant/values.yamlpackages/apps/rabbitmq/README.mdpackages/apps/rabbitmq/values.schema.jsonpackages/apps/rabbitmq/values.yamlpackages/apps/redis/README.mdpackages/apps/redis/values.schema.jsonpackages/apps/redis/values.yamlpackages/apps/tcp-balancer/README.mdpackages/apps/tcp-balancer/values.schema.jsonpackages/apps/tcp-balancer/values.yamlpackages/apps/vpn/README.mdpackages/apps/vpn/values.schema.jsonpackages/apps/vpn/values.yamlpackages/core/platform/images/migrations/migrations/39packages/core/platform/values.yamlpackages/extra/external-dns/README.mdpackages/extra/external-dns/values.schema.jsonpackages/extra/external-dns/values.yamlpackages/extra/ingress/README.mdpackages/extra/ingress/values.schema.jsonpackages/extra/ingress/values.yamlpackages/extra/seaweedfs/README.mdpackages/extra/seaweedfs/values.schema.jsonpackages/extra/seaweedfs/values.yamlpackages/library/cozy-lib/templates/_resourcepresets.tplpackages/library/cozy-lib/templates/_resources.tplpackages/system/clickhouse-rd/cozyrds/clickhouse.yamlpackages/system/external-dns-rd/cozyrds/external-dns.yamlpackages/system/foundationdb-rd/cozyrds/foundationdb.yamlpackages/system/harbor-rd/cozyrds/harbor.yamlpackages/system/http-cache-rd/cozyrds/http-cache.yamlpackages/system/ingress-rd/cozyrds/ingress.yamlpackages/system/kafka-rd/cozyrds/kafka.yamlpackages/system/keycloak/templates/sts.yamlpackages/system/kubernetes-rd/cozyrds/kubernetes.yamlpackages/system/mariadb-rd/cozyrds/mariadb.yamlpackages/system/mongodb-rd/cozyrds/mongodb.yamlpackages/system/nats-rd/cozyrds/nats.yamlpackages/system/openbao-rd/cozyrds/openbao.yamlpackages/system/opensearch-rd/cozyrds/opensearch.yamlpackages/system/postgres-rd/cozyrds/postgres.yamlpackages/system/qdrant-rd/cozyrds/qdrant.yamlpackages/system/rabbitmq-rd/cozyrds/rabbitmq.yamlpackages/system/redis-rd/cozyrds/redis.yamlpackages/system/seaweedfs-rd/cozyrds/seaweedfs.yamlpackages/system/tcp-balancer-rd/cozyrds/tcp-balancer.yamlpackages/system/vpn-rd/cozyrds/vpn.yamlpkg/apis/apps/presets/legacy.gopkg/apis/apps/presets/legacy_test.gopkg/registry/apps/application/rest.gopkg/registry/apps/application/rest_legacy_presets_test.go
Update the resource-management guide to describe the new
`<series>.<size>` instance-type preset scheme:
- five series (t1, c1, s1, u1, m1) covering CPU:memory ratios from
1:0.5 to 1:8
- eight sizes (nano through 4xlarge) per series
- explicit callout that legacy `medium` (1 CPU / 1Gi) and new
`*.medium` (2 CPU) names overlap but resources do not
- 1:1 legacy-to-instance-type mapping table for the seven deprecated
flat names that remain accepted as aliases
- mention of the API-server deprecation warning and the platform
upgrade migration that rewrites stored values
Also correct CPU values in the prior table that disagreed with the
actual cozy-lib library (nano was listed as 100m / 128Mi but
cozy-lib has always rendered 250m / 128Mi for nano, and so on for
every row); pin the table on the values cozy-lib actually returns.
Track corresponding code change at cozystack/cozystack#2607.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Update the resource-management guide to describe the new
`<series>.<size>` instance-type preset scheme:
- five series (t1, c1, s1, u1, m1) covering CPU:memory ratios from
1:0.5 to 1:8
- eight sizes (nano through 4xlarge) per series
- explicit callout that legacy `medium` (1 CPU / 1Gi) and new
`*.medium` (2 CPU) names overlap but resources do not
- 1:1 legacy-to-instance-type mapping table for the seven deprecated
flat names that remain accepted as aliases
- mention of the API-server deprecation warning and the platform
upgrade migration that rewrites stored values
Also correct CPU values in the prior table that disagreed with the
actual cozy-lib library (nano was listed as 100m / 128Mi but
cozy-lib has always rendered 250m / 128Mi for nano, and so on for
every row); pin the table on the values cozy-lib actually returns.
Track corresponding code change at cozystack/cozystack#2607.
Assisted-By: Claude <[email protected]>
Signed-off-by: Aleksei Sviridkin <[email protected]>
Address review feedback from gemini-code-assist on hack/check-rd-presets.sh:26
and coderabbitai on hack/check-rd-presets.sh:37.
- Switch the jq enum extractor from a description-substring heuristic
(test("preset"; "i")) to a JSON path-suffix selector that matches
fields literally named resourcesPreset. Eliminates false positives
from unrelated fields whose descriptions happen to mention "preset".
- Use grep -F for literal enum membership so the "." in entries like
t1.nano cannot accidentally match arbitrary characters (e.g. a typo
t1xnano would have satisfied t1.nano under basic regex).
Signed-off-by: Aleksei Sviridkin <[email protected]>
Address review feedback from gemini-code-assist on pkg/registry/apps/application/rest.go:1777. When app.Spec.Raw cannot be unmarshalled to map[string]any the deprecation walker now logs a klog.V(2) line naming the kind, name, namespace and the underlying error before returning. Upstream validation still owns rejecting invalid specs (this hook is purely informational), so the log stays at debug verbosity rather than surfacing as a warning that would fire on transient inputs the caller is about to reject anyway. Helper signature changed to (kind, namespace, name string, raw []byte) so the malformed-input path is reachable from existing unit tests without forcing a fake Application wrapper. Signed-off-by: Aleksei Sviridkin <[email protected]>
Address review feedback from coderabbitai on pkg/apis/apps/presets/legacy_test.go:151. Replace the index-by-index loop over `got` with a single t.Fatalf that prints both slices via %#v. The previous loop iterated only across `got`, so extra entries in `want` would slip past unreported when `got` was shorter than `want`; t.Fatalf with full slice representations names both sides regardless of length. Signed-off-by: Aleksei Sviridkin <[email protected]>
Address review feedback from coderabbitai across: - packages/apps/kubernetes/README.md - packages/apps/mariadb/README.md - packages/apps/nats/README.md - packages/apps/qdrant/README.md - packages/apps/redis/README.md - packages/apps/tcp-balancer/README.md - packages/apps/vpn/README.md Each of these READMEs left an inline 7-row preset table listing only the legacy flat names after the parameters block above already defaulted to an instance-type value (e.g. `t1.nano`). cozyvalues-gen only regenerates the `## Parameters` block, so the hand-written section drifted. Replace the inline tables with the same short paragraph already used by postgres and kafka READMEs: name the five series, note that the seven legacy names remain accepted as deprecated aliases, and link to the canonical reference at docs/operations/resource-presets.md so the full size matrix and legacy mapping live in exactly one place. Signed-off-by: Aleksei Sviridkin <[email protected]>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/apps/kubernetes/README.md (1)
214-217:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winCanonical link was added, but stale preset catalog below still contradicts it.
Good change here, but the following
### instanceType Resources/series sections still document retired families and old sizes, which conflicts with this new canonical guidance. Please remove or update that stale catalog to avoid mixed instructions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/apps/kubernetes/README.md` around lines 214 - 217, The README currently contains a stale catalog under the "### instanceType Resources" heading that contradicts the new canonical naming guidance (series.<size> and the five series t1/c1/s1/u1/m1 plus nano→4xlarge sizes and deprecated legacy aliases); remove or update the entire legacy catalog sections (the "### instanceType Resources" heading and each series subsection) so they reflect the canonical series.<size matrix and the legacy-to-instance-type mapping linked in docs/operations/resource-presets.md, ensuring the documented series names (t1, c1, s1, u1, m1), sizes (nano..4xlarge) and deprecated aliases are accurate and not duplicated elsewhere in the file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@packages/apps/kubernetes/README.md`:
- Around line 214-217: The README currently contains a stale catalog under the
"### instanceType Resources" heading that contradicts the new canonical naming
guidance (series.<size> and the five series t1/c1/s1/u1/m1 plus nano→4xlarge
sizes and deprecated legacy aliases); remove or update the entire legacy catalog
sections (the "### instanceType Resources" heading and each series subsection)
so they reflect the canonical series.<size matrix and the
legacy-to-instance-type mapping linked in docs/operations/resource-presets.md,
ensuring the documented series names (t1, c1, s1, u1, m1), sizes (nano..4xlarge)
and deprecated aliases are accurate and not duplicated elsewhere in the file.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dd1c0f99-92ab-4ce7-897e-8bda851194ff
📒 Files selected for processing (11)
hack/check-rd-presets.shpackages/apps/kubernetes/README.mdpackages/apps/mariadb/README.mdpackages/apps/nats/README.mdpackages/apps/qdrant/README.mdpackages/apps/redis/README.mdpackages/apps/tcp-balancer/README.mdpackages/apps/vpn/README.mdpkg/apis/apps/presets/legacy_test.gopkg/registry/apps/application/rest.gopkg/registry/apps/application/rest_legacy_presets_test.go
✅ Files skipped from review due to trivial changes (1)
- pkg/apis/apps/presets/legacy_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/registry/apps/application/rest.go
- pkg/registry/apps/application/rest_legacy_presets_test.go
|
Is it only about CPU & Memory presets ? Cloud Family could be quite complex in naming convention with all alternatives and combinations : |
|
YohanS (@YohanSciubukgian) not in this PR. Feel free to contribute! |
Andrei Kvapil (kvaps)
left a comment
There was a problem hiding this comment.
LGTM (also covers companion docs PR website#535).
Verified the rename's upgrade path is safe in three layers:
- cozy-lib retains legacy aliases with original CPU/memory, so existing HelmReleases keep rendering identical resources without any migration.
- Migration 39 walks both HelmReleases (
.spec.values) and every app CR underapps.cozystack.io; the jq walk catches nested presets (clickhouseKeeper,dashboards), it is idempotent, dry-run viaMIGRATION_DRY_RUN=1, and only advances the version stamp on a failure-free run. - The cozystack-api
Create/Updatehook emits klog warnings naming the JSON path and the 1:1 instance-type replacement.
Spot-checked: all 20 schema defaults migrate 1:1 (micro→t1.micro, medium→c1.small, …), hardcoded chart literals (harbor, opensearch, keycloak) preserve resources, CRD + JSON-schema enums are supersets so existing CRs keep validating, the 1:1 table is mirrored consistently across cozy-lib, the migration jq, pkg/apis/apps/presets/legacy.go, and the docs, and hack/check-rd-presets.sh enforces RD invariance plus a chart-template lint against new legacy literals.
## What this PR does Companion to [cozystack/cozystack#2607](cozystack/cozystack#2607). > **Merge order:** must land after cozystack/cozystack#2607. The new closing paragraph links to `docs/operations/resource-presets.md` in the cozystack repo, which is created by #2607 — the link 404s until #2607 is merged. Updates the resource-management guide to describe the new `<series>.<size>` instance-type preset scheme rolled out across all Cozystack apps: - Five series covering the full CPU-to-memory ratio range (`t1` 1:0.5, `c1` 1:1, `s1` 1:2, `u1` 1:4, `m1` 1:8) with eight sizes each. - Explicit callout that legacy `medium` (1 CPU / 1Gi) and instance-type `*.medium` (2 CPU) names overlap but resources do not. - 1:1 legacy-to-instance-type mapping table for the seven deprecated flat names that remain accepted as aliases. - Mention of the API-server deprecation warning and the platform upgrade migration (Migration 39) that rewrites stored values. ### Fixes pre-existing CPU drift in three tables on the same page The previous tables listed `nano = 100m`, `micro = 250m`, `small = 500m`, etc. — values that never matched what `cozy-lib` actually rendered. The library returns `nano = 250m / 128Mi`, `micro = 500m / 256Mi`, `small = 1 / 512Mi`, and so on. Pin all three preset tables (the main one and both `cpu-allocation-ratio` example tables) on the values the library actually returns, and switch the example tables to instance-type names while we're there. ### Other cleanups - Fix typos in the line: `If both resources and resourcesPreset are defined, resource is used and resourcsePreset is ignored.` (was missing the trailing `s` on `resource` and had `resourcsePreset` instead of `resourcesPreset`). ### Release note ```release-note docs(resource-management): describe instance-type preset scheme (t1/c1/s1/u1/m1 × 8 sizes), add legacy-to-instance-type mapping table, correct CPU values across all three preset tables to match the cozy-lib library. ```
## What this PR does Follow-up to #2675. Fixes four broken references in `docs/changelogs/v1.4.0.md` that were caught by re-verifying every link in the merged changelog: | Where | Was | Now | |---|---|---| | Resource Presets doc link (Feature Highlights) | `cozystack.io/docs/operations/resource-presets/` (404) | `cozystack.io/docs/v1.4/guides/resource-management/` | | HAMi doc link (Feature Highlights) | `cozystack.io/docs/operations/kubernetes/hami/` (404) | `cozystack.io/docs/v1.4/kubernetes/gpu-sharing/` | | Upgrade notes — resource presets PR ref | `#2426` (`feat(monitoring): upgrade victoria-metrics-operator`) | `#2607` (`feat(apps): instance-type resource presets`) | | Upgrade notes — postgres parameters PR ref | `#2475` (unrelated open issue about bundle YAML) | `#2466` (`feat(postgres)!: support all PostgreSQL configuration parameters`) | The Feature Highlights / Major Features sections already cited #2607 and #2466 correctly; only the Upgrade Notes section pointed at the wrong PR numbers. ### Release note ```release-note NONE ``` <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated changelog documentation links to reflect new resource management guides location. * Refreshed HAMi compatibility references to point to current GPU-sharing documentation. * Updated related PR references in upgrade notes for accuracy. <!-- review_stack_entry_start --> [](https://app.coderabbit.ai/change-stack/cozystack/cozystack/pull/2693?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Resource Presets doc URL: /docs/operations/resource-presets/ → /docs/v1.4/guides/resource-management/ (was 404) - HAMi doc URL: /docs/operations/kubernetes/hami/ → /docs/v1.4/kubernetes/gpu-sharing/ (was 404) - Upgrade-notes PR ref for presets: cozystack#2426 → cozystack#2607 - Upgrade-notes PR ref for postgres parameters: cozystack#2475 → cozystack#2466 Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
What this PR does
Closes #1959.
Continuation of Matthieu ROBIN (@matthieu-robin)'s instance-type resource presets work, addressing the migration gaps and resource regressions surfaced during the review of #1959.
Resource presets now follow a cloud-style
<series>.<size>naming convention. Five series cover the full CPU-to-memory ratio range, each with eight sizes (nanothrough4xlarge):t1c1s1u1m140 instance-type presets in total. The seven legacy flat names (
nano,micro,small,medium,large,xlarge,2xlarge) remain accepted as deprecated aliases.Upgrade path
The combination of three mechanisms makes the rename a no-op for existing deployments:
cozy-liblegacy aliases — preserve the exact pre-rename CPU and memory for every legacy name.helm template ... --set resourcesPreset=smallcontinues to render1 CPU / 512Mi, identical to before. No HelmRelease that already lives on the cluster breaks.HelmRelease.spec.valuesand every app CR underapps.cozystack.io/v1alpha1, rewriting legacy values to their 1:1 instance-type equivalents (nano → t1.nano,medium → c1.small, etc). Idempotent, best-effort, dry-runnable viaMIGRATION_DRY_RUN=1, distinguishes "no items" from "kubectl errored" so a broken cluster cannot silently stamp the version.cozystack-apideprecation warning — everyCreateandUpdateon an app CR with a legacy value emits aklogwarning naming the JSON path and the 1:1 replacement, so operators discover any remaining legacy data after the platform upgrade.The legacy-to-instance-type mapping is 1:1 by CPU and memory:
nanot1.nanomicrot1.microsmallt1.smallmediumc1.smalllargec1.mediumxlargec1.large2xlargec1.xlargeMirrored in four places (cozy-lib template, Go package, migration jq, docs) with cross-reference comments so drift is visible.
Why not just #1959
The implementation in #1959 had three blockers that motivated this rewrite:
cozy-liblost the legacy names entirely, so any existing HelmRelease withresourcesPreset: smallfailed render withPreset key 'small' invalid. Aliases close this hole.kubectl editwould fail enum validation. The new migration walks both.nano → m1.nanojumped from 128Mi to 2Gi (×16). With two replicas plus sentinel the e2e VM ran out of memory, producing the Redis 90s timeout that blocked the original PR. New defaults preserve resources 1:1.Deprecation timeline
Legacy aliases are scheduled for removal in a future cozystack release. The combination of migration + operator warnings is expected to converge production clusters before then. Removal will land as a separate PR with its own migration cleanup pass.
Test plan
make unit-tests— Go tests for the preset walker + warning helper,helm unittestlegacy↔instance-type parity suites forpostgres/clickhouse/opensearch, RD schema invariance check viahack/check-rd-presets.sh.make generateis idempotent.helm template ./packages/apps/rediswith the new default renders 250m / 128Mi (matches pre-rename Redis exactly — closes the e2e blocker).helm template ./packages/apps/postgres --set resourcesPreset=smallrenders 1 / 512Mi (legacy alias works).MIGRATION_DRY_RUN=1.Documentation
See
docs/operations/resource-presets.mdfor the full size matrix and migration table.Release note
Summary by CodeRabbit
New Features
Documentation
Tests
Chores