Skip to content
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

feature/add-quota #644

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Feb 22, 2025

Summary by CodeRabbit

  • New Features
    • Introduced a new configurable parameter for tenant resource quotas, enabling flexible CPU and memory management.
    • Added a dynamic setup for resource quota configuration based on tenant settings.
    • Updated application version to 1.8.0.
  • Documentation
    • Added documentation for the new resourceQuotas parameter in tenant configuration.
  • Chores
    • Updated versioning entries for the tenant application.

@klinch0 klinch0 requested a review from kvaps as a code owner February 22, 2025 12:18
@klinch0 klinch0 marked this pull request as draft February 22, 2025 12:18
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Feb 22, 2025
Copy link
Contributor

coderabbitai bot commented Feb 22, 2025

Walkthrough

The pull request updates the tenant application by modifying version numbers and introducing a new resource management parameter. The version is bumped from 1.7.0 to 1.8.0, with corresponding changes in the Chart.yaml and versions_map files. Additionally, a new resourceQuotas parameter is added to the README, values file, JSON schema, and a new Kubernetes ResourceQuota template, allowing for tenant quota configuration.

Changes

Files Change Summary
packages/apps/tenant/Chart.yaml, packages/apps/versions_map Updated version from 1.7.0 to 1.8.0. In versions_map, fixed the 1.7.0 version with a specific commit hash and set 1.8.0 to HEAD.
packages/apps/tenant/README.md, packages/apps/tenant/values.yaml, packages/apps/tenant/values.schema.json,
packages/apps/tenant/templates/quota.yaml
Added a new resourceQuotas parameter for tenant quotas: documentation updates in README, configuration placeholder and commented examples in values,
property addition in JSON schema, and a new ResourceQuota template that conditionally generates resource quotas.

Sequence Diagram(s)

sequenceDiagram
    participant U as User/Operator
    participant H as Helm Renderer
    participant K as Kubernetes API Server
    U->>H: Provide tenant configuration with new `resourceQuotas` parameter
    H->>H: Process Chart (version update) and values (including `resourceQuotas`)
    H->>K: Generate and deploy ResourceQuota (if `resourceQuotas` defined)
    K-->>H: Acknowledge applied quota configuration
Loading

Possibly related PRs

Suggested labels

lgtm

Suggested reviewers

  • kvaps
  • xy2
  • lllamnyp

Poem

Oh, joyful hop, a change so neat,
A version bump and quotas meet.
YAML and JSON in a rhythmic dance,
Tenant updates invite a fresh chance.
With a gentle nudge, I celebrate today—
A bunny’s cheer in code display!
🐰✨


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. (Beta)
  • @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.

@klinch0 klinch0 marked this pull request as ready for review February 24, 2025 10:25
@dosubot dosubot bot added the documentation Improvements or additions to documentation label Feb 24, 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 (5)
packages/apps/tenant/values.schema.json (1)

35-39: Add validation for resource quotas structure.

The schema for resources should include validation for the expected structure of resource quotas (limits and requests for CPU and memory) as shown in the example in values.yaml.

         "resources": {
             "type": "object",
             "description": "Tenant quotas",
-            "default": {}
+            "default": {},
+            "properties": {
+                "limits": {
+                    "type": "object",
+                    "properties": {
+                        "cpu": { "type": "string", "pattern": "^[0-9]+m?$" },
+                        "memory": { "type": "string", "pattern": "^[0-9]+(Mi|Gi)$" }
+                    }
+                },
+                "requests": {
+                    "type": "object",
+                    "properties": {
+                        "cpu": { "type": "string", "pattern": "^[0-9]+m?$" },
+                        "memory": { "type": "string", "pattern": "^[0-9]+(Mi|Gi)$" }
+                    }
+                }
+            }
         }
packages/apps/tenant/README.md (1)

61-61: Add usage examples for tenant quotas.

Consider adding examples of how to configure resource quotas, similar to the example structure provided in values.yaml. This will help users understand how to properly configure tenant quotas.

packages/apps/tenant/values.yaml (1)

17-23: Add unit explanations in the example.

The example is helpful but could be improved by adding comments explaining the units used for CPU and memory values.

 # resources:
 #   limits:
-#     cpu: 4000m
-#     memory: 4Gi
+#     cpu: 4000m    # 4 CPU cores (1000m = 1 core)
+#     memory: 4Gi   # 4 Gibibytes
 #   requests:
