diff --git a/adapter/cmd/adapter/main.go b/adapter/cmd/adapter/main.go index 10c83644b1..c83fa25a9d 100644 --- a/adapter/cmd/adapter/main.go +++ b/adapter/cmd/adapter/main.go @@ -42,7 +42,7 @@ func startMicroGateway() { logger.Fatal("Error starting the adapter", err) } conf, errReadConfig := config.ReadConfigs() - config.GetTcpKeepaliveEnabledOrgs() + config.GetTCPKeepaliveEnabledOrgs() if errReadConfig != nil { logger.Fatal("Error loading configuration. ", errReadConfig) } diff --git a/adapter/config/default_config.go b/adapter/config/default_config.go index f4899e3679..afb5ae189a 100644 --- a/adapter/config/default_config.go +++ b/adapter/config/default_config.go @@ -157,14 +157,13 @@ var defaultConfig = &Config{ MaxRetries: 50, }, }, - TcpConfigurations: upstreamTcpConfigs{ + TCPConfigurations: upstreamTCPConfigs{ KeepaliveTimeInMillis: 120000, KeepaliveProbes: 9, - KeepaliveIntervalInMillis: 75, + KeepaliveIntervalInMillis: 75000, }, - HttpConfigurations: upstreamHttpConfigs{ + HTTPConfigurations: upstreamHTTPConfigs{ IdleTimeoutInMillis: 120000, - MaxConnectionDurationInMillis: 120000, }, }, Connection: connection{ diff --git a/adapter/config/parser.go b/adapter/config/parser.go index 15d82a4b6e..0018a1f268 100644 --- a/adapter/config/parser.go +++ b/adapter/config/parser.go @@ -39,6 +39,7 @@ var ( adapterConfig *Config defaultVhost map[string]string e error + // UpstreamConnectionConfEnabledOrgList is the list of orgs that need to handle connection timeouts UpstreamConnectionConfEnabledOrgList []string ) @@ -257,8 +258,8 @@ func printDeprecatedWarningLog(deprecatedTerm, currentTerm string) { logger.Warnf("%s is deprecated. Use %s instead", deprecatedTerm, currentTerm) } -// GetTcpKeepaliveEnabledOrgs returns the list of orgs that need to handle connection timeouts -func GetTcpKeepaliveEnabledOrgs() { +// GetTCPKeepaliveEnabledOrgs returns the list of orgs that need to handle connection timeouts +func GetTCPKeepaliveEnabledOrgs() { orgs := os.Getenv("TCP_KEEPALIVE_ENABLED_ORGS") UpstreamConnectionConfEnabledOrgList = strings.Split(orgs, ",") if len(UpstreamConnectionConfEnabledOrgList) == 0 { diff --git a/adapter/config/types.go b/adapter/config/types.go index 090394a2ca..fd61cfe642 100644 --- a/adapter/config/types.go +++ b/adapter/config/types.go @@ -241,8 +241,8 @@ type envoyUpstream struct { DNS upstreamDNS Retry upstreamRetry CircuitBreakers []upstreamCircuitBreaker - TcpConfigurations upstreamTcpConfigs - HttpConfigurations upstreamHttpConfigs + TCPConfigurations upstreamTCPConfigs + HTTPConfigurations upstreamHTTPConfigs } type upstreamTLS struct { @@ -278,14 +278,13 @@ type dnsResolverConfig struct { CAres cAres } -type upstreamTcpConfigs struct { +type upstreamTCPConfigs struct { KeepaliveTimeInMillis uint32 KeepaliveProbes uint32 KeepaliveIntervalInMillis uint32 } -type upstreamHttpConfigs struct { +type upstreamHTTPConfigs struct { IdleTimeoutInMillis uint32 - MaxConnectionDurationInMillis uint32 } type dnsResolverType string diff --git a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go index b041518a34..9a07490a7e 100644 --- a/adapter/internal/oasparser/envoyconf/routes_with_clusters.go +++ b/adapter/internal/oasparser/envoyconf/routes_with_clusters.go @@ -351,16 +351,15 @@ func getClusterName(epPrefix string, organizationID string, vHost string, swagge func getKeepAliveConfigs(cluster *clusterv3.Cluster, conf *config.Config) { cluster.UpstreamConnectionOptions = &clusterv3.UpstreamConnectionOptions{ TcpKeepalive: &corev3.TcpKeepalive{ - KeepaliveProbes: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveProbes), - KeepaliveInterval: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveIntervalInMillis), - KeepaliveTime: wrapperspb.UInt32(conf.Envoy.Upstream.TcpConfigurations.KeepaliveTimeInMillis / 1000), + KeepaliveProbes: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveProbes), + KeepaliveInterval: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveIntervalInMillis / 1000), + KeepaliveTime: wrapperspb.UInt32(conf.Envoy.Upstream.TCPConfigurations.KeepaliveTimeInMillis / 1000), }, } config := &upstreams.HttpProtocolOptions{ CommonHttpProtocolOptions: &corev3.HttpProtocolOptions{ - IdleTimeout: durationpb.New(time.Duration(conf.Envoy.Upstream.HttpConfigurations.IdleTimeoutInMillis) * time.Millisecond), - MaxConnectionDuration: durationpb.New(time.Duration(conf.Envoy.Upstream.HttpConfigurations.MaxConnectionDurationInMillis) * time.Millisecond), + IdleTimeout: durationpb.New(time.Duration(conf.Envoy.Upstream.HTTPConfigurations.IdleTimeoutInMillis) * time.Millisecond), }, UpstreamProtocolOptions: &upstreams.HttpProtocolOptions_UseDownstreamProtocolConfig{}, } diff --git a/resources/conf/config.toml.template b/resources/conf/config.toml.template index 6244cbdf9e..6923abf03e 100644 --- a/resources/conf/config.toml.template +++ b/resources/conf/config.toml.template @@ -190,20 +190,18 @@ retainKeys = ["self_validate_jwt", "issuer", "claim_mappings", "consumer_key_cla maxInterval = "500ms" # TCP configurations applicable with the upstream clusters -[router.upstream.tcpConfigurations] +[router.upstream.tCPConfigurations] # The number of milliseconds a connection needs to be idle before keep-alive probes start being sent keepaliveTimeInMillis = 120000 # Maximum number of keep-alive probes to send without response before deciding the connection is dead keepaliveProbes = 9 # The number of milliseconds between keep-alive probes - keepaliveIntervalInMillis = 75 + keepaliveIntervalInMillis = 75000 # HTTP configurations applicable with the upstream clusters -[router.upstream.httpConfigurations] +[router.upstream.hTTPConfigurations] # Idle timeout in milliseconds for connections idleTimeoutInMillis = 120000 - # The maximum duration of a connection in milliseconds - maxConnectionDurationInMillis = 120000 # Timeouts managed by the connection manager [router.connectionTimeout]