Skip to content

feat(chart): set the number of app replicas - #310

Merged
uniqueg merged 9 commits into
devfrom
feat/chart-replicas
Nov 1, 2026
Merged

uniqueg merged 9 commits into
devfrom
feat/chart-replicas

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Blocked: do not merge before foca-common 0.3.0 is released (elixir-cloud-aai/foca#585, tag chart-v0.3.0). Chart.yaml pins 0.3.0, but Chart.lock and charts.sha256 still lock 0.2.0, as 0.3.0 isn't published yet; CI's dependency build and pin checks fail until then. After the release: helm dependency update deployment, regenerate deployment/charts.sha256 (cd deployment && sha256sum charts/foca-common-0.3.0.tgz > charts.sha256), and commit.

Exposes the new values of foca-common 0.3.0 in Cloud Registry's chart:

  • cloudRegistry.replicas (1 by default) and cloudRegistry.podDisruptionBudget (enabled, minAvailable/maxUnavailable; rendered only with more than one replica, maxUnavailable: 1 by default, unready pods always evictable) in values.yaml, values.schema.json ($defs of the library's 0.3.0 schema) and a new templates/poddisruptionbudget.yaml;
  • deployment/README.md (also served as docs/deployment.md): new "Replicas" section with the multi-replica caveats (counter off by one while a pod starts, node clocks for lock staleness, per-process memory and caches, rules changed in the database directly, single-pod MongoDB, scaling to 0 for upgrades), the restore step of the legacy-chart migration, and links to the library docs at chart-v0.3.0;
  • curated notes of 1.0.0rc1 (Features);
  • chart tests (defaults, replicas, budget bounds, disabled, schema rejections, all kinds in test_names).

Multi-replica safety

The app is correct with several replicas: it already runs as several instances (rolling updates, Gunicorn workers). Roles, invitations, locks, counters and types are in MongoDB, written atomically or with compare-and-swap; the startup tasks (add_service_keys(), resume_renames(), add_service_creators(), reconcile_service_counts(), add_service_types(), sync_pending_services()) are written to run concurrently; FOCA's adapter records rule changes that every instance applies before its next request; _last_resume in rename.py only throttles per worker, and _claim() resumes each rename once.

Closes #307

Verification

  • With foca-common 0.3.0 packaged locally from the foca branch into deployment/charts/: pytest tests/test_chart.py tests/test_chart_readme.py tests/test_check_release_pins.py: all pass except test_library_dependency and test_packaged_chart_includes_library, which compare with Chart.lock (still 0.2.0, see above).
  • ruff check, ruff format --check on tests/: passed.
  • CI: expected to fail on the dependency build and pin checks until foca-common 0.3.0 is released.

Review

Adversarial and quality review; no high findings. Fixed: the medium ones (tests of schema rejections, release notes entry) and the lows (test split, "with FOCA 0.18" kept in the schema comment, README wording on rolling updates, spreading and Gunicorn workers). The finding on unready pods blocking drains was fixed in the library (unhealthyPodEvictionPolicy: AlwaysAllow, foca#585).

Declined review findings

  • Mention the values in NOTES.txt or docs/upgrading.md (low): defaults are unchanged, so no upgrade step is needed; the README covers them.

Open questions

None; this PR only waits for the foca-common 0.3.0 release.

🤖 Generated with Claude Code

Summary by Sourcery

Support running the Cloud Registry chart with configurable app replicas and disruption protection while documenting the operational considerations.

New Features:

  • Add configurable app replica counts and PodDisruptionBudget support to the deployment chart.
  • Expose replica and disruption-budget settings through chart values and schema validation.

Enhancements:

  • Document multi-replica operation, availability considerations, and migration behavior.
  • Update the chart to foca-common 0.3.0 and refresh related documentation links and release notes.

Documentation:

  • Expand deployment documentation with replica configuration, operational caveats, and upgrade guidance.

Tests:

  • Add chart coverage for replica defaults, PodDisruptionBudget behavior and bounds, disabled budgets, resource naming, and invalid configurations.

uniqueg and others added 4 commits November 1, 2026 11:50
Pin foca-common 0.3.0 and expose its cloudRegistry.replicas and
cloudRegistry.podDisruptionBudget values (values.yaml, schema, a
template for the PodDisruptionBudget), with chart tests, and document
replicas and their caveats in the chart's README. Chart.lock and
charts.sha256 still lock 0.2.0 until foca-common 0.3.0 is released.

Closes #307

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Test the schema's rejection of invalid replicas and budgets, split the
budget tests by case, add the feature to the notes of 1.0.0rc1, keep
"with FOCA 0.18" in the schema's comment, and take the library's
updated schema of podDisruptionBudget.enabled (null allowed).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rolling updates replace pods one by one (a new pod first only with up
to 3 replicas), spreading across nodes is not guaranteed, unready pods
don't block drains (unhealthyPodEvictionPolicy of foca-common 0.3.0,
now expected by the chart tests), and Gunicorn workers count as
instances only with more than one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg uniqueg added this to the v1.0.0-rc1 milestone Nov 1, 2026
@uniqueg uniqueg added the type: feature New feature or request label Nov 1, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR upgrades the chart to foca-common 0.3.0 and exposes configurable application replicas with optional, replica-aware PodDisruptionBudget support. It updates schemas, templates, operational documentation, and release notes, with tests covering rendering defaults, budget configuration, disabling, and invalid values. The dependency lock and packaged checksum intentionally await publication of foca-common 0.3.0.

File-Level Changes

Change Details Files
Expose configurable application replicas and disruption protection through the Helm chart.
  • Add cloudRegistry.replicas with a default of one and replica-aware PodDisruptionBudget settings.
  • Render the library chart's PodDisruptionBudget helper only when enabled and more than one replica is configured.
  • Upgrade the foca-common dependency references to chart version 0.3.0 and update the copied value schema.
  • Files: deployment/Chart.yaml, deployment/Chart.lock, deployment/charts.sha256, deployment/values.yaml, deployment/values.schema.json, deployment/templates/poddisruptionbudget.yaml
deployment/Chart.yaml
deployment/Chart.lock
deployment/charts.sha256
deployment/values.yaml
deployment/values.schema.json
deployment/templates/poddisruptionbudget.yaml
Document operating Cloud Registry with multiple replicas and the dependency upgrade.
  • Add replica, disruption budget, scheduling, MongoDB, cache, clock, startup reconciliation, and upgrade caveats.
  • Document restoring the configured replica count after the legacy-chart migration.
  • Update library documentation links to chart-v0.3.0 and add the feature to the 1.0.0rc1 release notes.
  • Files: deployment/README.md, docs/development.md, docs/releases/1.0.0rc1.md
deployment/README.md
docs/development.md
docs/releases/1.0.0rc1.md
Add chart rendering and schema validation coverage for replica and disruption budget behavior.
  • Verify the default single-replica deployment omits the budget and multiple replicas render the expected budget.
  • Test numeric and percentage availability bounds, disabling the budget, invalid values, and mutual exclusivity.
  • Include the PodDisruptionBudget when validating resource names and all rendered resource kinds.
  • Files: tests/test_chart.py
tests/test_chart.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

uniqueg and others added 3 commits November 1, 2026 19:19
Update Chart.lock and charts.sha256 to the published foca-common 0.3.0
chart (ghcr.io digest sha256:accab959...), which adds app replicas and
a PodDisruptionBudget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
@codecov

codecov Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (4a43ed0) to head (d61923b).
⚠️ Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #310   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         2368      2368           
=========================================
  Hits          2368      2368           

☔ View full report in Codecov by Harness.
📢 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.

@uniqueg
uniqueg marked this pull request as ready for review November 1, 2026 21:44

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="deployment/README.md" line_range="738-740" />
<code_context>
    kubectl scale deploy/cloud-registry -n <namespace> --replicas=1
    ```

+   With several replicas (see [Replicas](#replicas)), scale to
+   `cloudRegistry.replicas` instead, or run `helm upgrade` with the values
+   file, which restores it.
+
 Once the new release works, delete a retained volume
</code_context>
<issue_to_address>
**Restore configured replica count**

The issue asks to replace the hard-coded --replicas=1 in the upgrade steps. The restore command still sets one replica; the added guidance asks multi-replica users to adjust it manually or run helm upgrade.
</issue_to_address>

Linked issues

#307 feat(chart): set the number of app replicas · 4 of 6 met · 1 to check by hand

# Requirement Status Notes
1 Pin foca-common 0.3.0 and expose replicas and PodDisruptionBudget settings. ✅ Met Chart.yaml, Chart.lock, and charts.sha256 use 0.3.0; values, schema, template, and documentation links are updated.
2 Keep the default at one replica. ✅ Met values.yaml sets replicas to 1, and chart tests verify the default.
3 Set the ELIXIR On-Cloud deployment to two replicas. 👀 Check by hand (external system) Check the ELIXIR On-Cloud deployment's release values to confirm it sets cloudRegistry.replicas to 2.
4 Document replica operation and the listed multi-replica caveats. ✅ Met The README covers service-counter corrections, clock synchronization, MongoDB availability, and scaling back after stopped-app upgrades, among other caveats.
5 Replace the hard-coded --replicas=1 in the upgrade steps. 🟡 Partly met The README tells multi-replica users to scale to cloudRegistry.replicas or run helm upgrade, but the restore command still specifies --replicas=1.
6 Add chart tests for replicas and disruption budgets. ✅ Met Tests cover defaults, multiple replicas, budget bounds and disabling, invalid values, and resource names.

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and when configured for multiple replicas, the chart changes Kubernetes deployment and eviction behavior; a faulty replica count or disruption budget could cause downtime during node drains or upgrades. Reverting removes the configuration, but it cannot undo an outage that already occurred.

Blocking findings: deployment/README.md:740


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread deployment/README.md Resolved
Scale the app back to cloudRegistry.replicas after the restore in the
legacy-chart migration, instead of a fixed single replica.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_011FSoqMUX3EU35poH13xMgG
@uniqueg
uniqueg merged commit 4c392a8 into dev Nov 1, 2026
32 checks passed
@uniqueg
uniqueg deleted the feat/chart-replicas branch November 1, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(chart): set the number of app replicas

1 participant