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

feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1, etc #5222

Merged
merged 4 commits into from
Mar 27, 2025

Conversation

rolodato
Copy link
Member

@rolodato rolodato commented Mar 12, 2025

In #5199, I tried to improve the UX for configuring replica database URLs by accepting a JSON-encoded list of database URLs. This approach is not suitable for use with Helm.

In our Helm values, there are several ways of accepting database URLs:

  • Plaintext URL
  • Plaintext key/value config
  • Secret reference

The problem is dealing with secret references. At deploy time, we cannot access the contents of Kubernetes secrets, so we cannot directly create a JSON-encoded list of URLs. We could imagine some workaround such as having an init container that dynamically creates this list, but this is more trouble than it's worth.

Instead, from Helm we can define each environment variable so that it gets its value from a secret. We can do this for any replica URLs that are passed in via secrets. See Flagsmith/flagsmith-charts#337 for details.

We now accept multiple environment variables such as REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1, etc by starting from 0 and incrementing until we can't find any more variables.

No docs changes for now, as this is only meant to be used by the Helm chart for now.

How did you test this code?

Unit tests.

@rolodato rolodato requested a review from a team as a code owner March 12, 2025 18:46
@rolodato rolodato requested review from gagantrivedi and removed request for a team March 12, 2025 18:46
Copy link

vercel bot commented Mar 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) Visit Preview Mar 27, 2025 11:45pm
flagsmith-frontend-preview ⬜️ Ignored (Inspect) Visit Preview Mar 27, 2025 11:45pm
flagsmith-frontend-staging ⬜️ Ignored (Inspect) Visit Preview Mar 27, 2025 11:45pm

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request labels Mar 12, 2025
Copy link
Contributor

github-actions bot commented Mar 12, 2025

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:main Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:main Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:main Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:main Finished ✅ Results
ghcr.io/flagsmith/flagsmith:main Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:main Finished ✅ Results

Copy link
Contributor

github-actions bot commented Mar 12, 2025

Uffizzi Preview deployment-61826 was deleted.

Copy link

codecov bot commented Mar 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.52%. Comparing base (3059eeb) to head (d098102).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5222   +/-   ##
=======================================
  Coverage   97.52%   97.52%           
=======================================
  Files        1225     1226    +1     
  Lines       42543    42563   +20     
=======================================
+ Hits        41489    41509   +20     
  Misses       1054     1054           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@khvn26 khvn26 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@rolodato rolodato changed the title feat: Accept numbered replica database URLs feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1`, etc Mar 25, 2025
@rolodato rolodato changed the title feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1`, etc feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1, etc Mar 25, 2025
@rolodato rolodato changed the title feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1, etc feat: Each replica database URL can now be configured with an individual environment variable, using REPLICA_DATABASE_URL_0, REPLICA_DATABASE_URL_1, etc Mar 25, 2025
@rolodato rolodato merged commit b704d1c into main Mar 27, 2025
22 of 24 checks passed
@rolodato rolodato deleted the feat/numbered-replica-dbs branch March 27, 2025 23:44
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants