Skip to content

feat: support running the plugin with multiple replicas - #1105

Open
armru wants to merge 1 commit into
mainfrom
dev/620
Open

armru wants to merge 1 commit into
mainfrom
dev/620

Conversation

@armru

@armru armru commented Sep 17, 2026

Copy link
Copy Markdown
Member

Closes #620

Problem

Running the plugin Deployment with more than one replica does not work today. The gRPC server is added to the controller-runtime manager as a plain runnable, without implementing LeaderElectionRunnable, so controller-runtime only starts it on the pod holding the leader lease. The other replicas never listen on port 9090, fail the TCP readiness probe and stay NotReady forever. The Service can only route to the leader, and a leader crash means waiting for the lease to expire before anything answers again.

Fix

Make the gRPC runnable opt out of leader election. Every replica now serves the plugin interface, so the Service load-balances across all ready pods. The handlers only read ObjectStore objects from the informer cache and never write, so serving them from every replica is safe. The ObjectStore controller keeps using leader election as before, so there is still a single writer.

The Deployment strategy stays Recreate. Switching to RollingUpdate would run two plugin versions side by side during an upgrade and turn gRPC compatibility between consecutive releases into a contract, which deserves its own discussion. Multiple replicas therefore protect against pod or node loss, not against upgrade downtime; the docs say so.

Testing

  • Unit test guarding NeedLeaderElection().
  • New Serial e2e spec: scale the Deployment to two replicas, check both become ready (this fails on main), find the leader through the lease, create an ObjectStore and a Cluster through the load-balanced Service, delete the leader pod, wait for a new leader and both replicas ready again, then create a second Cluster to check reconciliation still works after the failover. The Deployment is scaled back to one replica afterwards.
  • Ran the new spec locally against an ephemeral k3s cluster: passes.

@armru
armru requested a review from a team as a code owner September 17, 2026 11:33
The gRPC server runnable was added to the controller-runtime manager
without implementing LeaderElectionRunnable, so it only ran on the
leader. With more than one replica the other pods never listened on the
plugin port, failed the readiness probe and stayed NotReady, and the
Service could only ever route to the leader.

The gRPC handlers only read from the informer cache, so every replica
can serve them. Make the runnable opt out of leader election; the
ObjectStore controller keeps using leader election as before.

Add an e2e test that scales the deployment to two replicas, checks both
become ready, deletes the leader pod and verifies that a new leader is
elected and clusters still reconcile. Document how to run multiple
replicas.

Closes #620

Signed-off-by: Armando Ruocco <armando.ruocco@enterprisedb.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugin-barman-cloud deployment multiply replicas support

1 participant