Skip to content

Conversation

@klinch0
Copy link
Contributor

@klinch0 klinch0 commented Feb 27, 2025

Summary by CodeRabbit

  • New Features

    • Enabled dynamic inclusion of topology constraints across various deployment configurations based on a dedicated configuration source.
  • Chores

    • Upgraded the PostgreSQL application chart version from 0.8.0 to 0.9.0.
    • Updated version mapping by fixing the reference for version 0.8.0 and adding an entry for 0.9.0.

@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
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 27, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the PostgreSQL chart version from 0.8.0 to 0.9.0 and modify the version reference in the versions map to use a fixed commit hash for 0.8.0 while adding an entry for 0.9.0. Additionally, several YAML template files across different packages now include a conditional block that retrieves and processes the topologyConfig from a ConfigMap named cozystack-scheduling in the cozy-system namespace. This update enables dynamic configuration of topology constraints in the deployments.

Changes

Files Change Summary
packages/apps/postgres/Chart.yaml Updated chart version from 0.8.0 to 0.9.0.
packages/apps/versions_map Changed postgres 0.8.0 entry from HEAD to commit hash cb7b8158 and added a new entry for postgres 0.9.0 HEAD.
packages/apps/postgres/templates/db.yaml, packages/apps/ferretdb/templates/postgres.yaml, packages/extra/monitoring/templates/alerta/alerta-db.yaml, packages/extra/monitoring/templates/grafana/db.yaml, packages/system/keycloak/templates/db.yaml Added conditional logic to retrieve and process topologyConfig from the ConfigMap cozystack-scheduling (in the cozy-system namespace) and include its formatted content in the configuration.

Sequence Diagram(s)

sequenceDiagram
    participant T as Templating Engine
    participant CM as ConfigMap ("cozystack-scheduling")
    participant YF as YAML Formatter
    participant SR as Spec Renderer

    T->>CM: Lookup ConfigMap in cozy-system
    alt ConfigMap exists
        CM-->>T: Return ConfigMap data
        T->>T: Check for "topologyConfig"
        alt topologyConfig exists
            T->>YF: Convert YAML to formatted string
            YF-->>T: Return indented YAML
            T->>SR: Include formatted topologyConfig in spec
        else No topologyConfig
            T->>SR: Render spec without topologyConfig
        end
    else ConfigMap not found
        T->>SR: Render spec without topologyConfig
    end
Loading

Suggested labels

size:XL

Suggested reviewers

  • kvaps
  • themoriarti

Poem

I'm a little rabbit, hopping with glee,
In YAML forests, where changes run free.
Chart versions hop from 0.8 to 0.9,
And ConfigMaps whisper secrets in line.
With a twitch of my nose and a click of my paw,
I celebrate these changes, in awe of code's raw beauty!


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cce138 and 88729e4.

📒 Files selected for processing (5)
  • packages/apps/ferretdb/templates/postgres.yaml (1 hunks)
  • packages/apps/postgres/templates/db.yaml (1 hunks)
  • packages/extra/monitoring/templates/alerta/alerta-db.yaml (1 hunks)
  • packages/extra/monitoring/templates/grafana/db.yaml (1 hunks)
  • packages/system/keycloak/templates/db.yaml (1 hunks)

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.

❤️ 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 15
{{ 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
@kvaps kvaps marked this pull request as draft March 4, 2025 08:37
@klinch0 klinch0 force-pushed the feature/add-multi-dc branch from fd19f81 to 4cce138 Compare March 5, 2025 07:41
@klinch0 klinch0 marked this pull request as ready for review March 5, 2025 07:43
@klinch0 klinch0 requested a review from lllamnyp as a code owner March 5, 2025 07:43
@dosubot dosubot bot added the documentation Improvements or additions to documentation label Mar 5, 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 (4)
packages/extra/monitoring/templates/alerta/alerta-db.yaml (1)

8-14: Dynamic ConfigMap Block and YAML Indentation
The new block that fetches and processes topologyConfig via the lookup function is implemented consistently with similar changes elsewhere. However, please verify that the output YAML fragment (via fromYaml | toYaml | nindent 2) integrates correctly under the parent spec mapping. Note that YAMLlint flagged a syntax error on line 9; this is likely a false positive due to the templating logic.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

packages/system/keycloak/templates/db.yaml (1)

9-15: Conditional TopologyConfig Extraction Block
This conditional block that retrieves topologyConfig from the cozystack-scheduling ConfigMap mirrors the pattern used in other parts of the PR. Please confirm that the dynamically injected YAML is valid and properly indented within the overall YAML structure. The static analysis error on line 10 may be a templating false positive.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

packages/apps/ferretdb/templates/postgres.yaml (1)

9-15: Dynamic Inclusion of Topology Constraints
The conditional block for fetching topologyConfig is in line with the broader update. As with similar blocks, ensure that the output YAML fragment (indented by nindent 2) correctly merges into the surrounding configuration. The YAMLlint error on line 10 should be revisited to ensure the final rendered output is valid.

packages/extra/monitoring/templates/grafana/db.yaml (1)

9-15: Dynamic Topology Constraints Inclusion
This conditional block for injecting topology constraints from the cozystack-scheduling ConfigMap is implemented consistently with similar updates in the PR. Please double-check that the output YAML—formatted with fromYaml | toYaml | nindent 2—merges correctly under the current mapping. The YAMLlint error on line 10 may be a false positive; if it persists, consider wrapping the dynamic content under an explicit key.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fd19f81 and 4cce138.

📒 Files selected for processing (7)
  • packages/apps/ferretdb/templates/postgres.yaml (1 hunks)
  • packages/apps/postgres/Chart.yaml (1 hunks)
  • packages/apps/postgres/templates/db.yaml (1 hunks)
  • packages/apps/versions_map (1 hunks)
  • packages/extra/monitoring/templates/alerta/alerta-db.yaml (1 hunks)
  • packages/extra/monitoring/templates/grafana/db.yaml (1 hunks)
  • packages/system/keycloak/templates/db.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/apps/postgres/Chart.yaml
  • packages/apps/versions_map
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/extra/monitoring/templates/alerta/alerta-db.yaml

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

(syntax)

packages/extra/monitoring/templates/grafana/db.yaml

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

(syntax)

packages/system/keycloak/templates/db.yaml

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

(syntax)

packages/apps/postgres/templates/db.yaml

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

(syntax)

🔇 Additional comments (1)
packages/apps/postgres/templates/db.yaml (1)

9-15: YAML Indentation and Dynamic Block Insertion
The topology constraints block injected via the ConfigMap lookup is implemented using the templating functions. However, as noted in previous reviews, ensure that its output—currently indented using nindent 2—aligns correctly within the spec mapping. YAMLlint reported a potential syntax error on line 10; consider verifying the final YAML structure or wrapping the dynamic content within an explicit key if needed.

🧰 Tools
🪛 YAMLlint (1.35.1)

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

(syntax)

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 5, 2025
@lllamnyp lllamnyp merged commit 425ce77 into cozystack:main Mar 5, 2025
1 check passed
@NickVolynkin NickVolynkin mentioned this pull request Jul 24, 2025
3 tasks
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 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