Skip to content

Commit 9d96060

Browse files
committed
Address feedback.
1 parent 002e3d8 commit 9d96060

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

designs/warmreplicas.md

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Add support for warm replicas
33

44
## Motivation
55
Controllers reconcile all objects during startup / leader election failover to account for changes
6-
in the reconciliation logic. For certain sources, the time to serve the initial list can be
6+
in the reconciliation logic. For certain sources, the time to do the cache sync can be
77
significant in the order of minutes. This is problematic because by default controllers (and by
88
extension watches) do not start until they have won leader election. This implies guaranteed
99
downtime as even after leader election, the controller has to wait for the initial list to be served
@@ -35,8 +35,7 @@ and all controllers are leader election runnables by default.
3535
behavior when manager is not in leader mode. This interface should be as follows:
3636
```go
3737
type WarmupRunnable interface {
38-
NeedWarmup() bool
39-
GetWarmupRunnable() Runnable
38+
Warmup(context.Context) error
4039
}
4140
```
4241

@@ -65,29 +64,12 @@ func(rw runnableWrapper) Start(ctx context.Context) error {
6564
return rw.startFunc(ctx)
6665
}
6766

68-
// NeedWarmup implements WarmupRunnable
69-
func (c *Controller[request]) NeedWarmup() bool {
70-
if c.ShouldWarmupWithoutLeadership == nil {
71-
return false
67+
func (c *Controller[request]) Warmup(ctx context.Context) error {
68+
if !c.ShouldWarmupWithoutLeadership {
69+
return nil
7270
}
73-
return c.ShouldWarmupWithoutLeadership
74-
}
7571

76-
// GetWarmupRunnable implements WarmupRunnable
77-
func (c *Controller[request]) GetWarmupRunnable() Runnable {
78-
return runnableWrapper{
79-
startFunc: func (ctx context.Context) error {
80-
if !c.ShouldWarmupWithoutLeadership {
81-
return nil
82-
}
83-
84-
// pseudocode
85-
for _, watch := c.startWatches {
86-
watch.Start()
87-
// handle syncing sources
88-
}
89-
}
90-
}
72+
return c.startEventSources(ctx)
9173
}
9274
```
9375

@@ -107,12 +89,10 @@ func (r *runnables) Add(fn Runnable) error {
10789
switch runnable := fn.(type) {
10890
// ...
10991
case WarmupRunnable:
110-
if runnable.NeedWarmup() {
111-
r.Warmup.Add(runnable.GetWarmupRunnable(), nil)
112-
}
92+
r.Warmup.Add(RunnableFunc(fn.Warmup), nil)
11393

11494
// fallthrough to ensure that a runnable that implements both LeaderElection and
115-
// NonLeaderElection interfaces is added to both groups
95+
// Warmup interfaces are added to both groups
11696
fallthrough
11797
case LeaderElectionRunnable:
11898
if !runnable.NeedLeaderElection() {

0 commit comments

Comments
 (0)