Skip to content

Commit e436108

Browse files
Default watchers resyncPeriod to 0 to disable it.
Using the default 0 duration period should instruct the watchers to avoid re-listing from cache and getting onUpdate calls. We should not need this, since our reconcile logic is retrying if an event fails to update wg peers and never lets go. kubernetes-sigs/controller-runtime#521 (comment) If a watcher fails to connect to apiservers for a while it should be able to sync when is back online and create sufficient events to sync our peers again: https://kubernetes.io/docs/reference/using-api/api-concepts/#efficient-detection-of-changes
1 parent d818e16 commit e436108

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Is a list of remote clusters that may define the following:
6262

6363
- wgListenPort: WG listen port.
6464

65+
- resyncPeriod: Kubernetes watcher resync period. It should yield update events
66+
for everything that is stored in the cache. Default `0` value disables it.
6567
## Example
6668
```
6769
{

config.go

-8
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
4141
}
4242
}
4343

44-
var (
45-
defaultWatcherResyncPeriod = Duration{time.Hour}
46-
zeroDuration = Duration{0}
47-
)
48-
4944
type localClusterConfig struct {
5045
Name string `json:"name"`
5146
KubeConfigPath string `json:"kubeConfigPath"`
@@ -97,9 +92,6 @@ func parseConfig(rawConfig []byte) (*Config, error) {
9792
if r.WGListenPort == 0 {
9893
r.WGListenPort = defaultWGListenPort
9994
}
100-
if r.ResyncPeriod == zeroDuration {
101-
r.ResyncPeriod = defaultWatcherResyncPeriod
102-
}
10395
}
10496
return conf, nil
10597
}

config_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,6 @@ func TestConfig(t *testing.T) {
109109
assert.Equal(t, "10.0.1.0/16", config.Remotes[1].PodSubnet)
110110
assert.Equal(t, defaultWGDeviceMTU, config.Remotes[1].WGDeviceMTU)
111111
assert.Equal(t, defaultWGListenPort, config.Remotes[1].WGListenPort)
112-
assert.Equal(t, defaultWatcherResyncPeriod, config.Remotes[1].ResyncPeriod)
112+
assert.Equal(t, Duration{0}, config.Remotes[1].ResyncPeriod)
113113

114114
}

0 commit comments

Comments
 (0)