Skip to content

Conversation

@maorfr
Copy link
Collaborator

@maorfr maorfr commented Aug 18, 2025

part of https://issues.redhat.com/browse/MGMT-21487

this PR enables secure connectivity between the service and the database for the lightspeed-stack persistence layer.

we mount a DB CA certificate to a file on the pod and pass that file through the lightspeed-stack configuration, as was implemented in lightspeed-core/lightspeed-stack#347

Summary by CodeRabbit

  • Chores
    • Enabled full TLS verification for Postgres connections.
    • Switched CA certificate provisioning from environment variable to a mounted secret.
    • Updated container to read the CA certificate from the mounted location and removed legacy env-based config.
    • Improves connection security and aligns with secret management best practices.
    • No user-facing functional changes; ensure the required secret containing the CA certificate is available during deployment.

@openshift-ci openshift-ci bot requested review from eranco74 and jhernand August 18, 2025 09:48
@coderabbitai
Copy link

coderabbitai bot commented Aug 18, 2025

Walkthrough

Updated template.yaml to configure Postgres TLS with ssl_mode: verify-full and a CA cert path. Replaced env-based CA cert provisioning with a secret-mounted volume at /etc/tls/ca-bundle.pem, added the corresponding volume and mount, and removed the old ASSISTED_CHAT_POSTGRES_CA_CERT environment variable.

Changes

Cohort / File(s) Summary
Postgres TLS via secret volume
template.yaml
Set database.postgres.ssl_mode: verify-full and ca_cert_path: /etc/tls/ca-bundle.pem. Removed env var ASSISTED_CHAT_POSTGRES_CA_CERT. Added secret volume db-ca-cert from ASSISTED_CHAT_DB_SECRET_NAME mapping db.ca_cert to ca-bundle.pem (optional). Mounted at /etc/tls (readOnly).

Sequence Diagram(s)

sequenceDiagram
    participant Pod
    participant Secret(db-ca-cert)
    participant Container(lightspeed-stack)
    participant Postgres

    Pod->>Secret(db-ca-cert): Mount secret as volume
    Pod->>Container(lightspeed-stack): Start with /etc/tls/ca-bundle.pem
    Container(lightspeed-stack)->>Postgres: Connect with ssl_mode=verify-full, ca_cert_path=/etc/tls/ca-bundle.pem
    Postgres-->>Container(lightspeed-stack): TLS connection established
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

approved, lgtm

Suggested reviewers

  • carbonin
  • keitwb

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@openshift-ci
Copy link

openshift-ci bot commented Aug 18, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maorfr

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@maorfr maorfr changed the title Lightspeed ssl enable SSL and CA cert for lightspeed-stack Aug 18, 2025
@omertuc
Copy link
Member

omertuc commented Aug 18, 2025

/lgtm

Copy link

@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 (2)
template.yaml (2)

181-182: Postgres TLS enabled; verify hostname matches cert and lib supports these keys

Good move to enforce TLS. Two follow-ups to avoid runtime surprises:

  • With ssl_mode=verify-full, the value in ASSISTED_CHAT_POSTGRES_HOST must match a SAN/CN on the server cert; otherwise connections will fail. Confirm the secret’s db.host aligns with the cert.
  • Ensure lightspeed-stack actually reads postgres.ssl_mode and postgres.ca_cert_path (naming must match what the app/library expects). If this follows lightspeed-stack PR 347, you’re likely good.

Optional hardening:

  • If other Postgres clients in this pod exist (e.g., llama_stack_client_config inference_store/persistence_store), consider setting PGSSLMODE=verify-full and PGSSLROOTCERT=/etc/tls/ca-bundle.pem in the container env to enforce TLS consistently, or extend their config to add TLS settings if supported.

478-481: Mount only the CA file to avoid shadowing /etc/tls directory

Mounting the whole directory at /etc/tls can mask any existing contents. Mount the single file via subPath instead.

Apply this diff:

-          - name: db-ca-cert
-            mountPath: /etc/tls
-            readOnly: true
+          - name: db-ca-cert
+            mountPath: /etc/tls/ca-bundle.pem
+            subPath: ca-bundle.pem
+            readOnly: true
📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 70509d4 and fa50704.

📒 Files selected for processing (1)
  • template.yaml (3 hunks)

@openshift-merge-bot openshift-merge-bot bot merged commit 4a7696f into rh-ecosystem-edge:main Aug 18, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants