Skip to content

Commit

Permalink
chore(kuma-cp) change default flush intervals (#1237) (#1251)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
(cherry picked from commit 47b8752)

Co-authored-by: Jakub Dyszkiewicz <jakub.dyszkiewicz@gmail.com>
  • Loading branch information
mergify[bot] and jakubdyszkiewicz authored Dec 1, 2020
1 parent e7bdfca commit 2dce318
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
3 changes: 2 additions & 1 deletion pkg/api-server/config_ws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ var _ = Describe("Config WS", func() {
"kds": {
"grpcPort": 5685,
"refreshInterval": "1s",
"zoneInsightFlushInterval": "10s",
"tlsCertFile": "",
"tlsKeyFile": ""
}
Expand Down Expand Up @@ -247,7 +248,7 @@ var _ = Describe("Config WS", func() {
},
"xdsServer": {
"dataplaneConfigurationRefreshInterval": "1s",
"dataplaneStatusFlushInterval": "1s"
"dataplaneStatusFlushInterval": "10s"
},
"diagnostics": {
"serverPort": 5680,
Expand Down
4 changes: 3 additions & 1 deletion pkg/config/app/kuma-cp/kuma-cp.defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ xdsServer:
# Interval for re-genarting configuration for Dataplanes connected to the Control Plane
dataplaneConfigurationRefreshInterval: 1s # ENV: KUMA_XDS_SERVER_DATAPLANE_CONFIGURATION_REFRESH_INTERVAL
# Interval for flushing status of Dataplanes connected to the Control Plane
dataplaneStatusFlushInterval: 1s # ENV: KUMA_XDS_SERVER_DATAPLANE_STATUS_FLUSH_INTERVAL
dataplaneStatusFlushInterval: 10s # ENV: KUMA_XDS_SERVER_DATAPLANE_STATUS_FLUSH_INTERVAL

# API Server configuration
apiServer:
Expand Down Expand Up @@ -298,6 +298,8 @@ multizone:
grpcPort: 5685 # ENV: KUMA_MULTIZONE_GLOBAL_KDS_GRPC_PORT
# Interval for refreshing state of the world
refreshInterval: 1s # ENV: KUMA_MULTIZONE_GLOBAL_KDS_REFRESH_INTERVAL
# Interval for flushing Zone Insights (stats of multi-zone communication)
zoneInsightFlushInterval: 10s # ENV: KUMA_MULTIZONE_GLOBAL_KDS_ZONE_INSIGHT_FLUSH_INTERVAL
# TlsCertFile defines a path to a file with PEM-encoded TLS cert.
tlsCertFile: # ENV: KUMA_MULTIZONE_GLOBAL_KDS_TLS_CERT_FILE
# TTlsKeyFile defines a path to a file with PEM-encoded TLS key.
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ var _ = Describe("Config loader", func() {
Expect(cfg.Multizone.Global.PollTimeout).To(Equal(750 * time.Millisecond))
Expect(cfg.Multizone.Global.KDS.GrpcPort).To(Equal(uint32(1234)))
Expect(cfg.Multizone.Global.KDS.RefreshInterval).To(Equal(time.Second * 2))
Expect(cfg.Multizone.Global.KDS.ZoneInsightFlushInterval).To(Equal(time.Second * 5))
Expect(cfg.Multizone.Global.KDS.TlsCertFile).To(Equal("/cert"))
Expect(cfg.Multizone.Global.KDS.TlsKeyFile).To(Equal("/key"))
Expect(cfg.Multizone.Remote.GlobalAddress).To(Equal("grpc://1.1.1.1:5685"))
Expand Down Expand Up @@ -337,6 +338,7 @@ multizone:
kds:
grpcPort: 1234
refreshInterval: 2s
zoneInsightFlushInterval: 5s
tlsCertFile: /cert
tlsKeyFile: /key
remote:
Expand Down Expand Up @@ -469,6 +471,7 @@ sdsServer:
"KUMA_MULTIZONE_REMOTE_ZONE": "zone-1",
"KUMA_MULTIZONE_REMOTE_KDS_ROOT_CA_FILE": "/rootCa",
"KUMA_MULTIZONE_REMOTE_KDS_REFRESH_INTERVAL": "9s",
"KUMA_MULTIZONE_GLOBAL_KDS_ZONE_INSIGHT_FLUSH_INTERVAL": "5s",
"KUMA_DEFAULTS_SKIP_MESH_CREATION": "true",
"KUMA_DIAGNOSTICS_SERVER_PORT": "5003",
"KUMA_DIAGNOSTICS_DEBUG_ENDPOINTS": "true",
Expand Down
5 changes: 5 additions & 0 deletions pkg/config/multizone/kds.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type KdsServerConfig struct {
GrpcPort uint32 `yaml:"grpcPort" envconfig:"kuma_multizone_global_kds_grpc_port"`
// Interval for refreshing state of the world
RefreshInterval time.Duration `yaml:"refreshInterval" envconfig:"kuma_multizone_global_kds_refresh_interval"`
// Interval for flushing Zone Insights (stats of multi-zone communication)
ZoneInsightFlushInterval time.Duration `yaml:"zoneInsightFlushInterval" envconfig:"kuma_multizone_global_kds_zone_insight_flush_interval"`
// TlsCertFile defines a path to a file with PEM-encoded TLS cert.
TlsCertFile string `yaml:"tlsCertFile" envconfig:"kuma_multizone_global_kds_tls_cert_file"`
// TlsKeyFile defines a path to a file with PEM-encoded TLS key.
Expand All @@ -32,6 +34,9 @@ func (c *KdsServerConfig) Validate() (errs error) {
if c.RefreshInterval <= 0 {
return errors.New(".RefreshInterval must be positive")
}
if c.ZoneInsightFlushInterval <= 0 {
return errors.New(".ZoneInsightFlushInterval must be positive")
}
if c.TlsCertFile == "" && c.TlsKeyFile != "" {
return errors.New("TlsCertFile cannot be empty if TlsKeyFile has been set")
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/config/multizone/multicluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ func DefaultGlobalConfig() *GlobalConfig {
return &GlobalConfig{
PollTimeout: 500 * time.Millisecond,
KDS: &KdsServerConfig{
GrpcPort: 5685,
RefreshInterval: 1 * time.Second,
GrpcPort: 5685,
RefreshInterval: 1 * time.Second,
ZoneInsightFlushInterval: 10 * time.Second,
},
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/xds/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func (x *XdsServerConfig) Validate() error {
func DefaultXdsServerConfig() *XdsServerConfig {
return &XdsServerConfig{
DataplaneConfigurationRefreshInterval: 1 * time.Second,
DataplaneStatusFlushInterval: 1 * time.Second,
DataplaneStatusFlushInterval: 10 * time.Second,
}
}
2 changes: 1 addition & 1 deletion pkg/config/xds/testdata/default-config.golden.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dataplaneConfigurationRefreshInterval: 1s
dataplaneStatusFlushInterval: 1s
dataplaneStatusFlushInterval: 10s
2 changes: 1 addition & 1 deletion pkg/kds/server/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func DefaultStatusTracker(rt core_runtime.Runtime, log logr.Logger) StatusTracke
return NewZoneInsightSink(
accessor,
func() *time.Ticker {
return time.NewTicker(1 * time.Second)
return time.NewTicker(rt.Config().Multizone.Global.KDS.ZoneInsightFlushInterval)
},
NewDataplaneInsightStore(rt.ResourceManager()),
l)
Expand Down

0 comments on commit 2dce318

Please sign in to comment.