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-multi-dc-for-pg #655

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

Conversation

klinch0
Copy link
Contributor

@klinch0 klinch0 commented Feb 27, 2025

Summary by CodeRabbit

  • New Features

    • Added a new configuration option for topology spread constraints to enhance pod distribution across topology domains. Documentation has been updated with guidance and sample configurations.
  • Chores

    • Upgraded the application chart to version 0.9.0 with improved version consistency.

@klinch0 klinch0 requested a review from kvaps as a code owner February 27, 2025 20:04
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Feb 27, 2025
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Walkthrough

The changes update the PostgreSQL application's Helm configuration. The chart version is incremented from 0.8.0 to 0.9.0, and the versions_map file is revised with a fixed commit hash for 0.8.0 and a new entry for 0.9.0. Additionally, a new parameter topologySpreadConstraints is added across the README, templates, values schema, and values file. This parameter enables conditional deployment configuration within the chart through conditional logic in the YAML templates.

Changes

Files Change Summary
packages/apps/postgres/Chart.yaml, packages/apps/postgres/versions_map Updated PostgreSQL chart version: incremented version from 0.8.0 to 0.9.0, updated the commit hash for 0.8.0 in versions_map, and added a new entry for 0.9.0.
packages/apps/postgres/README.md, packages/apps/postgres/templates/db.yaml, packages/apps/postgres/values.schema.json, packages/apps/postgres/values.yaml Introduced new parameter topologySpreadConstraints: added to documentation in README.md, implemented a conditional block in db.yaml, and updated values and JSON schema files with default empty array and example configurations.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant H as Helm
    participant T as Template Engine
    participant D as Deployment Spec
    U->>H: Run helm install using values.yaml
    H->>T: Render templates (db.yaml)
    T->>T: Check if topologySpreadConstraints exists
    alt Parameter provided
        T->>D: Insert topologySpreadConstraints into deployment spec
    else Not provided
        T->>D: Omit topologySpreadConstraints
    end
    T-->>H: Return rendered manifest
    H->>K: Deploy manifest to Kubernetes
Loading

Possibly related PRs

Suggested labels

enhancement, documentation, lgtm

Suggested reviewers

  • kvaps
  • lllamnyp

Poem

In the garden of code, I hop with delight,
Chart versions and parameters dance in the light.
New constraints emerge with a conditional cheer,
Each line of YAML sings, “Change is here!”
With a twitch of my nose, I celebrate the new tier 🐇
Hop on, dear coder—let’s keep the updates clear!


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.

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: 1

🧹 Nitpick comments (3)
packages/apps/postgres/values.schema.json (1)

105-109: Schema definition could be more specific

The items field is currently empty, which means any array items would be validated against an empty schema. Consider enhancing this to properly validate the structure of Kubernetes topology spread constraints.

 "topologySpreadConstraints": {
     "type": "array",
     "description": "The topologySpreadConstraints",
     "default": [],
-    "items": {}
+    "items": {
+        "type": "object",
+        "properties": {
+            "maxSkew": {
+                "type": "integer",
+                "description": "The degree to which pods may be unevenly distributed"
+            },
+            "topologyKey": {
+                "type": "string",
+                "description": "The key of node labels"
+            },
+            "whenUnsatisfiable": {
+                "type": "string",
+                "description": "How to deal with a pod if it doesn't satisfy the spread constraint",
+                "enum": ["DoNotSchedule", "ScheduleAnyway"]
+            }
+        }
+    }
packages/apps/postgres/README.md (2)

63-63: Typo in Backup Parameter Description

There is a typo in the description for backup.enabled ("Enable pereiodic backups"). Please correct "pereiodic" to "periodic" for clarity.


71-71: Reconsider Parameter Placement and Description

The newly added topologySpreadConstraints parameter is inserted under the "Backup parameters" section. Given its purpose for dynamic deployment configuration, consider either:

  • Moving it to a more appropriate section (e.g., "Deployment Parameters"), or
  • Updating its description to clarify its role within backup or broader deployment settings.

This will help users better understand its function and context.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 160e4e2 and fd19f81.

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

[error] 10-10: syntax error: could not find expected ':'

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: pre-commit
🔇 Additional comments (2)
packages/apps/versions_map (1)

72-73: Version updates look good!

The changes properly version the postgres package, fixing version 0.8.0 to a specific commit hash and correctly setting 0.9.0 to track HEAD.

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

80-85: Well-structured configuration with helpful examples

The addition of the topologySpreadConstraints parameter with commented examples provides clear guidance for users who want to configure topology spread constraints.

Comment on lines +9 to +12
{{ if .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml .Values.topologySpreadConstraints | nindent 4 }}
{{- end }}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix YAML indentation to ensure proper parsing

The static analysis tool reports a syntax error on line 10. While the templating logic is correct, there might be an indentation issue with how the topologySpreadConstraints key is placed relative to other spec fields.

 spec:
   instances: {{ .Values.replicas }}
   enableSuperuserAccess: true
-  {{ if .Values.topologySpreadConstraints }}
-  topologySpreadConstraints:
-    {{- toYaml .Values.topologySpreadConstraints | nindent 4 }}
-  {{- end }}
+  {{- if .Values.topologySpreadConstraints }}
+  topologySpreadConstraints:
+    {{- toYaml .Values.topologySpreadConstraints | nindent 4 }}
+  {{- end }}
   postgresql:
     parameters:

The issue is with the whitespace handling in the templating. Using {{- instead of {{ at the beginning of the if statement will properly trim whitespace and prevent YAML parsing errors.

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

Suggested change
{{ if .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml .Values.topologySpreadConstraints | nindent 4 }}
{{- end }}
spec:
instances: {{ .Values.replicas }}
enableSuperuserAccess: true
{{- if .Values.topologySpreadConstraints }}
topologySpreadConstraints:
{{- toYaml .Values.topologySpreadConstraints | nindent 4 }}
{{- end }}
postgresql:
parameters:
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 10-10: syntax error: could not find expected ':'

(syntax)

@dosubot dosubot bot added the enhancement New feature or request label Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

1 participant