Skip to content

Conversation

@xy2
Copy link
Contributor

@xy2 xy2 commented Mar 3, 2025

  1. Now the default resources definitions are forwarded to the actual VMCluster if user hasn't specified any.
  2. The default cpu limit of 500m that is set by the VM-operator has been increased to 2000m, which is the bare minimum to render a single average Grafana page without glitches.

Summary by CodeRabbit

  • Refactor
    • Streamlined resource management by applying consistent default CPU and memory allocations across core system components, ensuring improved performance stability and simplified configuration.

@xy2 xy2 requested a review from kvaps as a code owner March 3, 2025 18:43
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Mar 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

Walkthrough

This update simplifies the resource configurations within the vmcluster.yaml file. It removes conditional checks by replacing the hasKey/toYaml functions with a direct dig function to fetch CPU and memory values for the vminsert, vmselect, and vmstorage components. Default values for limits and requests are clearly defined for each component. No changes were made to public interfaces.

Changes

File(s) Change Summary
packages/extra/…/vm/vmcluster.yaml Modified resource limits and requests for vminsert, vmselect, and vmstorage by removing conditional logic. Defaults applied: vminsert (CPU: 500m, Memory: 1000Mi), vmselect (CPU: 2000m, Memory: 1000Mi, Requests: CPU: 500m, Memory: 500Mi), vmstorage (CPU: 100m, Memory: 2048Mi, Requests: CPU: 100m, Memory: 500Mi).

Possibly related PRs

  • aenix-io/cozystack#555: Updates to resource configurations similar to those applied for the vmagent.
  • aenix-io/cozystack#535: Modifies resource declarations for vmstorage in a manner consistent with this PR.

Suggested labels

size:XS, lgtm

Suggested reviewers

  • kvaps

Poem

I'm a little rabbit on a YAML spree,
Hopping through configs so merrily.
Conditional clutter now out of sight,
With defaults set, everything's just right.
A cheerful hop for every byte!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

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

@xy2 xy2 requested a review from klinch0 March 3, 2025 18:44
@dosubot dosubot bot added the enhancement New feature or request label Mar 3, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
packages/extra/monitoring/templates/vm/vmcluster.yaml (2)

14-17: Clarify vminsert CPU Limit Default Behavior
The CPU limit for vminsert is included conditionally using the dig function with a default value of nil, while the memory has a default of "1000Mi". If the intention is to allow the operator to apply its default (or leave it unset), this is fine. However, if a specific CPU default (such as "500m") is expected for vminsert, please consider adjusting the call or adding documentation to clarify the design decision.


51-54: Clarify vmstorage CPU Limit Default Handling
Similar to vminsert, vmstorage’s CPU limit is conditionally rendered via the dig function with a default of nil. Ensure that this behavior is intentional—i.e. that the operator should provide or omit a CPU limit if not specified. Documenting this behavior or considering a default similar to requests might help avoid confusion in the future.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c46052 and 3e273c0.

📒 Files selected for processing (1)
  • packages/extra/monitoring/templates/vm/vmcluster.yaml (2 hunks)
🔇 Additional comments (5)
packages/extra/monitoring/templates/vm/vmcluster.yaml (5)

19-20: Verify Default Resource Requests for vminsert
The resource requests for vminsert correctly default to "500m" for CPU and "500Mi" for memory using the dig function. These values appear well balanced for typical usage.


25-29: Increase and Document vmselect CPU Limit
The vmselect section now sets the CPU limit to "2000m", which meets the PR objective to enhance performance. The accompanying comments clearly explain that omitting this would have led to the operator defaulting to "500m", which is insufficient. This clear documentation enables future maintainers to understand the rationale behind the increased value.


31-32: Confirm vmselect Resource Requests
The CPU and memory requests for vmselect are defined with defaults "500m" and "500Mi" respectively. These defaults provide a balanced baseline compared to the increased CPU limit and appear to be in line with the intended resource allocation strategy.


56-57: Approve vmstorage Resource Requests Defaults
The resource requests for vmstorage, with defaults "100m" for CPU and "500Mi" for memory, are explicitly provided. These settings appear consistent with the desired resource allocation strategy for this component.


1-67: Overall Template Simplification and Resource Allocation Defaults
The revised template effectively streamlines resource configuration by replacing previous conditional logic with direct calls to the dig function. The defaults for memory and requests are clearly defined, and the increased default CPU limit for vmselect ("2000m") aligns well with the performance enhancement goals outlined in the PR.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 1-1: syntax error: expected the node content, but found '-'

(syntax)

@xy2
Copy link
Contributor Author

xy2 commented Mar 3, 2025

Here is a result (in case no resource changes requested by user):

--- vmcluster-before.yaml       2025-03-03 19:36:37.538818989 +0100
+++ vmcluster-after.yaml        2025-03-03 19:36:42.464828766 +0100
@@ -1,49 +1,65 @@
 apiVersion: operator.victoriametrics.com/v1beta1
 kind: VMCluster
 metadata:
   annotations:
     meta.helm.sh/release-name: monitoring
     meta.helm.sh/release-namespace: tenant-root
   creationTimestamp: "2025-02-03T23:15:17Z"
   finalizers:
   - apps.victoriametrics.com/finalizer
-  generation: 1
+  generation: 2
   labels:
     app.kubernetes.io/managed-by: Helm
     helm.toolkit.fluxcd.io/name: monitoring
     helm.toolkit.fluxcd.io/namespace: tenant-root
   name: shortterm
   namespace: tenant-root
   uid: 711b0177-b931-4441-9353-0aa072d9e586
 spec:
   replicationFactor: 2
   retentionPeriod: 3d
   vminsert:
     replicaCount: 2
-    resources: {}
+    resources:
+      limits:
+        memory: 1000Mi
+      requests:
+        cpu: 500m
+        memory: 500Mi
   vmselect:
     cacheMountPath: /select-cache
     extraArgs:
       dedup.minScrapeInterval: 15s
       search.maxUniqueTimeseries: "600000"
       vmalert.proxyURL: http://vmalert-shortterm.tenant-root.svc:8080
     replicaCount: 2
-    resources: {}
+    resources:
+      limits:
+        cpu: 2000m
+        memory: 1000Mi
+      requests:
+        cpu: 500m
+        memory: 500Mi
     storage:
       volumeClaimTemplate:
         spec:
           resources:
             requests:
               storage: 2Gi
   vmstorage:
     replicaCount: 2
-    resources: {}
+    resources:
+      limits:
+        memory: 2048Mi
+      requests:
+        cpu: 100m
+        memory: 500Mi
     storage:
       volumeClaimTemplate:
         spec:
           resources:
             requests:
               storage: 10Gi
     storageDataPath: /vm-data
 status:
   clusterStatus: operational

Copy link
Member

@kvaps kvaps left a comment

Choose a reason for hiding this comment

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

LGTM

@kvaps kvaps merged commit d4452ea into cozystack:main Mar 5, 2025
1 check passed
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 5, 2025
@xy2 xy2 deleted the 169-victoria-limits branch March 5, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants