Skip to content

Commit e874bc4

Browse files
authored
Merge pull request #876 from openziti/jitter-refreshes
Add a jitter config, which will default to 0.1, for session and service refreshes. Fixes #832
2 parents 8c3062b + a0590e3 commit e874bc4

File tree

10 files changed

+133
-49
lines changed

10 files changed

+133
-49
lines changed

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
# Release notes 1.5.0
22

3+
## Notes
4+
5+
Session and service refresh timers now include configurable jitter to avoid thundering-herd load spikes on the
6+
controller. A new `RefreshJitter` field on `Options` controls the amount of randomization applied to refresh
7+
intervals. It is a fraction (0.0–0.5) representing the ±percentage of the configured interval. The default
8+
value is 0.1 (±10%), and the maximum allowed value is 0.5 (±50%).
9+
10+
For example, with the default 5-minute service refresh interval and 0.1 jitter, each refresh will fire at a
11+
random time between 4m30s and 5m30s. Internally, fixed-interval tickers have been replaced with per-cycle
12+
randomized timers, so each refresh cycle gets a newly randomized delay.
13+
314
## Issues Fixed and Dependency Updates
415

516
* github.com/openziti/sdk-golang: [v1.4.2 -> v1.5.0](https://github.com/openziti/sdk-golang/compare/v1.4.2...v1.5.0)
17+
* [Issue #832](https://github.com/openziti/sdk-golang/issues/832) - Fuzz session refresh timers
618
* [Issue #879](https://github.com/openziti/sdk-golang/issues/879) - Return the connId in inspect response
719
* [Issue #878](https://github.com/openziti/sdk-golang/issues/878) - Fix responses from rx goroutines
820
* [Issue #874](https://github.com/openziti/sdk-golang/issues/874) - Add inspect support at the context level
921
* [Issue #871](https://github.com/openziti/sdk-golang/issues/871) - Make SDK better at sticking to MaxTerminator terminators
1022

23+
* github.com/go-resty/resty/v2: v2.17.1 -> v2.17.2
24+
* github.com/openziti/channel/v4: [v4.3.2 -> v4.3.6](https://github.com/openziti/channel/compare/v4.3.2...v4.3.6)
25+
* [Issue #228](https://github.com/openziti/channel/issues/228) - Ensure that Underlay never return nil on MultiChannel
26+
* [Issue #226](https://github.com/openziti/channel/issues/226) - Allow specifying a minimum number of underlays for a channel, regardless of underlay type
27+
28+
* github.com/openziti/edge-api: [v0.26.52 -> v0.26.56](https://github.com/openziti/edge-api/compare/v0.26.52...v0.26.56)
29+
* [Issue #170](https://github.com/openziti/edge-api/issues/170) - Add preferredLeader flag to controllers
30+
* [Issue #167](https://github.com/openziti/edge-api/issues/167) - Add ctrlChanListeners to router types
31+
32+
* github.com/openziti/foundation/v2: [v2.0.86 -> v2.0.87](https://github.com/openziti/foundation/compare/v2.0.86...v2.0.87)
33+
* github.com/openziti/identity: [v1.0.124 -> v1.0.125](https://github.com/openziti/identity/compare/v1.0.124...v1.0.125)
34+
* github.com/openziti/transport/v2: [v2.0.208 -> v2.0.209](https://github.com/openziti/transport/compare/v2.0.208...v2.0.209)
35+
1136
# Release notes 1.4.2
1237

1338
This release exposes internal OIDC responses for structures for testing purposes.

example/go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ require (
1010
github.com/google/uuid v1.6.0
1111
github.com/gorilla/mux v1.8.1
1212
github.com/michaelquigley/pfxlog v0.6.10
13-
github.com/openziti/edge-api v0.26.52
14-
github.com/openziti/foundation/v2 v2.0.86
13+
github.com/openziti/edge-api v0.26.56
14+
github.com/openziti/foundation/v2 v2.0.87
1515
github.com/openziti/runzmd v1.0.83
1616
github.com/openziti/sdk-golang v1.2.6
17-
github.com/openziti/transport/v2 v2.0.208
17+
github.com/openziti/transport/v2 v2.0.209
1818
github.com/pkg/errors v0.9.1
1919
github.com/sirupsen/logrus v1.9.4
2020
github.com/spf13/cobra v1.10.2
@@ -64,7 +64,7 @@ require (
6464
github.com/go-openapi/swag/typeutils v0.25.1 // indirect
6565
github.com/go-openapi/swag/yamlutils v0.25.1 // indirect
6666
github.com/go-openapi/validate v0.25.1 // indirect
67-
github.com/go-resty/resty/v2 v2.17.1 // indirect
67+
github.com/go-resty/resty/v2 v2.17.2 // indirect
6868
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
6969
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
7070
github.com/golang/protobuf v1.5.4 // indirect
@@ -87,9 +87,9 @@ require (
8787
github.com/mitchellh/mapstructure v1.5.0 // indirect
8888
github.com/muhlemmer/gu v0.3.1 // indirect
8989
github.com/oklog/ulid v1.3.1 // indirect
90-
github.com/openziti/channel/v4 v4.3.2 // indirect
90+
github.com/openziti/channel/v4 v4.3.6 // indirect
9191
github.com/openziti/go-term-markdown v1.0.1 // indirect
92-
github.com/openziti/identity v1.0.124 // indirect
92+
github.com/openziti/identity v1.0.125 // indirect
9393
github.com/openziti/metrics v1.4.3 // indirect
9494
github.com/openziti/secretstream v0.1.47 // indirect
9595
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect

example/go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6
169169
github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
170170
github.com/go-openapi/validate v0.25.1 h1:sSACUI6Jcnbo5IWqbYHgjibrhhmt3vR6lCzKZnmAgBw=
171171
github.com/go-openapi/validate v0.25.1/go.mod h1:RMVyVFYte0gbSTaZ0N4KmTn6u/kClvAFp+mAVfS/DQc=
172-
github.com/go-resty/resty/v2 v2.17.1 h1:x3aMpHK1YM9e4va/TMDRlusDDoZiQ+ViDu/WpA6xTM4=
173-
github.com/go-resty/resty/v2 v2.17.1/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
172+
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
173+
github.com/go-resty/resty/v2 v2.17.2/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
174174
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
175175
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
176176
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
@@ -370,24 +370,24 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
370370
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
371371
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
372372
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
373-
github.com/openziti/channel/v4 v4.3.2 h1:e3LKw7C2hPIVHtSMGhqgXqmhH4uz9hcbCIvj82Sc7jw=
374-
github.com/openziti/channel/v4 v4.3.2/go.mod h1:OWDEE5BjC01tAhEOut3cmfw2n5zce1YLiFOde97RokE=
375-
github.com/openziti/edge-api v0.26.52 h1:QIOcHWLDUV4pjZFRD0AbUfBM39HqOFz7lQWcQ982o8E=
376-
github.com/openziti/edge-api v0.26.52/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
377-
github.com/openziti/foundation/v2 v2.0.86 h1:r4F1jsi8UFmeHmI4v6JC/hncPPjGxGEumOZRrE4Oey0=
378-
github.com/openziti/foundation/v2 v2.0.86/go.mod h1:LrE/z8YXQUbwfyGwg3HgFs9ElGOq/T61EXbkagkDozQ=
373+
github.com/openziti/channel/v4 v4.3.6 h1:WvkDuYkoDOKJM5q4uAUcHNJ6XhOl7kmbZBn5YVWWwMI=
374+
github.com/openziti/channel/v4 v4.3.6/go.mod h1:N0y43HqOpLqMr545Dt3g62tNy07g65UylmnwVs+c4JM=
375+
github.com/openziti/edge-api v0.26.56 h1:8n9o3rgi3Mkyy2D45zIDad2N2ah3KJEUaae3rMhZyoI=
376+
github.com/openziti/edge-api v0.26.56/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
377+
github.com/openziti/foundation/v2 v2.0.87 h1:tD1Lba3C/MfBmDnLSmlyKB8hxjry4HAaNrdJqN+fqxQ=
378+
github.com/openziti/foundation/v2 v2.0.87/go.mod h1:LrE/z8YXQUbwfyGwg3HgFs9ElGOq/T61EXbkagkDozQ=
379379
github.com/openziti/go-term-markdown v1.0.1 h1:9uzMpK4tav6OtvRxRt99WwPTzAzCh+Pj9zWU2FBp3Qg=
380380
github.com/openziti/go-term-markdown v1.0.1/go.mod h1:aIhR12zlROVqr7x51DtBALaQZQ3FofBuKDWqCfaz3oo=
381-
github.com/openziti/identity v1.0.124 h1:cPUJeoz33vtpSU5eoKm0+vlz+8FOsxxjbdH5xEwk500=
382-
github.com/openziti/identity v1.0.124/go.mod h1:rOC47MGGa+tfqd0DAO6FrL3iTpFtOLz29Jsit5rDrPw=
381+
github.com/openziti/identity v1.0.125 h1:vrtasPXwQHpHYDhdtzCEMcMMIIx794LiC3P+Bh2Lm3Y=
382+
github.com/openziti/identity v1.0.125/go.mod h1:UC62KTzk2TbWievxrO5SFCDkjCmzPwZd1wmnpHmkW6w=
383383
github.com/openziti/metrics v1.4.3 h1:KUlhHtTH1rt2Ry59xDMlXIwNwkSnoJbqHWoflKlqvl4=
384384
github.com/openziti/metrics v1.4.3/go.mod h1:MOLcoTxhPNla6+NWUCMVTnl1PNqTU40qrbKVa/lVVgg=
385385
github.com/openziti/runzmd v1.0.83 h1:T8S7rD222c5neh1v2gDsP7J8OFYkhxmjCeMWkWpxUbw=
386386
github.com/openziti/runzmd v1.0.83/go.mod h1:oPFspRH9aJ63v4hHlQOghD3vafK6BD928LKlc3+/SFk=
387387
github.com/openziti/secretstream v0.1.47 h1:pAarwAXSbboSBJ9RBs08501LW2DDFxfYfw0gC7LBU84=
388388
github.com/openziti/secretstream v0.1.47/go.mod h1:NnG3IC546Jk8fqYFWIMaAtznsIrNWengrnK+aOMNFZU=
389-
github.com/openziti/transport/v2 v2.0.208 h1:xvCJnKJD2MQlPrcb3chwGUUYyvtZUvwKcKlZLnlkqz0=
390-
github.com/openziti/transport/v2 v2.0.208/go.mod h1:pY84V3bOMoauTjUhxm4097SCsydxFk1xH1/junrcrok=
389+
github.com/openziti/transport/v2 v2.0.209 h1:hq2qlFesYRSQw55zB/hupsGrpvwBq0tbUA8aTd8Si70=
390+
github.com/openziti/transport/v2 v2.0.209/go.mod h1:/v6P+ZWkJ88Q74irQtz1ox8xqhy5KY56+V6ucX8ZcY0=
391391
github.com/orcaman/concurrent-map/v2 v2.0.1 h1:jOJ5Pg2w1oeB6PeDurIYf6k9PQ+aTITr/6lP/L/zp6c=
392392
github.com/orcaman/concurrent-map/v2 v2.0.1/go.mod h1:9Eq3TG2oBe5FirmYWQfYO5iH1q0Jv47PLaNK++uCdOM=
393393
github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 h1:mOvehYivJ4Aqu2CPe3D3lv8jhqOI9/1o0THxJHBE0qw=

example/influxdb-client-go/go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ require (
6161
github.com/go-playground/locales v0.14.1 // indirect
6262
github.com/go-playground/universal-translator v0.18.1 // indirect
6363
github.com/go-playground/validator/v10 v10.15.4 // indirect
64-
github.com/go-resty/resty/v2 v2.17.1 // indirect
64+
github.com/go-resty/resty/v2 v2.17.2 // indirect
6565
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
6666
github.com/goccy/go-json v0.10.2 // indirect
6767
github.com/golang-jwt/jwt/v5 v5.3.1 // indirect
@@ -103,13 +103,13 @@ require (
103103
github.com/modern-go/reflect2 v1.0.2 // indirect
104104
github.com/muhlemmer/gu v0.3.1 // indirect
105105
github.com/oklog/ulid v1.3.1 // indirect
106-
github.com/openziti/channel/v4 v4.3.2 // indirect
107-
github.com/openziti/edge-api v0.26.52 // indirect
108-
github.com/openziti/foundation/v2 v2.0.86 // indirect
109-
github.com/openziti/identity v1.0.124 // indirect
106+
github.com/openziti/channel/v4 v4.3.6 // indirect
107+
github.com/openziti/edge-api v0.26.56 // indirect
108+
github.com/openziti/foundation/v2 v2.0.87 // indirect
109+
github.com/openziti/identity v1.0.125 // indirect
110110
github.com/openziti/metrics v1.4.3 // indirect
111111
github.com/openziti/secretstream v0.1.47 // indirect
112-
github.com/openziti/transport/v2 v2.0.208 // indirect
112+
github.com/openziti/transport/v2 v2.0.209 // indirect
113113
github.com/orcaman/concurrent-map/v2 v2.0.1 // indirect
114114
github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 // indirect
115115
github.com/pelletier/go-toml/v2 v2.1.0 // indirect

example/influxdb-client-go/go.sum

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
200200
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
201201
github.com/go-playground/validator/v10 v10.15.4 h1:zMXza4EpOdooxPel5xDqXEdXG5r+WggpvnAKMsalBjs=
202202
github.com/go-playground/validator/v10 v10.15.4/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU=
203-
github.com/go-resty/resty/v2 v2.17.1 h1:x3aMpHK1YM9e4va/TMDRlusDDoZiQ+ViDu/WpA6xTM4=
204-
github.com/go-resty/resty/v2 v2.17.1/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
203+
github.com/go-resty/resty/v2 v2.17.2 h1:FQW5oHYcIlkCNrMD2lloGScxcHJ0gkjshV3qcQAyHQk=
204+
github.com/go-resty/resty/v2 v2.17.2/go.mod h1:kCKZ3wWmwJaNc7S29BRtUhJwy7iqmn+2mLtQrOyQlVA=
205205
github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs=
206206
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
207207
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
@@ -446,20 +446,20 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
446446
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
447447
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
448448
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
449-
github.com/openziti/channel/v4 v4.3.2 h1:e3LKw7C2hPIVHtSMGhqgXqmhH4uz9hcbCIvj82Sc7jw=
450-
github.com/openziti/channel/v4 v4.3.2/go.mod h1:OWDEE5BjC01tAhEOut3cmfw2n5zce1YLiFOde97RokE=
451-
github.com/openziti/edge-api v0.26.52 h1:QIOcHWLDUV4pjZFRD0AbUfBM39HqOFz7lQWcQ982o8E=
452-
github.com/openziti/edge-api v0.26.52/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
453-
github.com/openziti/foundation/v2 v2.0.86 h1:r4F1jsi8UFmeHmI4v6JC/hncPPjGxGEumOZRrE4Oey0=
454-
github.com/openziti/foundation/v2 v2.0.86/go.mod h1:LrE/z8YXQUbwfyGwg3HgFs9ElGOq/T61EXbkagkDozQ=
455-
github.com/openziti/identity v1.0.124 h1:cPUJeoz33vtpSU5eoKm0+vlz+8FOsxxjbdH5xEwk500=
456-
github.com/openziti/identity v1.0.124/go.mod h1:rOC47MGGa+tfqd0DAO6FrL3iTpFtOLz29Jsit5rDrPw=
449+
github.com/openziti/channel/v4 v4.3.6 h1:WvkDuYkoDOKJM5q4uAUcHNJ6XhOl7kmbZBn5YVWWwMI=
450+
github.com/openziti/channel/v4 v4.3.6/go.mod h1:N0y43HqOpLqMr545Dt3g62tNy07g65UylmnwVs+c4JM=
451+
github.com/openziti/edge-api v0.26.56 h1:8n9o3rgi3Mkyy2D45zIDad2N2ah3KJEUaae3rMhZyoI=
452+
github.com/openziti/edge-api v0.26.56/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
453+
github.com/openziti/foundation/v2 v2.0.87 h1:tD1Lba3C/MfBmDnLSmlyKB8hxjry4HAaNrdJqN+fqxQ=
454+
github.com/openziti/foundation/v2 v2.0.87/go.mod h1:LrE/z8YXQUbwfyGwg3HgFs9ElGOq/T61EXbkagkDozQ=
455+
github.com/openziti/identity v1.0.125 h1:vrtasPXwQHpHYDhdtzCEMcMMIIx794LiC3P+Bh2Lm3Y=
456+
github.com/openziti/identity v1.0.125/go.mod h1:UC62KTzk2TbWievxrO5SFCDkjCmzPwZd1wmnpHmkW6w=
457457
github.com/openziti/metrics v1.4.3 h1:KUlhHtTH1rt2Ry59xDMlXIwNwkSnoJbqHWoflKlqvl4=
458458
github.com/openziti/metrics v1.4.3/go.mod h1:MOLcoTxhPNla6+NWUCMVTnl1PNqTU40qrbKVa/lVVgg=
459459
github.com/openziti/secretstream v0.1.47 h1:pAarwAXSbboSBJ9RBs08501LW2DDFxfYfw0gC7LBU84=
460460
github.com/openziti/secretstream v0.1.47/go.mod h1:NnG3IC546Jk8fqYFWIMaAtznsIrNWengrnK+aOMNFZU=
461-
github.com/openziti/transport/v2 v2.0.208 h1:xvCJnKJD2MQlPrcb3chwGUUYyvtZUvwKcKlZLnlkqz0=
462-
github.com/openziti/transport/v2 v2.0.208/go.mod h1:pY84V3bOMoauTjUhxm4097SCsydxFk1xH1/junrcrok=
461+
github.com/openziti/transport/v2 v2.0.209 h1:hq2qlFesYRSQw55zB/hupsGrpvwBq0tbUA8aTd8Si70=
462+
github.com/openziti/transport/v2 v2.0.209/go.mod h1:/v6P+ZWkJ88Q74irQtz1ox8xqhy5KY56+V6ucX8ZcY0=
463463
github.com/orcaman/concurrent-map/v2 v2.0.1 h1:jOJ5Pg2w1oeB6PeDurIYf6k9PQ+aTITr/6lP/L/zp6c=
464464
github.com/orcaman/concurrent-map/v2 v2.0.1/go.mod h1:9Eq3TG2oBe5FirmYWQfYO5iH1q0Jv47PLaNK++uCdOM=
465465
github.com/parallaxsecond/parsec-client-go v0.0.0-20221025095442-f0a77d263cf9 h1:mOvehYivJ4Aqu2CPe3D3lv8jhqOI9/1o0THxJHBE0qw=

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ require (
1616
github.com/michaelquigley/pfxlog v0.6.10
1717
github.com/mitchellh/go-ps v1.0.0
1818
github.com/mitchellh/mapstructure v1.5.0
19-
github.com/openziti/channel/v4 v4.3.5
20-
github.com/openziti/edge-api v0.26.53
19+
github.com/openziti/channel/v4 v4.3.6
20+
github.com/openziti/edge-api v0.26.56
2121
github.com/openziti/foundation/v2 v2.0.87
2222
github.com/openziti/identity v1.0.125
2323
github.com/openziti/metrics v1.4.3

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
327327
github.com/onsi/gomega v1.10.5/go.mod h1:gza4q3jKQJijlu05nKWRCW/GavJumGt8aNRxWg7mt48=
328328
github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak=
329329
github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY=
330-
github.com/openziti/channel/v4 v4.3.5 h1:bF/JpxWTREVpoRwgGx5YbD7FAkZlvH0ZzzcYS9h1o8o=
331-
github.com/openziti/channel/v4 v4.3.5/go.mod h1:N0y43HqOpLqMr545Dt3g62tNy07g65UylmnwVs+c4JM=
332-
github.com/openziti/edge-api v0.26.53 h1:5KpaKIjF9mnOW8cWCHO6ljQ/te3ANVp20KoudRJZGAQ=
333-
github.com/openziti/edge-api v0.26.53/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
330+
github.com/openziti/channel/v4 v4.3.6 h1:WvkDuYkoDOKJM5q4uAUcHNJ6XhOl7kmbZBn5YVWWwMI=
331+
github.com/openziti/channel/v4 v4.3.6/go.mod h1:N0y43HqOpLqMr545Dt3g62tNy07g65UylmnwVs+c4JM=
332+
github.com/openziti/edge-api v0.26.56 h1:8n9o3rgi3Mkyy2D45zIDad2N2ah3KJEUaae3rMhZyoI=
333+
github.com/openziti/edge-api v0.26.56/go.mod h1:Sj8HEql6ol2Oqp0yd3ZbGayCg8t/XTlH7q608UDHrwE=
334334
github.com/openziti/foundation/v2 v2.0.87 h1:tD1Lba3C/MfBmDnLSmlyKB8hxjry4HAaNrdJqN+fqxQ=
335335
github.com/openziti/foundation/v2 v2.0.87/go.mod h1:LrE/z8YXQUbwfyGwg3HgFs9ElGOq/T61EXbkagkDozQ=
336336
github.com/openziti/identity v1.0.125 h1:vrtasPXwQHpHYDhdtzCEMcMMIIx794LiC3P+Bh2Lm3Y=

ziti/options.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package ziti
22

33
import (
4-
"github.com/openziti/edge-api/rest_model"
54
"time"
5+
6+
"github.com/openziti/edge-api/rest_model"
67
)
78

89
type ServiceEventType string
@@ -15,6 +16,7 @@ const (
1516
DefaultServiceRefreshInterval = 5 * time.Minute
1617
DefaultSessionRefreshInterval = time.Hour
1718
MinRefreshInterval = time.Second
19+
DefaultRefreshJitter = 0.1
1820
)
1921

2022
type serviceCB func(eventType ServiceEventType, service *rest_model.ServiceDetail)
@@ -29,6 +31,11 @@ type Options struct {
2931
// May not be less than 1 second
3032
SessionRefreshInterval time.Duration
3133

34+
// RefreshJitter is a fraction (0.0–0.5) representing ±percentage of the refresh interval
35+
// to randomize. For example, 0.1 means each refresh will fire at a random time within ±10%
36+
// of the configured interval, helping avoid thundering-herd load spikes on the controller.
37+
RefreshJitter float64
38+
3239
// Deprecated: OnContextReady is a callback that is invoked after the first successful authentication request. It
3340
// does not delineate between fully and partially authenticated API Sessions. Use context.AddListener() with the events
3441
// EventAuthenticationStateFull, EventAuthenticationStatePartial, EventAuthenticationStateUnAuthenticated instead.
@@ -47,6 +54,7 @@ func (self *Options) isEdgeRouterUrlAccepted(url string) bool {
4754
var DefaultOptions = &Options{
4855
RefreshInterval: DefaultServiceRefreshInterval,
4956
SessionRefreshInterval: DefaultSessionRefreshInterval,
57+
RefreshJitter: DefaultRefreshJitter,
5058
OnServiceUpdate: nil,
5159
}
5260

ziti/ziti.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,15 @@ func (context *ContextImpl) updateTokenOnAllErs(apiSession apis.ApiSession) erro
918918
return errors.Join(routerErrors...)
919919
}
920920

921+
func jitteredDuration(base time.Duration, jitter float64) time.Duration {
922+
if jitter <= 0 {
923+
return base
924+
}
925+
delta := float64(base) * jitter
926+
minD := float64(base) - delta
927+
return time.Duration(minD + rand.Float64()*2*delta)
928+
}
929+
921930
func (context *ContextImpl) runRefreshes() {
922931
log := pfxlog.Logger()
923932
svcRefreshInterval := context.options.RefreshInterval
@@ -928,8 +937,6 @@ func (context *ContextImpl) runRefreshes() {
928937
if svcRefreshInterval < MinRefreshInterval {
929938
svcRefreshInterval = MinRefreshInterval
930939
}
931-
svcRefreshTick := time.NewTicker(svcRefreshInterval)
932-
defer svcRefreshTick.Stop()
933940

934941
sessionRefreshInterval := context.options.SessionRefreshInterval
935942
if sessionRefreshInterval == 0 {
@@ -939,8 +946,10 @@ func (context *ContextImpl) runRefreshes() {
939946
sessionRefreshInterval = MinRefreshInterval
940947
}
941948

942-
sessionRefreshTick := time.NewTicker(sessionRefreshInterval)
943-
defer sessionRefreshTick.Stop()
949+
jitter := min(context.options.RefreshJitter, 0.5)
950+
951+
svcRefreshTimer := time.After(jitteredDuration(svcRefreshInterval, jitter))
952+
sessionRefreshTimer := time.After(jitteredDuration(sessionRefreshInterval, jitter))
944953

945954
refreshAt := time.Now().Add(30 * time.Second)
946955

@@ -983,15 +992,17 @@ func (context *ContextImpl) runRefreshes() {
983992
}
984993
}
985994

986-
case <-svcRefreshTick.C:
995+
case <-svcRefreshTimer:
987996
log.Debug("refreshing services")
988997
if err := context.refreshServices(false, false); err != nil {
989998
log.WithError(err).Error("failed to load service updates")
990999
}
1000+
svcRefreshTimer = time.After(jitteredDuration(svcRefreshInterval, jitter))
9911001

992-
case <-sessionRefreshTick.C:
1002+
case <-sessionRefreshTimer:
9931003
log.Debug("refreshing sessions")
9941004
context.refreshSessions()
1005+
sessionRefreshTimer = time.After(jitteredDuration(sessionRefreshInterval, jitter))
9951006
}
9961007
}
9971008
}

0 commit comments

Comments
 (0)