For #35 we're going to need to pull of from the election if the local Prometheus instance isn't healthy. Sadlly the k8s leader election API doesn't allow to easily start and stop.
As a consequence this PR introduces our own Elector abstraction, that can be started and stopped.
It is also a tad cleaner than the existing setup.
Relates to: #35
How to Test This PR?
As for now I tried it by patching main.go and introducing this logic after the elector has initially started. It behaves as expected.
for {
time.Sleep(30 * time.Second)
klog.Info("HAHAHA LEAVING ELECTION BECAUSE WHY NOT")
klog.Info(elector.Stop(grpCtx))
time.Sleep(30 * time.Second)
klog.Info("OKAY I'M BACK IN THE RACE")
klog.Info(elector.Start(grpCtx))
}
I'll also introduce a unit test suite for the election package.
What Does This PR do?
For #35 we're going to need to pull of from the election if the local Prometheus instance isn't healthy. Sadlly the k8s leader election API doesn't allow to easily start and stop.
As a consequence this PR introduces our own
Elector
abstraction, that can be started and stopped.It is also a tad cleaner than the existing setup.
Relates to: #35
How to Test This PR?
As for now I tried it by patching
main.go
and introducing this logic after the elector has initially started. It behaves as expected.I'll also introduce a unit test suite for the election package.
Good PR Checklist
Additional Notes