[platform] Always set resources for managed apps - #1156
Conversation
WalkthroughThis change unifies and simplifies resource configuration logic across multiple Helm charts and templates by introducing and adopting a new helper, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant HelmChart
participant cozy-lib.resources.defaultingSanitize
participant cozy-lib.resources.unsanitizedPreset
participant cozy-lib.resources.sanitize
User->>HelmChart: Deploy chart with resource values and/or preset
HelmChart->>cozy-lib.resources.defaultingSanitize: Call with (preset, values, context)
cozy-lib.resources.defaultingSanitize->>cozy-lib.resources.unsanitizedPreset: Fetch preset defaults
cozy-lib.resources.defaultingSanitize->>cozy-lib.resources.sanitize: Merge user values over defaults, sanitize
cozy-lib.resources.sanitize-->>cozy-lib.resources.defaultingSanitize: Return sanitized resources
cozy-lib.resources.defaultingSanitize-->>HelmChart: Return final resource config
HelmChart-->>User: Rendered manifest with unified resource settings
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (28)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (26)
🧰 Additional context used🧠 Learnings (2)📓 Common learningspackages/apps/kafka/templates/kafka.yaml (1)🪛 YAMLlint (1.37.1)packages/apps/kafka/templates/kafka.yaml[error] 11-11: syntax error: expected the node content, but found '-' (syntax) 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. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
02cd6e8 to
aca1a2b
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
packages/apps/kafka/templates/kafka.yaml (1)
70-77: Potential copy-paste slip: using Kafka’s storageClass for ZookeeperLine 75 references
.Values.kafka.storageClass, but this block configures Zookeeper storage.
If a chart consumer setszookeeper.storageClass, it will be ignored.- {{- with .Values.kafka.storageClass }} + {{- with .Values.zookeeper.storageClass }}Please confirm the intent and adjust if necessary.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (28)
packages/apps/clickhouse/Chart.yaml(1 hunks)packages/apps/clickhouse/templates/clickhouse.yaml(1 hunks)packages/apps/ferretdb/Chart.yaml(1 hunks)packages/apps/ferretdb/templates/postgres.yaml(1 hunks)packages/apps/http-cache/Chart.yaml(1 hunks)packages/apps/http-cache/templates/haproxy/deployment.yaml(1 hunks)packages/apps/http-cache/templates/nginx/deployment.yaml(1 hunks)packages/apps/kafka/Chart.yaml(1 hunks)packages/apps/kafka/templates/kafka.yaml(2 hunks)packages/apps/kubernetes/templates/cluster.yaml(2 hunks)packages/apps/mysql/Chart.yaml(1 hunks)packages/apps/mysql/templates/mariadb.yaml(1 hunks)packages/apps/nats/Chart.yaml(1 hunks)packages/apps/nats/templates/nats.yaml(1 hunks)packages/apps/postgres/Chart.yaml(1 hunks)packages/apps/postgres/templates/db.yaml(1 hunks)packages/apps/rabbitmq/Chart.yaml(1 hunks)packages/apps/rabbitmq/templates/rabbitmq.yaml(1 hunks)packages/apps/redis/Chart.yaml(1 hunks)packages/apps/redis/templates/redisfailover.yaml(1 hunks)packages/apps/tcp-balancer/Chart.yaml(1 hunks)packages/apps/tcp-balancer/templates/deployment.yaml(1 hunks)packages/apps/versions_map(9 hunks)packages/apps/vpn/Chart.yaml(1 hunks)packages/apps/vpn/templates/deployment.yaml(1 hunks)packages/library/cozy-lib/Chart.yaml(1 hunks)packages/library/cozy-lib/templates/_resourcepresets.tpl(2 hunks)packages/library/cozy-lib/templates/_resources.tpl(1 hunks)
✅ Files skipped from review due to trivial changes (5)
- packages/apps/http-cache/Chart.yaml
- packages/apps/vpn/Chart.yaml
- packages/apps/tcp-balancer/templates/deployment.yaml
- packages/apps/rabbitmq/templates/rabbitmq.yaml
- packages/apps/http-cache/templates/haproxy/deployment.yaml
🚧 Files skipped from review as they are similar to previous changes (22)
- packages/apps/clickhouse/Chart.yaml
- packages/apps/ferretdb/Chart.yaml
- packages/library/cozy-lib/Chart.yaml
- packages/apps/tcp-balancer/Chart.yaml
- packages/apps/postgres/Chart.yaml
- packages/apps/kafka/Chart.yaml
- packages/apps/rabbitmq/Chart.yaml
- packages/apps/nats/templates/nats.yaml
- packages/apps/mysql/Chart.yaml
- packages/apps/clickhouse/templates/clickhouse.yaml
- packages/apps/redis/Chart.yaml
- packages/apps/mysql/templates/mariadb.yaml
- packages/apps/http-cache/templates/nginx/deployment.yaml
- packages/apps/versions_map
- packages/apps/redis/templates/redisfailover.yaml
- packages/library/cozy-lib/templates/_resources.tpl
- packages/library/cozy-lib/templates/_resourcepresets.tpl
- packages/apps/postgres/templates/db.yaml
- packages/apps/kubernetes/templates/cluster.yaml
- packages/apps/ferretdb/templates/postgres.yaml
- packages/apps/vpn/templates/deployment.yaml
- packages/apps/nats/Chart.yaml
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: NickVolynkin
PR: cozystack/cozystack#1120
File: packages/apps/clickhouse/README.md:60-67
Timestamp: 2025-07-03T05:54:50.989Z
Learning: The `cozy-lib.resources.sanitize` function in packages/library/cozy-lib/templates/_resources.tpl supports both standard Kubernetes resource format (with limits:/requests: sections) and flat format (direct resource specifications). The flat format takes priority over nested values. CozyStack apps include cozy-lib as a chart dependency through symlinks in packages/apps/*/charts/cozy-lib directories.
packages/apps/kafka/templates/kafka.yaml (1)
Learnt from: NickVolynkin
PR: cozystack/cozystack#1120
File: packages/apps/clickhouse/README.md:60-67
Timestamp: 2025-07-03T05:54:50.989Z
Learning: The `cozy-lib.resources.sanitize` function in packages/library/cozy-lib/templates/_resources.tpl supports both standard Kubernetes resource format (with limits:/requests: sections) and flat format (direct resource specifications). The flat format takes priority over nested values. CozyStack apps include cozy-lib as a chart dependency through symlinks in packages/apps/*/charts/cozy-lib directories.
🪛 YAMLlint (1.37.1)
packages/apps/kafka/templates/kafka.yaml
[error] 11-11: syntax error: expected the node content, but found '-'
(syntax)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Build
| resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }} | ||
| storage: |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Same YAML-lint issue for Zookeeper block
Replicate the newline fix here to keep the manifest consistent and lint-clean.
- resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }}
+ resources:
+{{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }} | |
| storage: | |
| resources: | |
| {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.zookeeper.resourcesPreset .Values.zookeeper.resources $) | nindent 6 }} | |
| storage: |
🤖 Prompt for AI Agents
In packages/apps/kafka/templates/kafka.yaml at lines 69 to 70, the Zookeeper
block has a YAML-lint issue due to missing newline after the resources line. Add
a newline after the resources line in the Zookeeper block to match the
formatting used elsewhere and ensure the manifest passes linting checks.
| resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }} | ||
| listeners: |
There was a problem hiding this comment.
💡 Verification agent
❓ Verification inconclusive
Inline template breaks YAML-lint – move the helper call to the next line
Putting the {{- include ... }} expression on the same line as the resources: key confuses YAML-lint (syntax error: expected the node content, but found '-') and makes the template harder to read.
Emit the value on its own line – Helm will render identical output while keeping lint tools quiet.
- resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }}
+ resources:
+{{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }}Move Helm helper call to its own line under resources
To satisfy YAML-lint (which errors with “expected node content, but found '-'” when the helper is inline) and improve readability, break the value onto its own line. Helm will render the same output thanks to nindent 6.
- packages/apps/kafka/templates/kafka.yaml lines 11–12
- resources: {{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }}
+ resources:
+{{- include "cozy-lib.resources.defaultingSanitize" (list .Values.kafka.resourcesPreset .Values.kafka.resources $) | nindent 6 }}Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 11-11: syntax error: expected the node content, but found '-'
(syntax)
🤖 Prompt for AI Agents
In packages/apps/kafka/templates/kafka.yaml around lines 11 to 12, the Helm
helper call for resources is inline, causing YAML-lint errors and reducing
readability. Move the helper call to its own line directly under the
`resources:` key, ensuring it is indented properly with `nindent 6`. This change
will satisfy YAML-lint and maintain the same rendered output.
This patch removes the loophole to leave resource requests and limits unspecified in managed apps. Any of cpu, memory, and ephemeral storage are now filled in from the resource preset (default or user-specified) if not explicitly specified in .Values.resources. "none" is no longer an accepted value in resourcePresets and the primary resources now always have some explicit value for proper billing and isolation. Signed-off-by: Timofei Larkin <[email protected]>
aca1a2b to
bd9e283
Compare
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]>
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]>
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]>
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]>
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]>
Preset 'none' is in fact disallowed since #1156 Signed-off-by: Nick Volynkin <[email protected]> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated documentation across all supported applications to remove "none" from the list of allowed values for the `resourcesPreset` parameter. Only sizing presets from "nano" to "2xlarge" are now listed as valid options. * **Chores** * Incremented chart versions for all affected applications. * Updated version mapping to reference specific commits for released versions. * Removed "none" from allowed enum values for `resourcesPreset` in JSON schemas across all applications. * Refactored Makefiles to centralize and update resource preset enums, removing "none" from allowed values. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
What this PR does
This patch removes the loophole to leave resource requests and limits unspecified in managed apps. Any of cpu, memory, and ephemeral storage are now filled in from the resource preset (default or user-specified) if not explicitly specified in .Values.resources. "none" is no longer an accepted value in resourcePresets and the primary resources now always have some explicit value for proper billing and isolation.
Release note
Summary by CodeRabbit
New Features
Refactor
Chores