From 0fcbd255da0e5ffb0e2823c0df90a63b9d18beb5 Mon Sep 17 00:00:00 2001 From: slonka Date: Thu, 24 Sep 2020 13:29:54 +0200 Subject: [PATCH 1/6] Migrate all v2 resources to v3. --- .../servicemesh/envoycontrol/SimpleCache.java | 2 +- .../servicemesh/envoycontrol/ControlPlane.kt | 6 +- .../envoycontrol/groups/GroupChangeWatcher.kt | 2 +- .../envoycontrol/groups/NodeMetadata.kt | 2 +- .../callbacks/MeteredConnectionsCallbacks.kt | 6 ++ .../snapshot/EnvoySnapshotFactory.kt | 12 ++-- .../envoycontrol/snapshot/GlobalSnapshot.kt | 4 +- .../snapshot/SnapshotProperties.kt | 4 +- .../envoycontrol/snapshot/SnapshotUpdater.kt | 2 +- .../snapshot/SnapshotsVersions.kt | 6 +- .../resource/clusters/EnvoyClustersFactory.kt | 50 ++++++++--------- .../endpoints/EnvoyEndpointsFactory.kt | 16 +++--- .../listeners/EnvoyListenersFactory.kt | 55 ++++++++++--------- .../filters/AccessLogFilterFactory.kt | 2 +- .../listeners/filters/EnvoyDefaultFilters.kt | 4 +- .../listeners/filters/LuaFilterFactory.kt | 4 +- .../listeners/filters/RBACFilterFactory.kt | 18 +++--- .../filters/RBACFilterPermissions.kt | 10 ++-- .../listeners/filters/ServiceTagFilter.kt | 2 +- .../resource/routes/AdminRoutesFactory.kt | 14 ++--- .../resource/routes/AuthorizationRoute.kt | 2 +- .../routes/EnvoyEgressRoutesFactory.kt | 21 +++---- .../routes/EnvoyIngressRoutesFactory.kt | 18 +++--- .../resource/routes/RoutesMatchers.kt | 2 +- .../envoycontrol/v2/SimpleCacheTest.java | 11 +++- .../groups/MetadataNodeGroupTest.kt | 7 ++- .../envoycontrol/groups/NodeMetadataTest.kt | 2 +- .../envoycontrol/groups/RoutesAssertions.kt | 26 ++++----- .../snapshot/SnapshotUpdaterTest.kt | 4 +- .../snapshot/SnapshotsVersionsTest.kt | 14 ++--- .../filters/RBACFilterFactoryTest.kt | 16 +++--- .../filters/RBACFilterPermissionsTest.kt | 2 +- .../routes/EnvoyEgressRoutesFactoryTest.kt | 8 +-- .../snapshot/debug/SnapshotDebugController.kt | 20 +++---- .../snapshot/debug/SnapshotDebugInfo.kt | 10 ++-- .../envoycontrol/SnapshotDebugTest.kt | 3 +- .../ssl/EnvoyHttpsDependencyTest.kt | 16 ------ 37 files changed, 202 insertions(+), 201 deletions(-) diff --git a/envoy-control-core/src/main/java/pl/allegro/tech/servicemesh/envoycontrol/SimpleCache.java b/envoy-control-core/src/main/java/pl/allegro/tech/servicemesh/envoycontrol/SimpleCache.java index b5d9adff8..09a1c59b1 100644 --- a/envoy-control-core/src/main/java/pl/allegro/tech/servicemesh/envoycontrol/SimpleCache.java +++ b/envoy-control-core/src/main/java/pl/allegro/tech/servicemesh/envoycontrol/SimpleCache.java @@ -15,7 +15,7 @@ import io.envoyproxy.controlplane.cache.Watch; import io.envoyproxy.controlplane.cache.WatchCancelledException; import io.envoyproxy.controlplane.cache.XdsRequest; -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment; +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt index dccfe4492..1acccc98f 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ControlPlane.kt @@ -2,7 +2,7 @@ package pl.allegro.tech.servicemesh.envoycontrol import io.envoyproxy.controlplane.cache.NodeGroup import io.envoyproxy.controlplane.cache.SnapshotCache -import io.envoyproxy.controlplane.cache.v2.Snapshot +import io.envoyproxy.controlplane.cache.v3.Snapshot import io.envoyproxy.controlplane.server.DefaultExecutorGroup import io.envoyproxy.controlplane.server.ExecutorGroup import io.envoyproxy.controlplane.server.V2DiscoveryServer @@ -31,14 +31,14 @@ import pl.allegro.tech.servicemesh.envoycontrol.snapshot.EnvoySnapshotFactory import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotUpdater import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotsVersions import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.endpoints.EnvoyEndpointsFactory -import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.EnvoyListenersFactory import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.AccessLogFilterFactory import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.EnvoyHttpFilters +import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.EnvoyListenersFactory import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes.ServiceTagMetadataGenerator import pl.allegro.tech.servicemesh.envoycontrol.utils.DirectScheduler import pl.allegro.tech.servicemesh.envoycontrol.utils.ParallelScheduler import pl.allegro.tech.servicemesh.envoycontrol.utils.ParallelizableScheduler -import pl.allegro.tech.servicemesh.envoycontrol.v2.SimpleCache +import pl.allegro.tech.servicemesh.envoycontrol.v3.SimpleCache import reactor.core.Disposable import reactor.core.publisher.Flux import reactor.core.scheduler.Schedulers diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/GroupChangeWatcher.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/GroupChangeWatcher.kt index 4cb4cc3a8..a62bb3d8f 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/GroupChangeWatcher.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/GroupChangeWatcher.kt @@ -11,7 +11,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.utils.measureBuffer import reactor.core.publisher.Flux import reactor.core.publisher.FluxSink import java.util.function.Consumer -import pl.allegro.tech.servicemesh.envoycontrol.v2.SimpleCache as SimpleCache +import pl.allegro.tech.servicemesh.envoycontrol.v3.SimpleCache as SimpleCache /** * This class is needed to force snapshot creation in SnapshotUpdater when new group is added. 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 1cc1ec179..a25428cfc 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 @@ -5,7 +5,7 @@ import com.google.protobuf.Struct import com.google.protobuf.Value import com.google.protobuf.util.Durations import io.envoyproxy.controlplane.server.exception.RequestException -import io.envoyproxy.envoy.config.filter.accesslog.v2.ComparisonFilter +import io.envoyproxy.envoy.config.accesslog.v3.ComparisonFilter import io.grpc.Status import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.AccessLogFilterFactory diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/callbacks/MeteredConnectionsCallbacks.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/callbacks/MeteredConnectionsCallbacks.kt index f410fc3a5..6d9c3df79 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/callbacks/MeteredConnectionsCallbacks.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/callbacks/MeteredConnectionsCallbacks.kt @@ -45,6 +45,7 @@ class MeteredConnectionsCallbacks( fun connections(type: MetricsStreamType): AtomicInteger = connectionsByType[type]!! + @Suppress("ComplexMethod") private fun connectionsByType(typeUrl: String?): AtomicInteger { val type = when (typeUrl) { Resources.V2.CLUSTER_TYPE_URL -> MetricsStreamType.CDS @@ -52,6 +53,11 @@ class MeteredConnectionsCallbacks( Resources.V2.LISTENER_TYPE_URL -> MetricsStreamType.LDS Resources.V2.ROUTE_TYPE_URL -> MetricsStreamType.RDS Resources.V2.SECRET_TYPE_URL -> MetricsStreamType.SDS + Resources.V3.CLUSTER_TYPE_URL -> MetricsStreamType.CDS + Resources.V3.ENDPOINT_TYPE_URL -> MetricsStreamType.EDS + Resources.V3.LISTENER_TYPE_URL -> MetricsStreamType.LDS + Resources.V3.ROUTE_TYPE_URL -> MetricsStreamType.RDS + Resources.V3.SECRET_TYPE_URL -> MetricsStreamType.SDS "" -> MetricsStreamType.ADS // ads is when the type url is empty else -> MetricsStreamType.UNKNOWN } diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt index 8e0745c5b..54cb22033 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/EnvoySnapshotFactory.kt @@ -1,11 +1,11 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot -import io.envoyproxy.controlplane.cache.v2.Snapshot -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.Listener -import io.envoyproxy.envoy.api.v2.RouteConfiguration -import io.envoyproxy.envoy.api.v2.auth.Secret +import io.envoyproxy.controlplane.cache.v3.Snapshot +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.listener.v3.Listener +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.Secret import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.Timer import pl.allegro.tech.servicemesh.envoycontrol.groups.AllServicesGroup diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/GlobalSnapshot.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/GlobalSnapshot.kt index a231d2787..50b5aa4eb 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/GlobalSnapshot.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/GlobalSnapshot.kt @@ -1,8 +1,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot import io.envoyproxy.controlplane.cache.SnapshotResources -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment data class GlobalSnapshot( val clusters: SnapshotResources, 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 97ff77769..e96891f2a 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 @@ -2,8 +2,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.auth.TlsParameters +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.TlsParameters import pl.allegro.tech.servicemesh.envoycontrol.groups.PathMatchingType import java.time.Duration diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdater.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdater.kt index b9fa94b5f..b106289b3 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdater.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdater.kt @@ -1,7 +1,7 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot import io.envoyproxy.controlplane.cache.SnapshotCache -import io.envoyproxy.controlplane.cache.v2.Snapshot +import io.envoyproxy.controlplane.cache.v3.Snapshot import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.Timer import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersions.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersions.kt index 7dab586a5..8889a16d7 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersions.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersions.kt @@ -1,8 +1,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.Listener +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.listener.v3.Listener import pl.allegro.tech.servicemesh.envoycontrol.groups.Group import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotsVersions.Companion.newVersion import java.util.UUID diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt index 7ab17dffa..f2a00b126 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt @@ -5,31 +5,31 @@ import com.google.protobuf.Struct import com.google.protobuf.UInt32Value import com.google.protobuf.Value import com.google.protobuf.util.Durations -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.auth.CertificateValidationContext -import io.envoyproxy.envoy.api.v2.auth.CommonTlsContext -import io.envoyproxy.envoy.api.v2.auth.SdsSecretConfig -import io.envoyproxy.envoy.api.v2.auth.TlsParameters -import io.envoyproxy.envoy.api.v2.auth.UpstreamTlsContext -import io.envoyproxy.envoy.api.v2.cluster.CircuitBreakers -import io.envoyproxy.envoy.api.v2.cluster.OutlierDetection -import io.envoyproxy.envoy.api.v2.core.Address -import io.envoyproxy.envoy.api.v2.core.AggregatedConfigSource -import io.envoyproxy.envoy.api.v2.core.ApiConfigSource -import io.envoyproxy.envoy.api.v2.core.ConfigSource -import io.envoyproxy.envoy.api.v2.core.DataSource -import io.envoyproxy.envoy.api.v2.core.GrpcService -import io.envoyproxy.envoy.api.v2.core.Http2ProtocolOptions -import io.envoyproxy.envoy.api.v2.core.HttpProtocolOptions -import io.envoyproxy.envoy.api.v2.core.RoutingPriority -import io.envoyproxy.envoy.api.v2.core.SocketAddress -import io.envoyproxy.envoy.api.v2.core.TransportSocket -import io.envoyproxy.envoy.api.v2.core.UpstreamHttpProtocolOptions -import io.envoyproxy.envoy.api.v2.endpoint.Endpoint -import io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint -import io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints -import io.envoyproxy.envoy.type.matcher.StringMatcher +import io.envoyproxy.envoy.config.cluster.v3.CircuitBreakers +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.cluster.v3.OutlierDetection +import io.envoyproxy.envoy.config.core.v3.Address +import io.envoyproxy.envoy.config.core.v3.AggregatedConfigSource +import io.envoyproxy.envoy.config.core.v3.ApiConfigSource +import io.envoyproxy.envoy.config.core.v3.ConfigSource +import io.envoyproxy.envoy.config.core.v3.DataSource +import io.envoyproxy.envoy.config.core.v3.GrpcService +import io.envoyproxy.envoy.config.core.v3.Http2ProtocolOptions +import io.envoyproxy.envoy.config.core.v3.HttpProtocolOptions +import io.envoyproxy.envoy.config.core.v3.RoutingPriority +import io.envoyproxy.envoy.config.core.v3.SocketAddress +import io.envoyproxy.envoy.config.core.v3.TransportSocket +import io.envoyproxy.envoy.config.core.v3.UpstreamHttpProtocolOptions +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.endpoint.v3.Endpoint +import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint +import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.SdsSecretConfig +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.TlsParameters +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext +import io.envoyproxy.envoy.type.matcher.v3.StringMatcher import pl.allegro.tech.servicemesh.envoycontrol.groups.AllServicesGroup import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt index 6abe64b9a..b8d881c91 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/endpoints/EnvoyEndpointsFactory.kt @@ -4,14 +4,14 @@ import com.google.protobuf.ListValue import com.google.protobuf.Struct import com.google.protobuf.UInt32Value import com.google.protobuf.Value -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.core.Address -import io.envoyproxy.envoy.api.v2.core.Locality -import io.envoyproxy.envoy.api.v2.core.Metadata -import io.envoyproxy.envoy.api.v2.core.SocketAddress -import io.envoyproxy.envoy.api.v2.endpoint.Endpoint -import io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint -import io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints +import io.envoyproxy.envoy.config.core.v3.Address +import io.envoyproxy.envoy.config.core.v3.Metadata +import io.envoyproxy.envoy.config.core.v3.Locality +import io.envoyproxy.envoy.config.core.v3.SocketAddress +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.endpoint.v3.Endpoint +import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint +import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints import pl.allegro.tech.servicemesh.envoycontrol.services.MultiClusterState import pl.allegro.tech.servicemesh.envoycontrol.services.ServiceInstance import pl.allegro.tech.servicemesh.envoycontrol.services.ServiceInstances diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt index 670be667a..ef2e5dc90 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt @@ -5,32 +5,33 @@ import com.google.protobuf.Duration import com.google.protobuf.Struct import com.google.protobuf.Value import com.google.protobuf.util.Durations -import io.envoyproxy.envoy.api.v2.Listener -import io.envoyproxy.envoy.api.v2.auth.CommonTlsContext -import io.envoyproxy.envoy.api.v2.auth.DownstreamTlsContext -import io.envoyproxy.envoy.api.v2.auth.SdsSecretConfig -import io.envoyproxy.envoy.api.v2.auth.TlsParameters -import io.envoyproxy.envoy.api.v2.core.RuntimeUInt32 -import io.envoyproxy.envoy.api.v2.core.Address -import io.envoyproxy.envoy.api.v2.core.AggregatedConfigSource -import io.envoyproxy.envoy.api.v2.core.ApiConfigSource -import io.envoyproxy.envoy.api.v2.core.ConfigSource -import io.envoyproxy.envoy.api.v2.core.GrpcService -import io.envoyproxy.envoy.api.v2.core.Http1ProtocolOptions -import io.envoyproxy.envoy.api.v2.core.HttpProtocolOptions -import io.envoyproxy.envoy.api.v2.core.SocketAddress -import io.envoyproxy.envoy.api.v2.core.TransportSocket -import io.envoyproxy.envoy.api.v2.listener.Filter -import io.envoyproxy.envoy.api.v2.listener.FilterChain -import io.envoyproxy.envoy.api.v2.listener.FilterChainMatch -import io.envoyproxy.envoy.config.accesslog.v2.FileAccessLog -import io.envoyproxy.envoy.config.filter.accesslog.v2.AccessLog -import io.envoyproxy.envoy.config.filter.accesslog.v2.AccessLogFilter -import io.envoyproxy.envoy.config.filter.accesslog.v2.ComparisonFilter -import io.envoyproxy.envoy.config.filter.accesslog.v2.StatusCodeFilter -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpFilter -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.Rds +import io.envoyproxy.envoy.config.accesslog.v3.AccessLog +import io.envoyproxy.envoy.config.accesslog.v3.AccessLogFilter +import io.envoyproxy.envoy.config.accesslog.v3.ComparisonFilter +import io.envoyproxy.envoy.config.accesslog.v3.StatusCodeFilter +import io.envoyproxy.envoy.config.core.v3.Address +import io.envoyproxy.envoy.config.core.v3.AggregatedConfigSource +import io.envoyproxy.envoy.config.core.v3.ApiConfigSource +import io.envoyproxy.envoy.config.core.v3.ApiVersion +import io.envoyproxy.envoy.config.core.v3.ConfigSource +import io.envoyproxy.envoy.config.core.v3.GrpcService +import io.envoyproxy.envoy.config.core.v3.Http1ProtocolOptions +import io.envoyproxy.envoy.config.core.v3.HttpProtocolOptions +import io.envoyproxy.envoy.config.core.v3.RuntimeUInt32 +import io.envoyproxy.envoy.config.core.v3.SocketAddress +import io.envoyproxy.envoy.config.core.v3.TransportSocket +import io.envoyproxy.envoy.config.listener.v3.Filter +import io.envoyproxy.envoy.config.listener.v3.FilterChain +import io.envoyproxy.envoy.config.listener.v3.FilterChainMatch +import io.envoyproxy.envoy.config.listener.v3.Listener +import io.envoyproxy.envoy.extensions.access_loggers.file.v3.FileAccessLog +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.Rds +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CommonTlsContext +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.SdsSecretConfig +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.TlsParameters import pl.allegro.tech.servicemesh.envoycontrol.groups.AccessLogFilterSettings import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS @@ -254,6 +255,7 @@ class EnvoyListenersFactory( private fun egressRds(communicationMode: CommunicationMode): Rds { val configSource = ConfigSource.newBuilder() + .setResourceApiVersion(ApiVersion.V3) .setInitialFetchTimeout(egressRdsInitialFetchTimeout) when (communicationMode) { @@ -307,6 +309,7 @@ class EnvoyListenersFactory( private fun ingressRds(communicationMode: CommunicationMode): Rds { val configSource = ConfigSource.newBuilder() + .setResourceApiVersion(ApiVersion.V3) .setInitialFetchTimeout(ingressRdsInitialFetchTimeout) when (communicationMode) { diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/AccessLogFilterFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/AccessLogFilterFactory.kt index 54353fa4c..4a7e00732 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/AccessLogFilterFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/AccessLogFilterFactory.kt @@ -1,7 +1,7 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters import com.google.re2j.Pattern -import io.envoyproxy.envoy.config.filter.accesslog.v2.ComparisonFilter +import io.envoyproxy.envoy.config.accesslog.v3.ComparisonFilter import pl.allegro.tech.servicemesh.envoycontrol.groups.AccessLogFilterSettings import pl.allegro.tech.servicemesh.envoycontrol.groups.NodeMetadataValidationException diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/EnvoyDefaultFilters.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/EnvoyDefaultFilters.kt index bd20e533e..efc5fee04 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/EnvoyDefaultFilters.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/EnvoyDefaultFilters.kt @@ -1,8 +1,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters import com.google.protobuf.Any -import io.envoyproxy.envoy.config.filter.http.header_to_metadata.v2.Config -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpFilter +import io.envoyproxy.envoy.extensions.filters.http.header_to_metadata.v3.Config +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter import pl.allegro.tech.servicemesh.envoycontrol.groups.Group import pl.allegro.tech.servicemesh.envoycontrol.snapshot.GlobalSnapshot import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/LuaFilterFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/LuaFilterFactory.kt index 27dc17f77..8328b03bc 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/LuaFilterFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/LuaFilterFactory.kt @@ -1,8 +1,8 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters import com.google.protobuf.Any -import io.envoyproxy.envoy.config.filter.http.lua.v2.Lua -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpFilter +import io.envoyproxy.envoy.extensions.filters.http.lua.v3.Lua +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter import pl.allegro.tech.servicemesh.envoycontrol.groups.Group import pl.allegro.tech.servicemesh.envoycontrol.snapshot.IncomingPermissionsProperties diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactory.kt index 9fd238528..d2f3f8787 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactory.kt @@ -2,14 +2,14 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.fil import com.google.protobuf.Any import com.google.protobuf.UInt32Value -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.core.CidrRange -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpFilter -import io.envoyproxy.envoy.config.rbac.v2.Policy -import io.envoyproxy.envoy.config.rbac.v2.Principal -import io.envoyproxy.envoy.config.rbac.v2.RBAC -import io.envoyproxy.envoy.type.matcher.StringMatcher +import io.envoyproxy.envoy.config.core.v3.CidrRange +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.rbac.v3.Policy +import io.envoyproxy.envoy.config.rbac.v3.Principal +import io.envoyproxy.envoy.config.rbac.v3.RBAC +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter +import io.envoyproxy.envoy.type.matcher.v3.StringMatcher import pl.allegro.tech.servicemesh.envoycontrol.groups.ClientWithSelector import pl.allegro.tech.servicemesh.envoycontrol.groups.Group import pl.allegro.tech.servicemesh.envoycontrol.groups.Incoming @@ -23,7 +23,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.snapshot.IncomingPermissionsProp import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SelectorMatching import pl.allegro.tech.servicemesh.envoycontrol.snapshot.StatusRouteProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.TlsAuthenticationProperties -import io.envoyproxy.envoy.config.filter.http.rbac.v2.RBAC as RBACFilter +import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter class RBACFilterFactory( private val incomingPermissionsProperties: IncomingPermissionsProperties, diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissions.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissions.kt index 3b2e03806..fb5ef436d 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissions.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissions.kt @@ -1,10 +1,10 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher -import io.envoyproxy.envoy.config.rbac.v2.Permission -import io.envoyproxy.envoy.type.matcher.PathMatcher -import io.envoyproxy.envoy.type.matcher.RegexMatcher -import io.envoyproxy.envoy.type.matcher.StringMatcher +import io.envoyproxy.envoy.config.rbac.v3.Permission +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher +import io.envoyproxy.envoy.type.matcher.v3.PathMatcher +import io.envoyproxy.envoy.type.matcher.v3.RegexMatcher +import io.envoyproxy.envoy.type.matcher.v3.StringMatcher import pl.allegro.tech.servicemesh.envoycontrol.groups.IncomingEndpoint import pl.allegro.tech.servicemesh.envoycontrol.groups.PathMatchingType diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/ServiceTagFilter.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/ServiceTagFilter.kt index d337db9eb..11baffa99 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/ServiceTagFilter.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/ServiceTagFilter.kt @@ -1,6 +1,6 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters -import io.envoyproxy.envoy.config.filter.http.header_to_metadata.v2.Config +import io.envoyproxy.envoy.extensions.filters.http.header_to_metadata.v3.Config class ServiceTagFilter { companion object { diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AdminRoutesFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AdminRoutesFactory.kt index 7047d65b0..a0f11e2dd 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AdminRoutesFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AdminRoutesFactory.kt @@ -1,12 +1,12 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes -import io.envoyproxy.envoy.api.v2.core.DataSource -import io.envoyproxy.envoy.api.v2.route.DirectResponseAction -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher -import io.envoyproxy.envoy.api.v2.route.RedirectAction -import io.envoyproxy.envoy.api.v2.route.Route -import io.envoyproxy.envoy.api.v2.route.RouteAction -import io.envoyproxy.envoy.api.v2.route.RouteMatch +import io.envoyproxy.envoy.config.core.v3.DataSource +import io.envoyproxy.envoy.config.route.v3.DirectResponseAction +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher +import io.envoyproxy.envoy.config.route.v3.RedirectAction +import io.envoyproxy.envoy.config.route.v3.Route +import io.envoyproxy.envoy.config.route.v3.RouteAction +import io.envoyproxy.envoy.config.route.v3.RouteMatch import pl.allegro.tech.servicemesh.envoycontrol.protocol.HttpMethod import pl.allegro.tech.servicemesh.envoycontrol.snapshot.RoutesProperties diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AuthorizationRoute.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AuthorizationRoute.kt index 59d14153c..2f9f6cd23 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AuthorizationRoute.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/AuthorizationRoute.kt @@ -1,6 +1,6 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes -import io.envoyproxy.envoy.api.v2.route.Route +import io.envoyproxy.envoy.config.route.v3.Route class AuthorizationRoute( val authorized: Route, diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt index 65f5548e8..032d5d175 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactory.kt @@ -2,14 +2,14 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes import com.google.protobuf.util.Durations import io.envoyproxy.controlplane.cache.TestResources -import io.envoyproxy.envoy.api.v2.RouteConfiguration -import io.envoyproxy.envoy.api.v2.core.HeaderValue -import io.envoyproxy.envoy.api.v2.core.HeaderValueOption -import io.envoyproxy.envoy.api.v2.route.DirectResponseAction -import io.envoyproxy.envoy.api.v2.route.Route -import io.envoyproxy.envoy.api.v2.route.RouteAction -import io.envoyproxy.envoy.api.v2.route.RouteMatch -import io.envoyproxy.envoy.api.v2.route.VirtualHost +import io.envoyproxy.envoy.config.core.v3.HeaderValue +import io.envoyproxy.envoy.config.core.v3.HeaderValueOption +import io.envoyproxy.envoy.config.route.v3.DirectResponseAction +import io.envoyproxy.envoy.config.route.v3.Route +import io.envoyproxy.envoy.config.route.v3.RouteAction +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration +import io.envoyproxy.envoy.config.route.v3.RouteMatch +import io.envoyproxy.envoy.config.route.v3.VirtualHost import pl.allegro.tech.servicemesh.envoycontrol.snapshot.RouteSpecification import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties @@ -78,10 +78,11 @@ class EnvoyEgressRoutesFactory( .setMatch( RouteMatch.newBuilder() .setPrefix("/") + .build() ) .setRoute( createRouteAction(routeSpecification) - ) + ).build() ) .build() } @@ -124,7 +125,7 @@ class EnvoyEgressRoutesFactory( if (properties.egress.hostHeaderRewriting.enabled && routeSpecification.settings.rewriteHostHeader) { routeAction - .setAutoHostRewriteHeader(properties.egress.hostHeaderRewriting.customHostHeader) + .setHostRewriteHeader(properties.egress.hostHeaderRewriting.customHostHeader) } return routeAction diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyIngressRoutesFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyIngressRoutesFactory.kt index 8d13fac25..0c8b09e0b 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyIngressRoutesFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyIngressRoutesFactory.kt @@ -3,15 +3,15 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes import com.google.protobuf.Duration import com.google.protobuf.UInt32Value import com.google.protobuf.util.Durations -import io.envoyproxy.envoy.api.v2.RouteConfiguration -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher -import io.envoyproxy.envoy.api.v2.route.RetryPolicy -import io.envoyproxy.envoy.api.v2.route.Route -import io.envoyproxy.envoy.api.v2.route.RouteAction -import io.envoyproxy.envoy.api.v2.route.RouteMatch -import io.envoyproxy.envoy.api.v2.route.VirtualCluster -import io.envoyproxy.envoy.api.v2.route.VirtualHost -import io.envoyproxy.envoy.type.matcher.RegexMatcher +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher +import io.envoyproxy.envoy.config.route.v3.RetryPolicy +import io.envoyproxy.envoy.config.route.v3.Route +import io.envoyproxy.envoy.config.route.v3.RouteAction +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration +import io.envoyproxy.envoy.config.route.v3.RouteMatch +import io.envoyproxy.envoy.config.route.v3.VirtualCluster +import io.envoyproxy.envoy.config.route.v3.VirtualHost +import io.envoyproxy.envoy.type.matcher.v3.RegexMatcher import pl.allegro.tech.servicemesh.envoycontrol.groups.PathMatchingType import pl.allegro.tech.servicemesh.envoycontrol.groups.ProxySettings import pl.allegro.tech.servicemesh.envoycontrol.protocol.HttpMethod diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/RoutesMatchers.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/RoutesMatchers.kt index df5f5c3d9..191ae064c 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/RoutesMatchers.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/RoutesMatchers.kt @@ -1,6 +1,6 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.routes -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher import pl.allegro.tech.servicemesh.envoycontrol.protocol.HttpMethod fun httpMethodMatcher(method: HttpMethod): HeaderMatcher = exactHeader(":method", method.name) diff --git a/envoy-control-core/src/test/java/pl/allegro/tech/servicemesh/envoycontrol/v2/SimpleCacheTest.java b/envoy-control-core/src/test/java/pl/allegro/tech/servicemesh/envoycontrol/v2/SimpleCacheTest.java index 68e08dc52..bdf390421 100644 --- a/envoy-control-core/src/test/java/pl/allegro/tech/servicemesh/envoycontrol/v2/SimpleCacheTest.java +++ b/envoy-control-core/src/test/java/pl/allegro/tech/servicemesh/envoycontrol/v2/SimpleCacheTest.java @@ -20,6 +20,8 @@ import io.envoyproxy.envoy.api.v2.RouteConfiguration; import io.envoyproxy.envoy.api.v2.auth.Secret; import io.envoyproxy.envoy.api.v2.core.Node; +import java.util.Arrays; +import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; @@ -519,8 +521,13 @@ protected static void assertThatWatchReceivesSnapshot(WatchAndTracker watchAndTr assertThat(response).isNotNull(); assertThat(response.version()).isEqualTo(snapshot.version(watchAndTracker.watch.request().getTypeUrl())); - assertThat(response.resources().toArray(new Message[0])) - .containsExactlyElementsOf(snapshot.resources(watchAndTracker.watch.request().getTypeUrl()).values()); + Message[] responseValues = response.resources().toArray(new Message[0]); + Message[] snapshotValues = snapshot.resources(watchAndTracker.watch.request().getTypeUrl()).values().toArray(new Message[0]); + + assertThat(responseValues.length).isEqualTo(2); + assertThat(responseValues.length).isEqualTo(snapshotValues.length); + assertThat(responseValues[0]).isEqualToComparingFieldByFieldRecursively(snapshotValues[0]); + assertThat(responseValues[1]).isEqualToComparingFieldByFieldRecursively(snapshotValues[1]); } protected static class ResponseTracker implements Consumer { 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 7eb115741..4ec0798bc 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 @@ -10,7 +10,7 @@ import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.XDS import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.serviceDependencies -import io.envoyproxy.envoy.config.filter.accesslog.v2.ComparisonFilter.Op.EQ +import io.envoyproxy.envoy.config.accesslog.v3.ComparisonFilter import io.grpc.Status import org.junit.jupiter.api.assertThrows import org.junit.jupiter.params.ParameterizedTest @@ -242,8 +242,9 @@ class MetadataNodeGroupTest { val group = nodeGroup.hash(Node.newBuilder().setMetadata(metadata.build()).build()) // then - assertThat(group.listenersConfig!!.accessLogFilterSettings.statusCodeFilterSettings!!.comparisonCode).isEqualTo(400) - assertThat(group.listenersConfig!!.accessLogFilterSettings.statusCodeFilterSettings!!.comparisonOperator).isEqualTo(EQ) + val statusCodeFilterSettings = group.listenersConfig!!.accessLogFilterSettings.statusCodeFilterSettings!! + assertThat(statusCodeFilterSettings.comparisonCode).isEqualTo(400) + assertThat(statusCodeFilterSettings.comparisonOperator).isEqualTo(ComparisonFilter.Op.EQ) } @ParameterizedTest 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 92e1f984b..2c5e1f3ff 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 @@ -2,7 +2,7 @@ package pl.allegro.tech.servicemesh.envoycontrol.groups import com.google.protobuf.Value import com.google.protobuf.util.Durations -import io.envoyproxy.envoy.config.filter.accesslog.v2.ComparisonFilter +import io.envoyproxy.envoy.config.accesslog.v3.ComparisonFilter import io.grpc.Status import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.ObjectAssert diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/RoutesAssertions.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/RoutesAssertions.kt index e1dcd4bac..83fb1f62a 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/RoutesAssertions.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/groups/RoutesAssertions.kt @@ -1,15 +1,15 @@ package pl.allegro.tech.servicemesh.envoycontrol.groups import com.google.protobuf.Duration -import io.envoyproxy.envoy.api.v2.RouteConfiguration -import io.envoyproxy.envoy.api.v2.route.DirectResponseAction -import io.envoyproxy.envoy.api.v2.route.HeaderMatcher -import io.envoyproxy.envoy.api.v2.route.RedirectAction -import io.envoyproxy.envoy.api.v2.route.RetryPolicy -import io.envoyproxy.envoy.api.v2.route.Route -import io.envoyproxy.envoy.api.v2.route.RouteAction -import io.envoyproxy.envoy.api.v2.route.VirtualCluster -import io.envoyproxy.envoy.api.v2.route.VirtualHost +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration +import io.envoyproxy.envoy.config.route.v3.DirectResponseAction +import io.envoyproxy.envoy.config.route.v3.HeaderMatcher +import io.envoyproxy.envoy.config.route.v3.RedirectAction +import io.envoyproxy.envoy.config.route.v3.RetryPolicy +import io.envoyproxy.envoy.config.route.v3.Route +import io.envoyproxy.envoy.config.route.v3.RouteAction +import io.envoyproxy.envoy.config.route.v3.VirtualCluster +import io.envoyproxy.envoy.config.route.v3.VirtualHost import org.assertj.core.api.Assertions.assertThat import pl.allegro.tech.servicemesh.envoycontrol.snapshot.RetryPolicyProperties @@ -45,13 +45,13 @@ fun RouteAction.hasCustomRequestTimeout(requestTimeout: Duration): RouteAction { return this } -fun RouteAction.autoHostRewriteHeaderIsEmpty(): RouteAction { - assertThat(this.autoHostRewriteHeader).isEmpty() +fun RouteAction.hostRewriteHeaderIsEmpty(): RouteAction { + assertThat(this.hostRewriteHeader).isEmpty() return this } -fun RouteAction.hasAutoHostRewriteHeader(header: String): RouteAction { - assertThat(this.autoHostRewriteHeader).isEqualTo(header) +fun RouteAction.hasHostRewriteHeader(header: String): RouteAction { + assertThat(this.hostRewriteHeader).isEqualTo(header) return this } diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdaterTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdaterTest.kt index ea7c6e38c..68a7ebca4 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdaterTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotUpdaterTest.kt @@ -7,8 +7,8 @@ import io.envoyproxy.controlplane.cache.SnapshotCache import io.envoyproxy.controlplane.cache.StatusInfo import io.envoyproxy.controlplane.cache.Watch import io.envoyproxy.controlplane.cache.XdsRequest -import io.envoyproxy.controlplane.cache.v2.Snapshot -import io.envoyproxy.envoy.api.v2.RouteConfiguration +import io.envoyproxy.controlplane.cache.v3.Snapshot +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.simple.SimpleMeterRegistry import org.assertj.core.api.Assertions.assertThat diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersionsTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersionsTest.kt index 5e2da3f7d..e3a9def2a 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersionsTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/SnapshotsVersionsTest.kt @@ -1,12 +1,12 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.core.Address -import io.envoyproxy.envoy.api.v2.core.SocketAddress -import io.envoyproxy.envoy.api.v2.endpoint.Endpoint -import io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint -import io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.core.v3.Address +import io.envoyproxy.envoy.config.core.v3.SocketAddress +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.endpoint.v3.Endpoint +import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint +import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import pl.allegro.tech.servicemesh.envoycontrol.groups.AllServicesGroup diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactoryTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactoryTest.kt index 7e3cf8478..34c752087 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactoryTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterFactoryTest.kt @@ -3,14 +3,14 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.fil import com.google.protobuf.Any import com.google.protobuf.util.JsonFormat import io.envoyproxy.controlplane.cache.SnapshotResources -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.core.Address -import io.envoyproxy.envoy.api.v2.core.SocketAddress -import io.envoyproxy.envoy.api.v2.endpoint.Endpoint -import io.envoyproxy.envoy.api.v2.endpoint.LbEndpoint -import io.envoyproxy.envoy.api.v2.endpoint.LocalityLbEndpoints -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpFilter -import io.envoyproxy.envoy.config.filter.http.rbac.v2.RBAC as RBACFilter +import io.envoyproxy.envoy.config.core.v3.Address +import io.envoyproxy.envoy.config.core.v3.SocketAddress +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.endpoint.v3.Endpoint +import io.envoyproxy.envoy.config.endpoint.v3.LbEndpoint +import io.envoyproxy.envoy.config.endpoint.v3.LocalityLbEndpoints +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpFilter +import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import pl.allegro.tech.servicemesh.envoycontrol.groups.ClientWithSelector diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissionsTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissionsTest.kt index 3c76a3cfe..600e91bbe 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissionsTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/filters/RBACFilterPermissionsTest.kt @@ -1,7 +1,7 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters import com.google.protobuf.util.JsonFormat -import io.envoyproxy.envoy.config.rbac.v2.Permission +import io.envoyproxy.envoy.config.rbac.v3.Permission import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import pl.allegro.tech.servicemesh.envoycontrol.groups.IncomingEndpoint diff --git a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactoryTest.kt b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactoryTest.kt index 5f85ebf2b..249911d31 100644 --- a/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactoryTest.kt +++ b/envoy-control-core/src/test/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/routes/EnvoyEgressRoutesFactoryTest.kt @@ -6,8 +6,8 @@ import pl.allegro.tech.servicemesh.envoycontrol.groups.DependencySettings import pl.allegro.tech.servicemesh.envoycontrol.groups.Outgoing import pl.allegro.tech.servicemesh.envoycontrol.groups.hasCustomIdleTimeout import pl.allegro.tech.servicemesh.envoycontrol.groups.hasCustomRequestTimeout -import pl.allegro.tech.servicemesh.envoycontrol.groups.autoHostRewriteHeaderIsEmpty -import pl.allegro.tech.servicemesh.envoycontrol.groups.hasAutoHostRewriteHeader +import pl.allegro.tech.servicemesh.envoycontrol.groups.hostRewriteHeaderIsEmpty +import pl.allegro.tech.servicemesh.envoycontrol.groups.hasHostRewriteHeader import pl.allegro.tech.servicemesh.envoycontrol.groups.hasRequestHeaderToAdd import pl.allegro.tech.servicemesh.envoycontrol.groups.hasNoRequestHeaderToAdd import pl.allegro.tech.servicemesh.envoycontrol.groups.hasResponseHeaderToAdd @@ -116,7 +116,7 @@ internal class EnvoyEgressRoutesFactoryTest { .virtualHostsList[0] .routesList[0] .route - .autoHostRewriteHeaderIsEmpty() + .hostRewriteHeaderIsEmpty() } @Test @@ -136,6 +136,6 @@ internal class EnvoyEgressRoutesFactoryTest { .virtualHostsList[0] .routesList[0] .route - .hasAutoHostRewriteHeader(snapshotProperties.egress.hostHeaderRewriting.customHostHeader) + .hasHostRewriteHeader(snapshotProperties.egress.hostHeaderRewriting.customHostHeader) } } diff --git a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugController.kt b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugController.kt index 01192b472..0af1d07a7 100644 --- a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugController.kt +++ b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugController.kt @@ -13,13 +13,14 @@ import com.google.protobuf.util.JsonFormat import com.google.protobuf.util.JsonFormat.TypeRegistry import io.envoyproxy.controlplane.cache.NodeGroup import io.envoyproxy.controlplane.cache.SnapshotCache -import io.envoyproxy.controlplane.cache.v2.Snapshot -import io.envoyproxy.envoy.api.v2.auth.UpstreamTlsContext -import io.envoyproxy.envoy.api.v2.core.Node -import io.envoyproxy.envoy.config.filter.http.header_to_metadata.v2.Config -import io.envoyproxy.envoy.config.filter.http.lua.v2.Lua -import io.envoyproxy.envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager -import io.envoyproxy.envoy.config.rbac.v2.RBAC +import io.envoyproxy.controlplane.cache.v3.Snapshot +import io.envoyproxy.envoy.config.core.v3.Node +import io.envoyproxy.envoy.config.rbac.v3.RBAC +import io.envoyproxy.envoy.extensions.filters.http.header_to_metadata.v3.Config +import io.envoyproxy.envoy.extensions.filters.http.lua.v3.Lua +import io.envoyproxy.envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager +import io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext +import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter import io.envoyproxy.envoy.type.matcher.PathMatcher import io.envoyproxy.envoy.type.matcher.StringMatcher import org.springframework.boot.jackson.JsonComponent @@ -35,7 +36,6 @@ import org.springframework.web.bind.annotation.RestController import pl.allegro.tech.servicemesh.envoycontrol.ControlPlane import pl.allegro.tech.servicemesh.envoycontrol.groups.Group import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotUpdater -import io.envoyproxy.envoy.config.filter.http.rbac.v2.RBAC as FilterRBAC @RestController class SnapshotDebugController(controlPlane: ControlPlane) { @@ -44,7 +44,7 @@ class SnapshotDebugController(controlPlane: ControlPlane) { val snapshotUpdater: SnapshotUpdater = controlPlane.snapshotUpdater /** - * Returns a textual representation of the v2 snapshot for debugging purposes. + * Returns a textual representation of the snapshot for debugging purposes. * It contains the versions of XDS resources and the contents for a provided node JSON * extracted from Envoy's config_dump endpoint. */ @@ -95,7 +95,7 @@ class SnapshotDebugController(controlPlane: ControlPlane) { .add(Struct.getDescriptor()) .add(Value.getDescriptor()) .add(RBAC.getDescriptor()) - .add(FilterRBAC.getDescriptor()) + .add(RBACFilter.getDescriptor()) .add(Any.getDescriptor()) .add(PathMatcher.getDescriptor()) .add(StringMatcher.getDescriptor()) diff --git a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugInfo.kt b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugInfo.kt index 6ecd4382e..c554d8c32 100644 --- a/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugInfo.kt +++ b/envoy-control-runner/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/debug/SnapshotDebugInfo.kt @@ -1,9 +1,9 @@ package pl.allegro.tech.servicemesh.envoycontrol.snapshot.debug -import io.envoyproxy.envoy.api.v2.Cluster -import io.envoyproxy.envoy.api.v2.ClusterLoadAssignment -import io.envoyproxy.envoy.api.v2.Listener -import io.envoyproxy.envoy.api.v2.RouteConfiguration +import io.envoyproxy.envoy.config.cluster.v3.Cluster +import io.envoyproxy.envoy.config.endpoint.v3.ClusterLoadAssignment +import io.envoyproxy.envoy.config.listener.v3.Listener +import io.envoyproxy.envoy.config.route.v3.RouteConfiguration import net.openhft.hashing.LongHashFunction import pl.allegro.tech.servicemesh.envoycontrol.snapshot.GlobalSnapshot @@ -38,7 +38,7 @@ data class SnapshotDebugInfo( val snapshot: Snapshot, val versions: Versions ) { - constructor(snapshot: io.envoyproxy.controlplane.cache.v2.Snapshot) : this( + constructor(snapshot: io.envoyproxy.controlplane.cache.v3.Snapshot) : this( snapshot = Snapshot( clusters = snapshot.clusters().resources(), endpoints = snapshot.endpoints().resources(), diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/SnapshotDebugTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/SnapshotDebugTest.kt index 316bb7f66..f9fe4bfa1 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/SnapshotDebugTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/SnapshotDebugTest.kt @@ -84,8 +84,7 @@ open class SnapshotDebugTest : EnvoyControlTestConfiguration() { }, "locality": { "zone": "dev-dc4" - }, - "build_version": "b7bef67c256090919a4585a1a06c42f15d640a09/1.13.0-dev/Clean/RELEASE/BoringSSL" + } } """.trim() diff --git a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ssl/EnvoyHttpsDependencyTest.kt b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ssl/EnvoyHttpsDependencyTest.kt index 4d6e2e0d4..d3a3e7178 100644 --- a/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ssl/EnvoyHttpsDependencyTest.kt +++ b/envoy-control-tests/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/ssl/EnvoyHttpsDependencyTest.kt @@ -21,22 +21,6 @@ class EnvoyCurrentVersionHttpsDependencyTest : EnvoyHttpsDependencyTest() { } } -// TODO(https://github.com/allegro/envoy-control/issues/97) - remove when envoy < 1.14.0-dev will be not supported -class EnvoyCompatibleVersionHttpsDependencyTest : EnvoyHttpsDependencyTest() { - companion object { - @JvmStatic - @BeforeAll - fun setupTest() { - setup( - appFactoryForEc1 = { consulPort -> EnvoyControlRunnerTestApp(properties, consulPort) }, - // 1.13.0-dev - envoyImage = "envoyproxy/envoy-alpine-dev:b7bef67c256090919a4585a1a06c42f15d640a09" - ) - setupTestCommon() - } - } -} - abstract class EnvoyHttpsDependencyTest : EnvoyControlTestConfiguration() { companion object { @JvmStatic From 7e96f747ba37592dd0c3fa91831e1c469c52e87a Mon Sep 17 00:00:00 2001 From: slonka Date: Thu, 24 Sep 2020 14:36:22 +0200 Subject: [PATCH 2/6] Remove setSni no longer needed for Envoys <= 1.14.0-dev --- .../snapshot/resource/clusters/EnvoyClustersFactory.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt index f2a00b126..20d6c0bf0 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/clusters/EnvoyClustersFactory.kt @@ -192,12 +192,7 @@ class EnvoyClustersFactory( ).build() ).build() - val upstreamTlsContext = UpstreamTlsContext.newBuilder().setCommonTlsContext(commonTlsContext) - // for envoy >= 1.14.0-dev it will be overridden by setAutoSni below - // TODO(https://github.com/allegro/envoy-control/issues/97) - // remove when envoy < 1.14.0-dev will be not supported - .setSni(host) - .build() + val upstreamTlsContext = UpstreamTlsContext.newBuilder().setCommonTlsContext(commonTlsContext).build() val transportSocket = TransportSocket.newBuilder() .setTypedConfig(Any.pack( upstreamTlsContext From 4779973e9f6ad82d31805a5d6cbc0e5b755734bc Mon Sep 17 00:00:00 2001 From: slonka Date: Fri, 25 Sep 2020 12:13:24 +0200 Subject: [PATCH 3/6] Use one cache for resources --- .../server/CachedProtoResourcesSerializer.kt | 76 +++++++------------ 1 file changed, 26 insertions(+), 50 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt index da3691dcb..e11b58eca 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt @@ -5,72 +5,48 @@ import com.google.common.cache.CacheBuilder import com.google.protobuf.Any import com.google.protobuf.Message import io.envoyproxy.controlplane.cache.Resources +import io.envoyproxy.controlplane.server.serializer.DefaultProtoResourcesSerializer import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.binder.cache.GuavaCacheMetrics import pl.allegro.tech.servicemesh.envoycontrol.utils.noopTimer import java.util.function.Supplier -import io.envoyproxy.controlplane.cache.Resources.ApiVersion.V2 -import io.envoyproxy.controlplane.cache.Resources.ApiVersion.V3 -import io.envoyproxy.controlplane.server.serializer.DefaultProtoResourcesSerializer -import io.micrometer.core.instrument.Timer - internal class CachedProtoResourcesSerializer( - private val meterRegistry: MeterRegistry, - private val reportMetrics: Boolean + meterRegistry: MeterRegistry, + reportMetrics: Boolean ) : DefaultProtoResourcesSerializer() { - private fun createTimer(reportMetrics: Boolean, meterRegistry: MeterRegistry, timerName: String): Timer { - return if (reportMetrics) { - meterRegistry.timer(timerName) - } else { - noopTimer - } + private val serializeTimer = if (reportMetrics) { + meterRegistry.timer("protobuf-cache.serialize.time") + } else { + noopTimer } - private val cacheV2: Cache, MutableCollection> = createCache("protobuf-cache-v2") - private val cacheV3: Cache, MutableCollection> = createCache("protobuf-cache-v3") - private val v2Timer = createTimer(reportMetrics, meterRegistry, "protobuf-cache-v2.serialize.time") - private val v3Timer = createTimer(reportMetrics, meterRegistry, "protobuf-cache-v3.serialize.time") - - private fun createCache(cacheName: String): Cache, MutableCollection> { - return if (reportMetrics) { - GuavaCacheMetrics - .monitor( - meterRegistry, - CacheBuilder.newBuilder() - .recordStats() - .weakValues() - .build, MutableCollection>(), - cacheName - ) - } else { - CacheBuilder.newBuilder() + private val cache: Cache, MutableCollection> = if (reportMetrics) { + GuavaCacheMetrics + .monitor( + meterRegistry, + CacheBuilder.newBuilder() + .recordStats() .weakValues() - .build, MutableCollection>() - } + .build, MutableCollection>(), + "protobuf-cache" + ) + } else { + CacheBuilder.newBuilder() + .weakValues() + .build, MutableCollection>() } override fun serialize( - resources: MutableCollection, - apiVersion: Resources.ApiVersion - ): MutableCollection { - return if (apiVersion == V3) { - v2Timer.record(Supplier { getResources(resources, apiVersion) }) - } else { - v3Timer.record(Supplier { getResources(resources, apiVersion) }) - } - } + resources: MutableCollection, + apiVersion: Resources.ApiVersion + ): MutableCollection = serializeTimer.record(Supplier { getResources(resources, apiVersion) }) private fun getResources( - resources: MutableCollection, - apiVersion: Resources.ApiVersion + resources: MutableCollection, + apiVersion: Resources.ApiVersion ): MutableCollection { - val cache = when (apiVersion) { - V2 -> cacheV2 - V3 -> cacheV3 - } - return cache.get(resources) { resources.asSequence() .map { super.maybeRewriteTypeUrl(Any.pack(it), apiVersion) } @@ -79,7 +55,7 @@ internal class CachedProtoResourcesSerializer( } @Suppress("NotImplementedDeclaration") - override fun serialize(resource: Message?, apiVersion: Resources.ApiVersion?): Any { + override fun serialize(resource: Message?, apiVersion: Resources.ApiVersion): Any { throw NotImplementedError("Serializing single messages is not supported") } } From 430508c19d24dee4461037a56a093c60f68c01a8 Mon Sep 17 00:00:00 2001 From: slonka Date: Fri, 25 Sep 2020 14:07:57 +0200 Subject: [PATCH 4/6] Remove ApiVersion.V3 from RDS --- .../envoycontrol/server/CachedProtoResourcesSerializer.kt | 8 ++++---- .../snapshot/resource/listeners/EnvoyListenersFactory.kt | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt index e11b58eca..125a98c87 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt @@ -39,13 +39,13 @@ internal class CachedProtoResourcesSerializer( } override fun serialize( - resources: MutableCollection, - apiVersion: Resources.ApiVersion + resources: MutableCollection, + apiVersion: Resources.ApiVersion ): MutableCollection = serializeTimer.record(Supplier { getResources(resources, apiVersion) }) private fun getResources( - resources: MutableCollection, - apiVersion: Resources.ApiVersion + resources: MutableCollection, + apiVersion: Resources.ApiVersion ): MutableCollection { return cache.get(resources) { resources.asSequence() diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt index ef2e5dc90..2434ce2dd 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/snapshot/resource/listeners/EnvoyListenersFactory.kt @@ -12,7 +12,6 @@ import io.envoyproxy.envoy.config.accesslog.v3.StatusCodeFilter import io.envoyproxy.envoy.config.core.v3.Address import io.envoyproxy.envoy.config.core.v3.AggregatedConfigSource import io.envoyproxy.envoy.config.core.v3.ApiConfigSource -import io.envoyproxy.envoy.config.core.v3.ApiVersion import io.envoyproxy.envoy.config.core.v3.ConfigSource import io.envoyproxy.envoy.config.core.v3.GrpcService import io.envoyproxy.envoy.config.core.v3.Http1ProtocolOptions @@ -255,7 +254,6 @@ class EnvoyListenersFactory( private fun egressRds(communicationMode: CommunicationMode): Rds { val configSource = ConfigSource.newBuilder() - .setResourceApiVersion(ApiVersion.V3) .setInitialFetchTimeout(egressRdsInitialFetchTimeout) when (communicationMode) { @@ -309,7 +307,6 @@ class EnvoyListenersFactory( private fun ingressRds(communicationMode: CommunicationMode): Rds { val configSource = ConfigSource.newBuilder() - .setResourceApiVersion(ApiVersion.V3) .setInitialFetchTimeout(ingressRdsInitialFetchTimeout) when (communicationMode) { From b0f4cb2f2d4ce1e9babddb316e1abab473911596 Mon Sep 17 00:00:00 2001 From: slonka Date: Fri, 25 Sep 2020 14:48:45 +0200 Subject: [PATCH 5/6] Restore v2/v3 caches --- .../server/CachedProtoResourcesSerializer.kt | 68 +++++++++++++------ 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt index 125a98c87..da3691dcb 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt @@ -5,48 +5,72 @@ import com.google.common.cache.CacheBuilder import com.google.protobuf.Any import com.google.protobuf.Message import io.envoyproxy.controlplane.cache.Resources -import io.envoyproxy.controlplane.server.serializer.DefaultProtoResourcesSerializer import io.micrometer.core.instrument.MeterRegistry import io.micrometer.core.instrument.binder.cache.GuavaCacheMetrics import pl.allegro.tech.servicemesh.envoycontrol.utils.noopTimer import java.util.function.Supplier +import io.envoyproxy.controlplane.cache.Resources.ApiVersion.V2 +import io.envoyproxy.controlplane.cache.Resources.ApiVersion.V3 +import io.envoyproxy.controlplane.server.serializer.DefaultProtoResourcesSerializer +import io.micrometer.core.instrument.Timer + internal class CachedProtoResourcesSerializer( - meterRegistry: MeterRegistry, - reportMetrics: Boolean + private val meterRegistry: MeterRegistry, + private val reportMetrics: Boolean ) : DefaultProtoResourcesSerializer() { - private val serializeTimer = if (reportMetrics) { - meterRegistry.timer("protobuf-cache.serialize.time") - } else { - noopTimer + private fun createTimer(reportMetrics: Boolean, meterRegistry: MeterRegistry, timerName: String): Timer { + return if (reportMetrics) { + meterRegistry.timer(timerName) + } else { + noopTimer + } } - private val cache: Cache, MutableCollection> = if (reportMetrics) { - GuavaCacheMetrics - .monitor( - meterRegistry, - CacheBuilder.newBuilder() - .recordStats() + private val cacheV2: Cache, MutableCollection> = createCache("protobuf-cache-v2") + private val cacheV3: Cache, MutableCollection> = createCache("protobuf-cache-v3") + private val v2Timer = createTimer(reportMetrics, meterRegistry, "protobuf-cache-v2.serialize.time") + private val v3Timer = createTimer(reportMetrics, meterRegistry, "protobuf-cache-v3.serialize.time") + + private fun createCache(cacheName: String): Cache, MutableCollection> { + return if (reportMetrics) { + GuavaCacheMetrics + .monitor( + meterRegistry, + CacheBuilder.newBuilder() + .recordStats() + .weakValues() + .build, MutableCollection>(), + cacheName + ) + } else { + CacheBuilder.newBuilder() .weakValues() - .build, MutableCollection>(), - "protobuf-cache" - ) - } else { - CacheBuilder.newBuilder() - .weakValues() - .build, MutableCollection>() + .build, MutableCollection>() + } } override fun serialize( resources: MutableCollection, apiVersion: Resources.ApiVersion - ): MutableCollection = serializeTimer.record(Supplier { getResources(resources, apiVersion) }) + ): MutableCollection { + return if (apiVersion == V3) { + v2Timer.record(Supplier { getResources(resources, apiVersion) }) + } else { + v3Timer.record(Supplier { getResources(resources, apiVersion) }) + } + } private fun getResources( resources: MutableCollection, apiVersion: Resources.ApiVersion ): MutableCollection { + val cache = when (apiVersion) { + V2 -> cacheV2 + V3 -> cacheV3 + } + return cache.get(resources) { resources.asSequence() .map { super.maybeRewriteTypeUrl(Any.pack(it), apiVersion) } @@ -55,7 +79,7 @@ internal class CachedProtoResourcesSerializer( } @Suppress("NotImplementedDeclaration") - override fun serialize(resource: Message?, apiVersion: Resources.ApiVersion): Any { + override fun serialize(resource: Message?, apiVersion: Resources.ApiVersion?): Any { throw NotImplementedError("Serializing single messages is not supported") } } From 3aaef754e384dc4241486de7cd338e43b4b612b0 Mon Sep 17 00:00:00 2001 From: slonka Date: Fri, 25 Sep 2020 15:45:06 +0200 Subject: [PATCH 6/6] Fix v2 cache metric --- .../envoycontrol/server/CachedProtoResourcesSerializer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt index da3691dcb..d84e4f652 100644 --- a/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt +++ b/envoy-control-core/src/main/kotlin/pl/allegro/tech/servicemesh/envoycontrol/server/CachedProtoResourcesSerializer.kt @@ -55,7 +55,7 @@ internal class CachedProtoResourcesSerializer( resources: MutableCollection, apiVersion: Resources.ApiVersion ): MutableCollection { - return if (apiVersion == V3) { + return if (apiVersion == V2) { v2Timer.record(Supplier { getResources(resources, apiVersion) }) } else { v3Timer.record(Supplier { getResources(resources, apiVersion) })