linkerd2/multicluster/cmd
Matei David 958d7983ac
Add leader election to the service-mirror controller (#11046)
In order to support an HA mode for the service-mirror component, some
form of synchronization should be used to coordinate between replicas of
the service-mirror controller. Although in practice most of the updates
done by the replicas are idempotent (and have benign effects on
correctness), there are some downsides, such as: resource usage
implications from setting-up multiple watches, log pollution, errors
associated with writes on resources that out of date, and increased
difficulty in debugging.

This change adds coordination between the replicas through leader
election. To achieve leader election, client-go's `coordination` package
is used. The change refactors the existing code; the previous nested
loops now reside in a closure (to capture the necessary configuration),
and the closure is run when a leader is elected.

Leader election functions as part of a loop: a lease resource is created
(if it does not exist), and the controller blocks until it has acquired
the lease. The loop is terminated only on shutdown from an interrupt
signal. If the lease is lost, it is released, watchers are cleaned-up,
and the controller returns to blocking until it acquires the lease once
again.

Shutdown logic has been changed to rely on context cancellation
propagation so that the  watchers may be ended either by the leader
elector (when claim is lost) or by the main routine when an interrupt is
handled.

---------

Signed-off-by: Matei David <matei@buoyant.io>
Co-authored-by: Alejandro Pedraza <alejandro@buoyant.io>
2023-06-29 11:27:40 +01:00
..
service-mirror Add leader election to the service-mirror controller (#11046) 2023-06-29 11:27:40 +01:00
testdata Add leader election to the service-mirror controller (#11046) 2023-06-29 11:27:40 +01:00
allow.go Remove namespace from charts and split them into `linkerd-crd` and `linkerd-control-plane` (#6635) 2021-12-10 15:53:08 -05:00
check.go Fix `linkerd mc check` failing in the presence of lots of mirrored services (#10893) 2023-05-18 09:18:08 -05:00
gateways.go Add -o json flag for linkerd multicluster gateways (#10773) 2023-05-01 16:20:48 -07:00
install.go Remove admin policy resources from extensions (#10073) 2023-01-10 12:47:22 -08:00
install_test.go test: Diff structured YAML when possible (#8432) 2022-05-10 08:40:29 -07:00
link.go Add log-format value to the multicluster-link helm chart (#10779) 2023-06-08 05:10:48 -05:00
link_test.go Add unit test for `linkerd multicluster link` command (#8757) 2022-06-29 10:01:31 -06:00
main_test.go Add tests of multicluster install command (#7111) 2021-10-20 15:11:12 -07:00
root.go Remove `linkerd mc prune` (#10707) 2023-04-10 11:30:49 -07:00
uninstall.go Add support for legacy names in extension uninstall (#6226) 2021-06-08 20:18:52 +05:30
unlink.go Add leader election to the service-mirror controller (#11046) 2023-06-29 11:27:40 +01:00