From ef66026205a29bfc52e0767da6a566a77830dc21 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Tue, 30 Jul 2024 18:00:59 +0200 Subject: [PATCH 1/3] allegro-internal/flex-roadmap#687 Added compression properties to node metadata --- CHANGELOG.md | 4 + .../servicemesh/envoycontrol/groups/Groups.kt | 17 ++- .../envoycontrol/groups/MetadataNodeGroup.kt | 6 +- .../envoycontrol/groups/NodeMetadata.kt | 27 ++++ .../snapshot/SnapshotProperties.kt | 14 +- .../filters/CompressionFilterFactory.kt | 65 +++++---- .../envoycontrol/groups/NodeMetadataTest.kt | 80 ++++++++++- .../envoycontrol/groups/TestNodeFactory.kt | 62 ++++++--- .../envoycontrol/CompressionFilterTest.kt | 8 +- .../config/EnvoyControlTestConfiguration.kt | 1 + .../envoy/config_xds_compression.yaml | 126 ++++++++++++++++++ 11 files changed, 340 insertions(+), 70 deletions(-) create mode 100644 envoy-control-tests/src/main/resources/envoy/config_xds_compression.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index edc1118bd..23a154402 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ Lists all changes with user impact. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [0.20.19] +### Changed +- Added http compression filter properties to node metadata +- ## [0.20.18] ### Changed - Added http compression filter configuration diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/Groups.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/Groups.kt index 7117988b6..af35d7a1b 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/Groups.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/Groups.kt @@ -9,6 +9,7 @@ sealed class Group { abstract val proxySettings: ProxySettings abstract val pathNormalizationConfig: PathNormalizationConfig abstract val listenersConfig: ListenersConfig? + abstract val compressionConfig: CompressionConfig } data class ServicesGroup( @@ -18,6 +19,7 @@ data class ServicesGroup( override val proxySettings: ProxySettings = ProxySettings(), override val pathNormalizationConfig: PathNormalizationConfig = PathNormalizationConfig(), override val listenersConfig: ListenersConfig? = null, + override val compressionConfig: CompressionConfig = CompressionConfig(), ) : Group() data class AllServicesGroup( @@ -26,8 +28,9 @@ data class AllServicesGroup( override val discoveryServiceName: String? = null, override val proxySettings: ProxySettings = ProxySettings(), override val pathNormalizationConfig: PathNormalizationConfig = PathNormalizationConfig(), - override val listenersConfig: ListenersConfig? = null -) : Group() + override val listenersConfig: ListenersConfig? = null, + override val compressionConfig: CompressionConfig = CompressionConfig(), + ) : Group() data class PathNormalizationConfig( val normalizationEnabled: Boolean? = null, @@ -35,6 +38,16 @@ data class PathNormalizationConfig( val pathWithEscapedSlashesAction: String? = null ) +data class CompressionConfig( + val gzip: Compressor? = null, + val brotli: Compressor? = null, +) + +data class Compressor( + val enabled: Boolean? = null, + val quality: Int? = null, +) + data class ListenersConfig( val ingressHost: String, val ingressPort: Int, diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroup.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroup.kt index 70680e3f4..3c0928fcd 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroup.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroup.kt @@ -185,7 +185,8 @@ class MetadataNodeGroup( discoveryServiceName, proxySettings, nodeMetadata.pathNormalizationConfig, - listenersConfig + listenersConfig, + nodeMetadata.compressionConfig ) else -> ServicesGroup( @@ -194,7 +195,8 @@ class MetadataNodeGroup( discoveryServiceName, proxySettings, nodeMetadata.pathNormalizationConfig, - listenersConfig + listenersConfig, + nodeMetadata.compressionConfig ) } } diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt index 8845714bf..631c329cb 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadata.kt @@ -9,6 +9,7 @@ import io.grpc.Status import pl.allegro.tech.servicemesh.envoycontrol.groups.ClientWithSelector.Companion.decomposeClient import pl.allegro.tech.servicemesh.envoycontrol.snapshot.AccessLogFiltersProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.CommonHttpProperties +import pl.allegro.tech.servicemesh.envoycontrol.snapshot.CompressorProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.RetryPolicyProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties import pl.allegro.tech.servicemesh.envoycontrol.utils.AccessLogFilterParser @@ -35,6 +36,7 @@ class NodeMetadata(metadata: Struct, properties: SnapshotProperties) { val pathNormalizationConfig = getPathNormalization(metadata.fieldsMap["path_normalization"], properties) val proxySettings: ProxySettings = ProxySettings(metadata.fieldsMap["proxy_settings"], properties) + val compressionConfig: CompressionConfig = getCompressionSettings(metadata.fieldsMap["compression"], properties) } data class AccessLogFilterSettings(val proto: Value?, val properties: AccessLogFiltersProperties) { @@ -86,6 +88,22 @@ fun getPathNormalization(proto: Value?, snapshotProperties: SnapshotProperties): ) } +fun getCompressionSettings(proto: Value?, snapshotProperties: SnapshotProperties): CompressionConfig { + val defaultCompressionConfig = CompressionConfig( + Compressor(snapshotProperties.compression.gzip.enabled, snapshotProperties.compression.gzip.quality), + Compressor(snapshotProperties.compression.brotli.enabled, snapshotProperties.compression.brotli.quality) + ) + if (proto == null) { + return defaultCompressionConfig + } + return CompressionConfig( + proto.field("gzip")?.toCompressorProperties(snapshotProperties.compression.gzip) + ?: defaultCompressionConfig.gzip, + proto.field("brotli")?.toCompressorProperties(snapshotProperties.compression.brotli) + ?: defaultCompressionConfig.brotli, + ) +} + private fun getCommunicationMode(proto: Value?): CommunicationMode { val ads = proto ?.boolValue @@ -344,6 +362,15 @@ fun Value?.toIncoming(properties: SnapshotProperties): Incoming { ) } +fun Value?.toCompressorProperties(properties: CompressorProperties): Compressor { + val enabled = this?.field("enabled")?.boolValue + val quality = this?.field("quality")?.numberValue?.toInt() + return Compressor( + enabled ?: properties.enabled, + quality ?: properties.quality + ) +} + fun Value?.toUnlistedPolicy() = this?.stringValue ?.takeIf { it.isNotEmpty() } ?.let { diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt index 6c90d2e1d..6c64b7405 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotProperties.kt @@ -381,26 +381,20 @@ class DynamicForwardProxyProperties { } class CompressionProperties { - var gzip = GzipProperties() - var brotli = BrotliProperties() + var gzip = CompressorProperties() + var brotli = CompressorProperties() var minContentLength = 100 var disableOnEtagHeader = true var requestCompressionEnabled = false var responseCompressionEnabled = false - var enableForServices: List = emptyList() } -class BrotliProperties { +class CompressorProperties { var enabled = false - var quality = 11 + var quality = 1 var chooseFirst = true } -class GzipProperties { - var enabled = false - var chooseFirst = false -} - data class OAuthProvider( var jwksUri: URI = URI.create("http://localhost"), var createCluster: Boolean = false, diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/CompressionFilterFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/CompressionFilterFactory.kt index 2f3cc32ef..a90f4b997 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/CompressionFilterFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/CompressionFilterFactory.kt @@ -14,42 +14,43 @@ import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties class CompressionFilterFactory(val properties: SnapshotProperties) { - private val brotliCompressionFilter: HttpFilter = compressionFilter( - TypedExtensionConfig.newBuilder() - .setName("envoy.compression.brotli.compressor") - .setTypedConfig( - com.google.protobuf.Any.pack( - Brotli.newBuilder() - .setQuality(UInt32Value.of(properties.compression.brotli.quality)) - .build() - ) - ), - properties.compression.brotli.chooseFirst - ) - - private val gzipCompressionFilter: HttpFilter = compressionFilter( - TypedExtensionConfig.newBuilder() - .setName("envoy.compression.gzip.compressor") - .setTypedConfig( - com.google.protobuf.Any.pack( - Gzip.newBuilder() - .setCompressionStrategy(Gzip.CompressionStrategy.DEFAULT_STRATEGY) - .setCompressionLevel(Gzip.CompressionLevel.forNumber(BEST_VALUE)) - .build() - ) - ), - properties.compression.gzip.chooseFirst - ) - fun gzipCompressionFilter(group: Group): HttpFilter? { - return if (properties.compression.gzip.enabled && group.hasCompressionEnabled()) { - gzipCompressionFilter + val compressionLevel = Gzip.CompressionLevel.forNumber( + group.compressionConfig.gzip?.quality + ?: properties.compression.gzip.quality + ) ?: Gzip.CompressionLevel.forNumber(BEST_VALUE) + return if (group.compressionConfig.gzip?.enabled == true) { + compressionFilter( + TypedExtensionConfig.newBuilder() + .setName("envoy.compression.gzip.compressor") + .setTypedConfig( + com.google.protobuf.Any.pack( + Gzip.newBuilder() + .setCompressionStrategy(Gzip.CompressionStrategy.DEFAULT_STRATEGY) + .setCompressionLevel(compressionLevel) + .build() + ) + ), + properties.compression.gzip.chooseFirst + ) } else null } fun brotliCompressionFilter(group: Group): HttpFilter? { - return if (properties.compression.brotli.enabled && group.hasCompressionEnabled()) { - brotliCompressionFilter + val compressionLevel = group.compressionConfig.brotli?.quality ?: properties.compression.brotli.quality + return if (group.compressionConfig.brotli?.enabled == true) { + compressionFilter( + TypedExtensionConfig.newBuilder() + .setName("envoy.compression.brotli.compressor") + .setTypedConfig( + com.google.protobuf.Any.pack( + Brotli.newBuilder() + .setQuality(UInt32Value.of(compressionLevel)) + .build() + ) + ), + properties.compression.brotli.chooseFirst + ) } else null } @@ -90,6 +91,4 @@ class CompressionFilterFactory(val properties: SnapshotProperties) { .setDefaultValue(BoolValue.of(defaultValue)) ) .setMinContentLength(UInt32Value.of(properties.compression.minContentLength)) - - private fun Group.hasCompressionEnabled() = properties.compression.enableForServices.contains(this.serviceName) } diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadataTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadataTest.kt index 6a92d5336..bd361f9b4 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadataTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/NodeMetadataTest.kt @@ -1197,7 +1197,11 @@ class NodeMetadataTest { @Test fun `should parse normalization config`() { // given - val proto = pathNormalizationProto(normalizationEnabled = true, mergeSlashes = false, pathWithEscapedSlashesAction = "UNESCAPE_AND_REDIRECT") + val proto = pathNormalizationProto( + normalizationEnabled = true, + mergeSlashes = false, + pathWithEscapedSlashesAction = "UNESCAPE_AND_REDIRECT" + ) // when val value = getPathNormalization(proto, snapshotProperties()) @@ -1207,10 +1211,15 @@ class NodeMetadataTest { assertThat(value.mergeSlashes).isFalse assertThat(value.pathWithEscapedSlashesAction).isEqualTo("UNESCAPE_AND_REDIRECT") } + @Test fun `should use default values when there is no normalization config`() { // given - val proto = pathNormalizationProto(normalizationEnabled = null, mergeSlashes = null, pathWithEscapedSlashesAction = null) + val proto = pathNormalizationProto( + normalizationEnabled = null, + mergeSlashes = null, + pathWithEscapedSlashesAction = null + ) // when val value = getPathNormalization(proto, snapshotProperties()) @@ -1333,6 +1342,73 @@ class NodeMetadataTest { assertThat(customData).isEqualTo(mapOf("abc" to true)) } + @Test + fun `should use default values when there is no compression config`() { + // given + val proto = compressionProto(gzipEnabled = false, brotliEnabled = false) + + // when + val value = getCompressionSettings(proto, snapshotProperties()) + // expects + + assertThat(value.brotli?.enabled).isFalse() + assertThat(value.brotli?.quality).isEqualTo(1) + assertThat(value.gzip?.enabled).isFalse() + assertThat(value.gzip?.quality).isEqualTo(1) + } + + @Test + fun `should parse gzip config and set default quality if missing`() { + // given + val proto = compressionProto(gzipEnabled = true, brotliEnabled = false) + + // when + val value = getCompressionSettings(proto, snapshotProperties()) + // expects + + assertThat(value.gzip?.enabled).isTrue() + assertThat(value.gzip?.quality).isEqualTo(1) + } + + @Test + fun `should parse gzip config`() { + // given + val proto = compressionProto(gzipEnabled = true, gzipQuality = 2, brotliEnabled = false) + + // when + val value = getCompressionSettings(proto, snapshotProperties()) + // expects + + assertThat(value.gzip?.enabled).isTrue() + assertThat(value.gzip?.quality).isEqualTo(2) + } + + @Test + fun `should parse brotli config and set default quality if missing`() { + // given + val proto = compressionProto(gzipEnabled = false, brotliEnabled = true) + + // when + val value = getCompressionSettings(proto, snapshotProperties()) + // expects + + assertThat(value.brotli?.enabled).isTrue() + assertThat(value.gzip?.quality).isEqualTo(1) + } + + @Test + fun `should parse brotli config`() { + // given + val proto = compressionProto(gzipEnabled = false, brotliEnabled = true, brotliQuality = 3) + + // when + val value = getCompressionSettings(proto, snapshotProperties()) + // expects + + assertThat(value.brotli?.enabled).isTrue() + assertThat(value.brotli?.quality).isEqualTo(3) + } + fun ObjectAssert.hasTimeouts( idleTimeout: String, connectionIdleTimeout: String, diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/TestNodeFactory.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/TestNodeFactory.kt index 115a59b2c..377582674 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/TestNodeFactory.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/TestNodeFactory.kt @@ -128,22 +128,22 @@ fun pathNormalizationProto( mergeSlashes: Boolean?, pathWithEscapedSlashesAction: String? ) = struct { - normalizationEnabled?.let { - putFields( - "enabled", boolean(it) - ) - } - mergeSlashes?.let { - putFields( - "merge_slashes", boolean(it) - ) - } - pathWithEscapedSlashesAction?.let { - putFields( - "path_with_escaped_slashes_action", string(it) - ) - } + normalizationEnabled?.let { + putFields( + "enabled", boolean(it) + ) } + mergeSlashes?.let { + putFields( + "merge_slashes", boolean(it) + ) + } + pathWithEscapedSlashesAction?.let { + putFields( + "path_with_escaped_slashes_action", string(it) + ) + } +} fun accessLogBooleanFilterProto(value: Boolean? = null, fieldName: String): Value = struct { when { @@ -202,6 +202,38 @@ fun proxySettingsProto( } } +fun compressionProto( + gzipEnabled: Boolean? = null, + gzipQuality: Int? = null, + brotliEnabled: Boolean? = null, + brotliQuality: Int? = null, +) = struct { + gzipEnabled?.let { + putFields( + "gzip", struct { + if (gzipEnabled == true) { + putFields("enabled", boolean(true)) + } + gzipQuality?.let { + putFields("quality", integer(gzipQuality)) + } + } + ) + } + brotliEnabled?.let { + putFields( + "brotli", struct { + if (brotliEnabled == true) { + putFields("enabled", boolean(true)) + } + brotliQuality?.let { + putFields("quality", integer(brotliQuality)) + } + } + ) + } +} + data class RetryPolicyInput( val retryOn: List? = null, val hostSelectionRetryMaxAttempts: Int? = null, diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/CompressionFilterTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/CompressionFilterTest.kt index 36a3d19d7..89dd613c0 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/CompressionFilterTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/CompressionFilterTest.kt @@ -8,6 +8,7 @@ import org.junit.jupiter.api.extension.RegisterExtension import pl.allegro.tech.servicemesh.envoycontrol.assertions.untilAsserted import pl.allegro.tech.servicemesh.envoycontrol.config.AdsAllDependencies import pl.allegro.tech.servicemesh.envoycontrol.config.Xds +import pl.allegro.tech.servicemesh.envoycontrol.config.XdsCompression import pl.allegro.tech.servicemesh.envoycontrol.config.consul.ConsulExtension import pl.allegro.tech.servicemesh.envoycontrol.config.envoy.EnvoyExtension import pl.allegro.tech.servicemesh.envoycontrol.config.envoycontrol.EnvoyControlExtension @@ -19,7 +20,6 @@ class CompressionFilterTest { companion object { private const val SERVICE_NAME = "service-1" - private const val DOWNSTREAM_SERVICE_NAME = "echo2" private const val LONG_STRING = "Workshallmeantheworkofauthorship,whetherinSourceorObjectform," + "madeavailableundertheLicensesindicatedbyacopyrightnoticethatisincludedinorattachedto" + "thework(anexampleisprovidedintheAppendixbelow)." @@ -44,13 +44,9 @@ class CompressionFilterTest { val envoyControl = EnvoyControlExtension( consul, mapOf( - "envoy-control.envoy.snapshot.compression.gzip.enabled" to true, - "envoy-control.envoy.snapshot.compression.brotli.enabled" to true, "envoy-control.envoy.snapshot.compression.minContentLength" to 100, "envoy-control.envoy.snapshot.compression.responseCompressionEnabled" to true, - "envoy-control.envoy.snapshot.compression.enableForServices" to listOf(DOWNSTREAM_SERVICE_NAME), "envoy-control.envoy.snapshot.outgoing-permissions.servicesAllowedToUseWildcard" to "test-service" - ) ) @@ -69,7 +65,7 @@ class CompressionFilterTest { @JvmField @RegisterExtension - val downstreamEnvoy = EnvoyExtension(envoyControl, downstreamService, Xds) + val downstreamEnvoy = EnvoyExtension(envoyControl, downstreamService, XdsCompression) @JvmField @RegisterExtension diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/EnvoyControlTestConfiguration.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/EnvoyControlTestConfiguration.kt index 9a968b2be..ccf64027a 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/EnvoyControlTestConfiguration.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/config/EnvoyControlTestConfiguration.kt @@ -69,6 +69,7 @@ val AdsWithDisabledEndpointPermissions = EnvoyConfig("envoy/config_ads_disabled_ val AdsWithStaticListeners = EnvoyConfig("envoy/config_ads_static_listeners.yaml") val AdsWithNoDependencies = EnvoyConfig("envoy/config_ads_no_dependencies.yaml") val Xds = EnvoyConfig("envoy/config_xds.yaml") +val XdsCompression = EnvoyConfig("envoy/config_xds_compression.yaml") val RandomConfigFile = listOf(Ads, Xds, DeltaAds).random() val OAuthEnvoyConfig = EnvoyConfig("envoy/config_oauth.yaml") diff --git a/envoy-control-tests/src/main/resources/envoy/config_xds_compression.yaml b/envoy-control-tests/src/main/resources/envoy/config_xds_compression.yaml new file mode 100644 index 000000000..a3c842718 --- /dev/null +++ b/envoy-control-tests/src/main/resources/envoy/config_xds_compression.yaml @@ -0,0 +1,126 @@ +admin: + access_log_path: /dev/null + address: + socket_address: { address: 0.0.0.0, port_value: 10000 } +dynamic_resources: + lds_config: + resource_api_version: V3 + api_config_source: + api_type: GRPC + transport_api_version: V3 + grpc_services: + envoy_grpc: + cluster_name: envoy-control-xds + cds_config: + resource_api_version: V3 + api_config_source: + api_type: GRPC + transport_api_version: V3 + grpc_services: + envoy_grpc: + cluster_name: envoy-control-xds +node: + cluster: test-cluster + id: test-id + metadata: + ingress_host: "0.0.0.0" + ingress_port: 5001 + egress_host: "0.0.0.0" + egress_port: 5000 + use_remote_address: true + generate_request_id: true + preserve_external_request_id: true + access_log_enabled: false + add_upstream_external_address_header: true + resources_dir: "/etc/envoy/extra" + service_name: "echo2" + proxy_settings: + incoming: + endpoints: + - path: "/endpoint" + clients: ["authorizedClient"] + outgoing: + dependencies: + - service: "service-1" + - service: "service-2" + - service: "service-3" + - service: "service-4" + - service: "service-5" + - service: "echo" + timeoutPolicy: + requestTimeout: "15s" + - service: "consul" + timeoutPolicy: + requestTimeout: "15s" + - service: "proxy1" + - service: "proxy2" + - service: "service-redirect" + handleInternalRedirect: true + - service: "host-rewrite-service" + rewriteHostHeader: true + - domain: "https://my.example.com" + - domain: "https://bad.host.example.com" + - domain: "https://www.example.com" + - domain: "https://www.example-redirect.com" + handleInternalRedirect: true + compression: + gzip: + enabled: true + quality: 1 + brotli: + enabled: true + quality: 11 + +static_resources: + clusters: + - connect_timeout: 1s + load_assignment: + cluster_name: envoy-control-xds + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: HOST_IP + port_value: HOST_PORT + - endpoint: + address: + socket_address: + address: HOST_IP + port_value: HOST2_PORT + http2_protocol_options: {} + name: envoy-control-xds + - name: envoy-original-destination + type: ORIGINAL_DST + lb_policy: CLUSTER_PROVIDED + original_dst_lb_config: + use_http_header: true + connect_timeout: + seconds: 1 + http_protocol_options: + allow_absolute_url: true + - name: local_service + type: STATIC + load_assignment: + cluster_name: local_service + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: LOCAL_SERVICE_IP + port_value: 5678 + connect_timeout: 1s + - name: this_admin + type: STATIC + load_assignment: + cluster_name: this_admin + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 10000 + connect_timeout: + seconds: 1 From e8138b5aea26073566133760810db6a3c20448a9 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Tue, 30 Jul 2024 18:50:54 +0200 Subject: [PATCH 2/3] allegro-internal/flex-roadmap#687 Added compression properties to node metadata --- .../groups/MetadataNodeGroupTest.kt | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt index b8294fc73..afc6ccc89 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt @@ -30,6 +30,8 @@ class MetadataNodeGroupTest { mergeSlashes = true, pathWithEscapedSlashesAction = "KEEP_UNCHANGED" ) + private val defaultCompConfig = Compressor(false, 1) + private val compressionConfig = CompressionConfig(defaultCompConfig, defaultCompConfig) @Test fun `should assign to group with all dependencies`() { // given @@ -50,7 +52,8 @@ class MetadataNodeGroupTest { proxySettings = ProxySettings().with( serviceDependencies = serviceDependencies("a", "b", "c"), allServicesDependencies = true - ) + ), + compressionConfig = compressionConfig ) ) } @@ -68,7 +71,8 @@ class MetadataNodeGroupTest { ServicesGroup( proxySettings = ProxySettings().with(serviceDependencies = setOf()), pathNormalizationConfig = defaultNormalizationConfig, - communicationMode = XDS + communicationMode = XDS, + compressionConfig = compressionConfig ) ) } @@ -87,7 +91,8 @@ class MetadataNodeGroupTest { ServicesGroup( proxySettings = ProxySettings().with(serviceDependencies = serviceDependencies("a", "b", "c")), pathNormalizationConfig = defaultNormalizationConfig, - communicationMode = XDS + communicationMode = XDS, + compressionConfig = compressionConfig ) ) } @@ -106,7 +111,8 @@ class MetadataNodeGroupTest { AllServicesGroup( communicationMode = ADS, pathNormalizationConfig = defaultNormalizationConfig, - proxySettings = ProxySettings().with(allServicesDependencies = true) + proxySettings = ProxySettings().with(allServicesDependencies = true), + compressionConfig = compressionConfig ) ) } @@ -125,7 +131,8 @@ class MetadataNodeGroupTest { ServicesGroup( proxySettings = ProxySettings().with(serviceDependencies = serviceDependencies("a", "b", "c")), pathNormalizationConfig = defaultNormalizationConfig, - communicationMode = ADS + communicationMode = ADS, + compressionConfig = compressionConfig ) ) } @@ -146,7 +153,8 @@ class MetadataNodeGroupTest { // because service may define different settings for different dependencies (for example retry config) communicationMode = ADS, pathNormalizationConfig = defaultNormalizationConfig, - proxySettings = ProxySettings().with(serviceDependencies = serviceDependencies("a", "b", "c")) + proxySettings = ProxySettings().with(serviceDependencies = serviceDependencies("a", "b", "c")), + compressionConfig = compressionConfig ) ) } @@ -170,7 +178,8 @@ class MetadataNodeGroupTest { proxySettings = ProxySettings().with(serviceDependencies = serviceDependencies("a", "b", "c")), pathNormalizationConfig = defaultNormalizationConfig, communicationMode = XDS, - serviceName = "app1" + serviceName = "app1", + compressionConfig = compressionConfig ) ) } @@ -210,7 +219,8 @@ class MetadataNodeGroupTest { communicationMode = ADS, serviceName = "app1", pathNormalizationConfig = defaultNormalizationConfig, - proxySettings = addedProxySettings.with(serviceDependencies = serviceDependencies("a", "b")) + proxySettings = addedProxySettings.with(serviceDependencies = serviceDependencies("a", "b")), + compressionConfig = compressionConfig ) ) } @@ -232,7 +242,8 @@ class MetadataNodeGroupTest { communicationMode = XDS, serviceName = "app1", pathNormalizationConfig = defaultNormalizationConfig, - proxySettings = addedProxySettings.with(allServicesDependencies = true) + proxySettings = addedProxySettings.with(allServicesDependencies = true), + compressionConfig = compressionConfig ) ) } From c60040bc6dc8fe2b6438d7512ae087c4c97c7c79 Mon Sep 17 00:00:00 2001 From: "nastassia.dailidava" Date: Tue, 30 Jul 2024 18:52:43 +0200 Subject: [PATCH 3/3] allegro-internal/flex-roadmap#687 Added compression properties to node metadata --- .../servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt index afc6ccc89..a860a656c 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/MetadataNodeGroupTest.kt @@ -31,7 +31,8 @@ class MetadataNodeGroupTest { pathWithEscapedSlashesAction = "KEEP_UNCHANGED" ) private val defaultCompConfig = Compressor(false, 1) - private val compressionConfig = CompressionConfig(defaultCompConfig, defaultCompConfig) + private val compressionConfig = CompressionConfig(defaultCompConfig, defaultCompConfig) + @Test fun `should assign to group with all dependencies`() { // given