diff --git a/charts/fsm/README.md b/charts/fsm/README.md index 24f8a8fba..5753f6277 100644 --- a/charts/fsm/README.md +++ b/charts/fsm/README.md @@ -446,6 +446,7 @@ The following table lists the configurable parameters of the fsm chart and their | fsm.sidecarDrivers[0].sidecarImage | string | `"flomesh/pipy:0.90.2-41"` | Sidecar image for Linux workloads | | fsm.sidecarImage | string | `""` | Sidecar image for Linux workloads | | fsm.sidecarLogLevel | string | `"error"` | Log level for the proxy sidecar. Non developers should generally never set this value. In production environments the LogLevel should be set to `error` | +| fsm.sidecarTimeout | int | `60` | Sets connect/idle/read/write timeout | | fsm.tracing.address | string | `""` | Address of the tracing collector service (must contain the namespace). When left empty, this is computed in helper template to "jaeger..svc.cluster.local". Please override for BYO-tracing as documented in tracing.md | | fsm.tracing.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].key | string | `"kubernetes.io/os"` | | | fsm.tracing.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms[0].matchExpressions[0].operator | string | `"In"` | | diff --git a/charts/fsm/templates/preset-mesh-config.yaml b/charts/fsm/templates/preset-mesh-config.yaml index 1a35dfa85..417f4683e 100644 --- a/charts/fsm/templates/preset-mesh-config.yaml +++ b/charts/fsm/templates/preset-mesh-config.yaml @@ -24,6 +24,7 @@ data: "sidecarClass": {{.Values.fsm.sidecarClass | mustToJson }}, "sidecarImage": {{.Values.fsm.sidecarImage | mustToJson }}, "sidecarDrivers": {{.Values.fsm.sidecarDrivers | mustToJson }}, + "sidecarTimeout": {{.Values.fsm.sidecarTimeout | mustToJson}}, "localProxyMode": {{.Values.fsm.localProxyMode | mustToJson}}, "localDNSProxy": {{.Values.fsm.localDNSProxy | mustToJson}} }, diff --git a/charts/fsm/values.schema.json b/charts/fsm/values.schema.json index 1f21868c8..9759b67c7 100644 --- a/charts/fsm/values.schema.json +++ b/charts/fsm/values.schema.json @@ -186,6 +186,7 @@ "meshName", "maxDataPlaneConnections", "sidecarLogLevel", + "sidecarTimeout", "controllerLogLevel", "enforceSingleMesh", "deployJaeger", @@ -1028,6 +1029,15 @@ "30s" ] }, + "sidecarTimeout": { + "$id": "#/properties/fsm/properties/sidecarTimeout", + "type": "integer", + "title": "The sidecarTimeout schema", + "description": "Sets connect/idle/read/write timeout", + "examples": [ + "60" + ] + }, "sidecarLogLevel": { "$id": "#/properties/fsm/properties/sidecarLogLevel", "type": "string", diff --git a/charts/fsm/values.yaml b/charts/fsm/values.yaml index 0df497f1d..2042387de 100644 --- a/charts/fsm/values.yaml +++ b/charts/fsm/values.yaml @@ -464,6 +464,9 @@ fsm: # -- Sets the resync interval for regular proxy broadcast updates, set to 0s to not enforce any resync configResyncInterval: "90s" + # -- Sets connect/idle/read/write timeout + sidecarTimeout: 60 + # -- Controller log verbosity controllerLogLevel: info diff --git a/cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml b/cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml index 6f8427f8a..854879732 100644 --- a/cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml +++ b/cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml @@ -358,6 +358,9 @@ spec: description: MaxDataPlaneConnections defines the maximum allowed data plane connections from a proxy sidecar to the FSM controller. type: integer + sidecarTimeout: + description: connect/idle/read/write timeout + type: integer resources: description: Resources defines the compute resources for the sidecar. properties: @@ -918,6 +921,9 @@ spec: description: MaxDataPlaneConnections defines the maximum allowed data plane connections from a proxy sidecar to the FSM controller. type: integer + sidecarTimeout: + description: connect/idle/read/write timeout + type: integer resources: description: Resources defines the compute resources for the sidecar. properties: @@ -1773,6 +1779,9 @@ spec: description: MaxDataPlaneConnections defines the maximum allowed data plane connections from a proxy sidecar to the FSM controller. type: integer + sidecarTimeout: + description: connect/idle/read/write timeout + type: integer resources: description: Resources defines the compute resources for the sidecar. properties: diff --git a/pkg/apis/config/v1alpha1/mesh_config.go b/pkg/apis/config/v1alpha1/mesh_config.go index fd2763928..a52fd6192 100644 --- a/pkg/apis/config/v1alpha1/mesh_config.go +++ b/pkg/apis/config/v1alpha1/mesh_config.go @@ -76,6 +76,9 @@ type SidecarSpec struct { // ConfigResyncInterval defines the resync interval for regular proxy broadcast updates. ConfigResyncInterval string `json:"configResyncInterval,omitempty"` + // SidecarTimeout defines the connect/idle/read/write timeout. + SidecarTimeout int `json:"sidecarTimeout,omitempty"` + // Resources defines the compute resources for the sidecar. Resources corev1.ResourceRequirements `json:"resources,omitempty"` } diff --git a/pkg/apis/config/v1alpha2/mesh_config.go b/pkg/apis/config/v1alpha2/mesh_config.go index f497fc56f..da7db0a1c 100644 --- a/pkg/apis/config/v1alpha2/mesh_config.go +++ b/pkg/apis/config/v1alpha2/mesh_config.go @@ -98,6 +98,9 @@ type SidecarSpec struct { // ConfigResyncInterval defines the resync interval for regular proxy broadcast updates. ConfigResyncInterval string `json:"configResyncInterval,omitempty"` + // SidecarTimeout defines the connect/idle/read/write timeout. + SidecarTimeout int `json:"sidecarTimeout,omitempty"` + // Resources defines the compute resources for the sidecar. Resources corev1.ResourceRequirements `json:"resources,omitempty"` diff --git a/pkg/apis/config/v1alpha3/mesh_config.go b/pkg/apis/config/v1alpha3/mesh_config.go index 3dfb18bc7..daf30c9b2 100644 --- a/pkg/apis/config/v1alpha3/mesh_config.go +++ b/pkg/apis/config/v1alpha3/mesh_config.go @@ -116,6 +116,9 @@ type SidecarSpec struct { // ConfigResyncInterval defines the resync interval for regular proxy broadcast updates. ConfigResyncInterval string `json:"configResyncInterval,omitempty"` + // SidecarTimeout defines the connect/idle/read/write timeout. + SidecarTimeout int `json:"sidecarTimeout,omitempty"` + // Resources defines the compute resources for the sidecar. Resources corev1.ResourceRequirements `json:"resources,omitempty"` diff --git a/pkg/configurator/methods.go b/pkg/configurator/methods.go index 957e028dc..3a10da28f 100644 --- a/pkg/configurator/methods.go +++ b/pkg/configurator/methods.go @@ -213,6 +213,15 @@ func (c *Client) GetMaxDataPlaneConnections() int { return c.getMeshConfig().Spec.Sidecar.MaxDataPlaneConnections } +// GetSidecarTimeout returns connect/idle/read/write timeout +func (c *Client) GetSidecarTimeout() int { + timeout := c.getMeshConfig().Spec.Sidecar.SidecarTimeout + if timeout <= 0 { + timeout = 60 + } + return timeout +} + // GetSidecarLogLevel returns the sidecar log level func (c *Client) GetSidecarLogLevel() string { logLevel := c.getMeshConfig().Spec.Sidecar.LogLevel diff --git a/pkg/configurator/mock_client_generated.go b/pkg/configurator/mock_client_generated.go index 74dccaba6..0085d06a4 100644 --- a/pkg/configurator/mock_client_generated.go +++ b/pkg/configurator/mock_client_generated.go @@ -613,6 +613,20 @@ func (mr *MockConfiguratorMockRecorder) GetSidecarLogLevel() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSidecarLogLevel", reflect.TypeOf((*MockConfigurator)(nil).GetSidecarLogLevel)) } +// GetSidecarTimeout mocks base method. +func (m *MockConfigurator) GetSidecarTimeout() int { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetSidecarTimeout") + ret0, _ := ret[0].(int) + return ret0 +} + +// GetSidecarTimeout indicates an expected call of GetSidecarTimeout. +func (mr *MockConfiguratorMockRecorder) GetSidecarTimeout() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSidecarTimeout", reflect.TypeOf((*MockConfigurator)(nil).GetSidecarTimeout)) +} + // GetTracingEndpoint mocks base method. func (m *MockConfigurator) GetTracingEndpoint() string { m.ctrl.T.Helper() diff --git a/pkg/configurator/types.go b/pkg/configurator/types.go index 87365efda..6663359bf 100644 --- a/pkg/configurator/types.go +++ b/pkg/configurator/types.go @@ -99,6 +99,9 @@ type Configurator interface { // GetMaxDataPlaneConnections returns the max data plane connections allowed, 0 if disabled GetMaxDataPlaneConnections() int + // GetSidecarTimeout returns connect/idle/read/write timeout + GetSidecarTimeout() int + // GetFSMLogLevel returns the configured FSM log level GetFSMLogLevel() string diff --git a/pkg/messaging/broker.go b/pkg/messaging/broker.go index d9995b656..973f4b7ec 100644 --- a/pkg/messaging/broker.go +++ b/pkg/messaging/broker.go @@ -649,6 +649,7 @@ func getProxyUpdateEvent(msg events.PubSubMessage) *proxyUpdateEvent { prevSpec.Traffic.ServiceAccessMode != newSpec.Traffic.ServiceAccessMode || prevSpec.Observability.Tracing != newSpec.Observability.Tracing || prevSpec.Sidecar.LogLevel != newSpec.Sidecar.LogLevel || + prevSpec.Sidecar.SidecarTimeout != newSpec.Sidecar.SidecarTimeout || prevSpec.Traffic.InboundExternalAuthorization.Enable != newSpec.Traffic.InboundExternalAuthorization.Enable || // Only trigger an update on InboundExternalAuthorization field changes if the new spec has the 'Enable' flag set to true. (newSpec.Traffic.InboundExternalAuthorization.Enable && (prevSpec.Traffic.InboundExternalAuthorization != newSpec.Traffic.InboundExternalAuthorization)) || diff --git a/pkg/sidecar/providers/pipy/repo/jobs.go b/pkg/sidecar/providers/pipy/repo/jobs.go index a36ec9032..c5d030204 100644 --- a/pkg/sidecar/providers/pipy/repo/jobs.go +++ b/pkg/sidecar/providers/pipy/repo/jobs.go @@ -298,6 +298,7 @@ func features(s *Server, proxy *pipy.Proxy, pipyConf *PipyConf) { meshConf := mc.GetConfigurator() proxy.MeshConf = meshConf pipyConf.setSidecarLogLevel((*meshConf).GetMeshConfig().Spec.Sidecar.LogLevel) + pipyConf.setSidecarTimeout((*meshConf).GetMeshConfig().Spec.Sidecar.SidecarTimeout) pipyConf.setEnableSidecarActiveHealthChecks((*meshConf).GetFeatureFlags().EnableSidecarActiveHealthChecks) pipyConf.setEnableAutoDefaultRoute((*meshConf).GetFeatureFlags().EnableAutoDefaultRoute) pipyConf.setEnableEgress((*meshConf).IsEgressEnabled()) diff --git a/pkg/sidecar/providers/pipy/repo/policy.go b/pkg/sidecar/providers/pipy/repo/policy.go index befeb2f78..1258e41db 100644 --- a/pkg/sidecar/providers/pipy/repo/policy.go +++ b/pkg/sidecar/providers/pipy/repo/policy.go @@ -33,6 +33,13 @@ func (p *PipyConf) setSidecarLogLevel(sidecarLogLevel string) (update bool) { return } +func (p *PipyConf) setSidecarTimeout(sidecarTimeout int) (update bool) { + if update = p.Spec.SidecarTimeout != sidecarTimeout; update { + p.Spec.SidecarTimeout = sidecarTimeout + } + return +} + func (p *PipyConf) setLocalDNSProxy(enable bool, primary, secondary string) { if enable { p.Spec.LocalDNSProxy = new(LocalDNSProxy) diff --git a/pkg/sidecar/providers/pipy/repo/types.go b/pkg/sidecar/providers/pipy/repo/types.go index b15850cc6..5459ac368 100644 --- a/pkg/sidecar/providers/pipy/repo/types.go +++ b/pkg/sidecar/providers/pipy/repo/types.go @@ -211,6 +211,7 @@ type LocalDNSProxy struct { // MeshConfigSpec represents the spec of mesh config type MeshConfigSpec struct { SidecarLogLevel string + SidecarTimeout int Traffic TrafficSpec FeatureFlags FeatureFlags Probes struct {