Skip to content

Commit

Permalink
Add SidecarTimeout to MeshConfig. (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
cybwan authored and reaver-flomesh committed Sep 4, 2023
1 parent cd0cb3e commit 12e8484
Show file tree
Hide file tree
Showing 20 changed files with 110 additions and 10 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: Build test dependencies
env:
DOCKER_BUILDX_OUTPUT: type=docker
run: make docker-build-fsm build-fsm docker-build-tcp-echo-server
run: make docker-build-e2e build-fsm
- name: Run tests
id: test
env:
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
- name: Build test dependencies
env:
DOCKER_BUILDX_OUTPUT: type=docker
run: make docker-build-fsm build-fsm docker-build-tcp-echo-server
run: make docker-build-e2e build-fsm
- name: Run tests
id: test
env:
Expand Down Expand Up @@ -289,7 +289,7 @@ jobs:
- name: Build test dependencies
env:
DOCKER_BUILDX_OUTPUT: type=docker
run: make docker-build-fsm build-fsm docker-build-tcp-echo-server
run: make docker-build-e2e build-fsm
- name: Run tests
id: test
env:
Expand Down Expand Up @@ -350,7 +350,7 @@ jobs:
- name: Build test dependencies
env:
DOCKER_BUILDX_OUTPUT: type=docker
run: make docker-build-fsm build-fsm docker-build-tcp-echo-server
run: make docker-build-e2e build-fsm
- name: Run tests
id: test
env:
Expand Down Expand Up @@ -404,7 +404,7 @@ jobs:
- name: Build test dependencies
env:
DOCKER_BUILDX_OUTPUT: type=docker
run: make docker-build-fsm build-fsm docker-build-tcp-echo-server
run: make docker-build-e2e build-fsm
- name: Run tests
id: test
env:
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,17 @@ docker-build-fsm-gateway:

TRI_TARGETS = fsm-sidecar-init fsm-controller fsm-injector fsm-crds fsm-bootstrap fsm-preinstall fsm-healthcheck fsm-consul-connector fsm-ingress fsm-gateway
FSM_TARGETS = fsm-sidecar-init fsm-controller fsm-injector fsm-crds fsm-bootstrap fsm-preinstall fsm-healthcheck fsm-consul-connector fsm-interceptor fsm-ingress fsm-gateway
E2E_TARGETS = fsm-sidecar-init fsm-controller fsm-injector fsm-crds fsm-bootstrap fsm-preinstall fsm-healthcheck fsm-consul-connector fsm-ingress fsm-gateway

DOCKER_FSM_TARGETS = $(addprefix docker-build-, $(FSM_TARGETS))
DOCKER_E2E_TARGETS = $(addprefix docker-build-, $(E2E_TARGETS))

.PHONY: docker-build-fsm
docker-build-fsm: charts-tgz $(DOCKER_FSM_TARGETS)

.PHONY: docker-build-e2e
docker-build-e2e: charts-tgz $(DOCKER_E2E_TARGETS)

.PHONY: buildx-context
buildx-context:
@if ! docker buildx ls | grep -q "^fsm "; then docker buildx create --name fsm --driver-opt network=host; fi
Expand Down
1 change: 1 addition & 0 deletions charts/fsm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,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.<fsm-namespace>.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"` | |
Expand Down
1 change: 1 addition & 0 deletions charts/fsm/templates/preset-mesh-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
},
Expand Down
10 changes: 10 additions & 0 deletions charts/fsm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
"meshName",
"maxDataPlaneConnections",
"sidecarLogLevel",
"sidecarTimeout",
"controllerLogLevel",
"enforceSingleMesh",
"deployJaeger",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions charts/fsm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions cmd/fsm-bootstrap/crds/config.flomesh.io_meshconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/config/v1alpha1/mesh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/config/v1alpha2/mesh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/config/v1alpha3/mesh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
9 changes: 9 additions & 0 deletions pkg/configurator/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/configurator/mock_client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/configurator/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions pkg/manager/listeners/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ type client struct {
mc *configv1alpha3.MeshConfig
}

func (c *client) GetSidecarTimeout() int {
//TODO implement me
panic("implement me")
}

func (c *client) GetFSMIngressLogLevel() string {
//TODO implement me
panic("implement me")
Expand Down
1 change: 1 addition & 0 deletions pkg/messaging/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)) ||
Expand Down
16 changes: 13 additions & 3 deletions pkg/sidecar/providers/pipy/repo/codebase/connect-tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
{
metricsCache,
} = pipy.solve('metrics.js'),

connectOptions = (config?.Spec?.SidecarTimeout > 0) ? (
{
connectTimeout: config.Spec.SidecarTimeout,
readTimeout: config.Spec.SidecarTimeout,
writeTimeout: config.Spec.SidecarTimeout,
idleTimeout: config.Spec.SidecarTimeout,
}
) : {},

) => (

pipy({
Expand Down Expand Up @@ -44,10 +54,10 @@ pipy({
)
.branch(
() => __target.startsWith('127.0.0.1:'), (
$=>$.connect(() => __target, { bind: '127.0.0.6' })
$=>$.connect(() => __target, { bind: '127.0.0.6', ...connectOptions })
),
(
$=>$.connect(() => __target)
$=>$.connect(() => __target, connectOptions)
)
)
.handleData(
Expand All @@ -56,4 +66,4 @@ pipy({
)
)

))()
))()
14 changes: 12 additions & 2 deletions pkg/sidecar/providers/pipy/repo/codebase/main.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
((
config = pipy.solve('config.js'),

connectOptions = (config?.Spec?.SidecarTimeout > 0) ? (
{
connectTimeout: config.Spec.SidecarTimeout,
readTimeout: config.Spec.SidecarTimeout,
writeTimeout: config.Spec.SidecarTimeout,
idleTimeout: config.Spec.SidecarTimeout,
}
) : {},

) => pipy()

.branch(
Boolean(config?.Inbound?.TrafficMatches), (
$=>$
.listen(15003, { transparent: true })
.listen(15003, { transparent: true, ...connectOptions })
.onStart(() => new Data)
.use('modules/inbound-main.js')
)
Expand All @@ -14,7 +24,7 @@
.branch(
Boolean(config?.Outbound || config?.Spec?.Traffic?.EnableEgress), (
$=>$
.listen(15001, { transparent: true })
.listen(15001, { transparent: true, ...connectOptions })
.onStart(() => new Data)
.use('modules/outbound-main.js')
)
Expand Down
1 change: 1 addition & 0 deletions pkg/sidecar/providers/pipy/repo/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 7 additions & 0 deletions pkg/sidecar/providers/pipy/repo/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/sidecar/providers/pipy/repo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 12e8484

Please sign in to comment.