-#     cpu: 100m
-#     memory: 512Mi
+#     cpu: 100m     # 0.1 CPU cores
+#     memory: 512Mi # 512 Mebibytes
packages/apps/tenant/templates/quota.yaml (2)

1-1: Helm Template Directive and YAML Linting Note

The opening line uses a Helm template conditional ({{- if .Values.resources }}) which is correct for conditional resource rendering. Note that YAML lint tools may flag this as a syntax error due to the templating syntax. Ensure your linter is configured (or suppressed) for Helm templates to avoid false positives.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)


8-12: Conditional Rendering for Resource Requests

The spec.hard block includes a conditional that renders the requests.cpu and requests.memory fields only when both are provided. This prevents partially defined resource requests. Confirm that this behavior meets your requirements—if you wish to allow a partial definition, you'll need to adjust the conditional.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 24fa722 and ce9e04c.

📒 Files selected for processing (6)
  • packages/apps/tenant/Chart.yaml (1 hunks)
  • packages/apps/tenant/README.md (1 hunks)
  • packages/apps/tenant/templates/quota.yaml (1 hunks)
  • packages/apps/tenant/values.schema.json (1 hunks)
  • packages/apps/tenant/values.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/apps/tenant/Chart.yaml
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/apps/tenant/templates/quota.yaml

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

(syntax)

🔇 Additional comments (4)
packages/apps/versions_map (1)

106-107: LGTM!

The version mapping changes are consistent with the feature addition and follow the established pattern in the file.

packages/apps/tenant/templates/quota.yaml (3)

2-7: ResourceQuota Object Metadata Setup

The API version, kind, and metadata (including using the Helm helper to set the namespace) are defined correctly. The resource name “tenant-quota” is clear and consistent.


13-16: Conditional Rendering for Resource Limits

Similarly, the limits for CPU and memory are rendered only if both .Values.resources.limits.cpu and .Values.resources.limits.memory are defined. This avoids configuration with incomplete resource limits. The logic is sound, assuming that both fields are required together.


17-18: Proper Closure of the Helm Conditional

The closing {{- end }} correctly terminates the conditional block initiated in line 1, ensuring that the ResourceQuota definition is included only when the .Values.resources is provided.

version: 1.7.0
version: 1.7.1
Copy link
Member

Choose a reason for hiding this comment

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

Please bump feature version, not patch version

@klinch0 klinch0 changed the title feature/add-qouta feature/add-quota Feb 24, 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/apps/tenant/README.md (1)

53-61: Correct the possessive pronoun in the description.

In the table row for the host parameter, consider replacing “it's” with “its” for proper grammar (i.e. “for its parent tenant host”).

🧰 Tools
🪛 LanguageTool

[uncategorized] ~55-~55: Did you mean “its” (the possessive pronoun)?
Context: ...sing the tenant name as a subdomain for it's parent tenant host). | "" | | `etc...

(ITS_PREMIUM)

packages/apps/tenant/templates/quota.yaml (1)

1-28: Review Helm templating and YAML indentation.

This new Helm template for generating a Kubernetes ResourceQuota looks structurally sound. Please note that the static analysis warnings regarding indentation (e.g. expected 2 but found 4 on lines 11–12) appear to be false positives due to Helm’s templating syntax. If these warnings become disruptive in your CI pipeline, consider adding YAML linting exclusions for Helm templates.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)


[warning] 12-12: wrong indentation: expected 2 but found 4

(indentation)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce9e04c and 2e1a8a6.

📒 Files selected for processing (6)
  • packages/apps/tenant/Chart.yaml (1 hunks)
  • packages/apps/tenant/README.md (1 hunks)
  • packages/apps/tenant/templates/quota.yaml (1 hunks)
  • packages/apps/tenant/values.schema.json (1 hunks)
  • packages/apps/tenant/values.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/apps/tenant/Chart.yaml
  • packages/apps/tenant/values.schema.json
  • packages/apps/tenant/values.yaml
  • packages/apps/versions_map
🧰 Additional context used
🪛 LanguageTool
packages/apps/tenant/README.md

[uncategorized] ~55-~55: Did you mean “its” (the possessive pronoun)?
Context: ...sing the tenant name as a subdomain for it's parent tenant host). | "" | | `etc...

(ITS_PREMIUM)

🪛 YAMLlint (1.35.1)
packages/apps/tenant/templates/quota.yaml

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

(syntax)


[warning] 11-11: wrong indentation: expected 2 but found 4

(indentation)


[warning] 12-12: wrong indentation: expected 2 but found 4

(indentation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request 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