Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]

### Changed
- Remove xds support

## [0.19.24]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package pl.allegro.tech.servicemesh.envoycontrol.groups

sealed class Group {
abstract val communicationMode: CommunicationMode
abstract val serviceName: String
abstract val discoveryServiceName: String?
abstract val proxySettings: ProxySettings
abstract val listenersConfig: ListenersConfig?
}

data class ServicesGroup(
override val communicationMode: CommunicationMode,
override val serviceName: String = "",
override val discoveryServiceName: String? = null,
override val proxySettings: ProxySettings = ProxySettings(),
override val listenersConfig: ListenersConfig? = null
) : Group()

data class AllServicesGroup(
override val communicationMode: CommunicationMode,
override val serviceName: String = "",
override val discoveryServiceName: String? = null,
override val proxySettings: ProxySettings = ProxySettings(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,13 @@ class MetadataNodeGroup(
return when {
hasAllServicesDependencies(nodeMetadata) ->
AllServicesGroup(
nodeMetadata.communicationMode,
serviceName,
discoveryServiceName,
proxySettings,
listenersConfig
)
else ->
ServicesGroup(
nodeMetadata.communicationMode,
serviceName,
discoveryServiceName,
proxySettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class NodeMetadata(metadata: Struct, properties: SnapshotProperties) {
.fieldsMap["discovery_service_name"]
?.stringValue

val communicationMode = getCommunicationMode(metadata.fieldsMap["ads"])

val proxySettings: ProxySettings = ProxySettings(metadata.fieldsMap["proxy_settings"], properties)
}

Expand Down Expand Up @@ -63,17 +61,6 @@ data class ProxySettings(
)
}

private fun getCommunicationMode(proto: Value?): CommunicationMode {
val ads = proto
?.boolValue
?: false

return when (ads) {
true -> CommunicationMode.ADS
else -> CommunicationMode.XDS
}
}

fun Value?.toComparisonFilter(default: String? = null): ComparisonFilterSettings? {
return (this?.stringValue ?: default)?.let {
AccessLogFilterParser.parseComparisonFilter(it.uppercase())
Expand Down Expand Up @@ -673,10 +660,6 @@ enum class PathMatchingType {
PATH, PATH_PREFIX, PATH_REGEX
}

enum class CommunicationMode {
ADS, XDS
}

data class OAuth(
val provider: String = "",
val verification: Verification = Verification.OFFLINE,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package pl.allegro.tech.servicemesh.envoycontrol.groups

import io.envoyproxy.controlplane.server.DiscoveryServerCallbacks
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.XDS
import pl.allegro.tech.servicemesh.envoycontrol.logger
import pl.allegro.tech.servicemesh.envoycontrol.protocol.HttpMethod
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties
Expand Down Expand Up @@ -84,7 +82,6 @@ class NodeMetadataValidator(
validateDependencies(metadata)
validateIncomingEndpoints(metadata)
validateIncomingRateLimitEndpoints(metadata)
validateConfigurationMode(metadata)
}

private fun validateServiceName(metadata: NodeMetadata) {
Expand Down Expand Up @@ -170,13 +167,4 @@ class NodeMetadataValidator(

private fun isAllowedToHaveAllServiceDependencies(metadata: NodeMetadata) = properties
.outgoingPermissions.servicesAllowedToUseWildcard.contains(metadata.serviceName)

private fun validateConfigurationMode(metadata: NodeMetadata) {
if (metadata.communicationMode == ADS && !properties.enabledCommunicationModes.ads) {
throw ConfigurationModeNotSupportedException(metadata.serviceName, "ADS")
}
if (metadata.communicationMode == XDS && !properties.enabledCommunicationModes.xds) {
throw ConfigurationModeNotSupportedException(metadata.serviceName, "XDS")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MetricsDiscoveryServerCallbacks(private val meterRegistry: MeterRegistry)

meterRegistry.gauge("grpc.all-connections", connections)
connectionsByType.forEach { (type, typeConnections) ->
meterRegistry.gauge("grpc.connections.${type.name.toLowerCase()}", typeConnections)
meterRegistry.gauge("grpc.connections.${type.name.lowercase()}", typeConnections)
}
}

Expand All @@ -51,15 +51,15 @@ class MetricsDiscoveryServerCallbacks(private val meterRegistry: MeterRegistry)
}

override fun onV3StreamRequest(streamId: Long, request: V3DiscoveryRequest) {
meterRegistry.counter("grpc.requests.${StreamType.fromTypeUrl(request.typeUrl).name.toLowerCase()}")
meterRegistry.counter("grpc.requests.${StreamType.fromTypeUrl(request.typeUrl).name.lowercase()}")
.increment()
}

override fun onV3StreamDeltaRequest(
streamId: Long,
request: V3DeltaDiscoveryRequest
) {
meterRegistry.counter("grpc.requests.${StreamType.fromTypeUrl(request.typeUrl).name.toLowerCase()}.delta")
meterRegistry.counter("grpc.requests.${StreamType.fromTypeUrl(request.typeUrl).name.lowercase()}.delta")
.increment()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ 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
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode
import pl.allegro.tech.servicemesh.envoycontrol.groups.DependencySettings
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
import pl.allegro.tech.servicemesh.envoycontrol.groups.IncomingRateLimitEndpoint
Expand Down Expand Up @@ -41,14 +40,12 @@ class EnvoySnapshotFactory(

fun newSnapshot(
servicesStates: MultiClusterState,
clusterConfigurations: Map<String, ClusterConfiguration>,
communicationMode: CommunicationMode
clusterConfigurations: Map<String, ClusterConfiguration>
): GlobalSnapshot {
val sample = Timer.start(meterRegistry)

val clusters = clustersFactory.getClustersForServices(
clusterConfigurations.values,
communicationMode
clusterConfigurations.values
)
val securedClusters = clustersFactory.getSecuredClusters(clusters)

Expand Down Expand Up @@ -318,7 +315,7 @@ class EnvoySnapshotFactory(
routes.add(
egressRoutesFactory.createEgressDomainRoutes(
it.value,
it.key.port.toString().toLowerCase()
it.key.port.toString().lowercase()
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class SnapshotProperties {
var staticClusterConnectionTimeout: Duration = Duration.ofSeconds(2)
var trustedCaFile = "/etc/ssl/certs/ca-certificates.crt"
var dynamicListeners = ListenersFactoryProperties()
var enabledCommunicationModes = EnabledCommunicationModes()
var shouldSendMissingEndpoints = false
var metrics: MetricsProperties = MetricsProperties()
var dynamicForwardProxy = DynamicForwardProxyProperties()
Expand Down Expand Up @@ -296,11 +295,6 @@ class Http2Properties {
var tagName = "envoy"
}

class EnabledCommunicationModes {
var ads = true
var xds = true
}

class HostHeaderRewritingProperties {
var enabled = false
var customHostHeader = "x-envoy-original-host"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import io.envoyproxy.controlplane.cache.SnapshotCache
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
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.XDS
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
import pl.allegro.tech.servicemesh.envoycontrol.logger
import pl.allegro.tech.servicemesh.envoycontrol.services.MultiClusterState
Expand Down Expand Up @@ -59,8 +57,7 @@ class SnapshotUpdater(
UpdateResult(
action = newUpdate.action,
groups = newUpdate.groups,
adsSnapshot = newUpdate.adsSnapshot ?: previous.adsSnapshot,
xdsSnapshot = newUpdate.xdsSnapshot ?: previous.xdsSnapshot
snapshot = newUpdate.snapshot ?: previous.snapshot
)
}
// concat map guarantees sequential processing (unlike flatMap)
Expand All @@ -74,7 +71,7 @@ class SnapshotUpdater(
// step 4: update the snapshot for either all groups (if services changed)
// or specific groups (groups changed).
// TODO(dj): on what occasion can this be false?
if (result.adsSnapshot != null || result.xdsSnapshot != null) {
if (result.snapshot != null) {
// Stateful operation! This is the meat of this processing.
updateSnapshotForGroups(groups, result)
} else {
Expand Down Expand Up @@ -111,19 +108,9 @@ class SnapshotUpdater(
.name("snapshot-updater-services-published").metrics()
.createClusterConfigurations()
.map { (states, clusters) ->
var lastXdsSnapshot: GlobalSnapshot? = null
var lastAdsSnapshot: GlobalSnapshot? = null

if (properties.enabledCommunicationModes.xds) {
lastXdsSnapshot = snapshotFactory.newSnapshot(states, clusters, XDS)
}
if (properties.enabledCommunicationModes.ads) {
lastAdsSnapshot = snapshotFactory.newSnapshot(states, clusters, ADS)
}
val updateResult = UpdateResult(
action = Action.ALL_SERVICES_GROUP_ADDED,
adsSnapshot = lastAdsSnapshot,
xdsSnapshot = lastXdsSnapshot
snapshot = snapshotFactory.newSnapshot(states, clusters),
)
globalSnapshot = updateResult
updateResult
Expand Down Expand Up @@ -169,13 +156,11 @@ class SnapshotUpdater(
versions.retainGroups(cache.groups())
val results = Flux.fromIterable(groups)
.doOnNextScheduledOn(groupSnapshotScheduler) { group ->
if (result.adsSnapshot != null && group.communicationMode == ADS) {
updateSnapshotForGroup(group, result.adsSnapshot)
} else if (result.xdsSnapshot != null && group.communicationMode == XDS) {
updateSnapshotForGroup(group, result.xdsSnapshot)
if (result.snapshot != null) {
updateSnapshotForGroup(group, result.snapshot)
} else {
meterRegistry.counter("snapshot-updater.communication-mode.errors").increment()
logger.error("Requested snapshot for ${group.communicationMode.name} mode, but it is not here. " +
logger.error("Requested snapshot, but it is not here. " +
"Handling Envoy with not supported communication mode should have been rejected before." +
" Please report this to EC developers.")
}
Expand Down Expand Up @@ -212,6 +197,5 @@ enum class Action {
data class UpdateResult(
val action: Action,
val groups: List<Group> = listOf(),
val adsSnapshot: GlobalSnapshot? = null,
val xdsSnapshot: GlobalSnapshot? = null
val snapshot: GlobalSnapshot? = null
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ 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.ApiVersion
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
Expand All @@ -36,9 +34,6 @@ 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 pl.allegro.tech.servicemesh.envoycontrol.groups.AllServicesGroup
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.ADS
import pl.allegro.tech.servicemesh.envoycontrol.groups.CommunicationMode.XDS
import pl.allegro.tech.servicemesh.envoycontrol.groups.DependencySettings
import pl.allegro.tech.servicemesh.envoycontrol.groups.DomainDependency
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
Expand Down Expand Up @@ -77,10 +72,9 @@ class EnvoyClustersFactory(
}

fun getClustersForServices(
services: Collection<ClusterConfiguration>,
communicationMode: CommunicationMode
services: Collection<ClusterConfiguration>
): List<Cluster> {
return services.map { edsCluster(it, communicationMode) }
return services.map { edsCluster(it) }
}

fun getSecuredClusters(insecureClusters: List<Cluster>): List<Cluster> {
Expand Down Expand Up @@ -351,8 +345,7 @@ class EnvoyClustersFactory(
}

private fun edsCluster(
clusterConfiguration: ClusterConfiguration,
communicationMode: CommunicationMode
clusterConfiguration: ClusterConfiguration
): Cluster {
val clusterBuilder = Cluster.newBuilder()

Expand All @@ -366,32 +359,9 @@ class EnvoyClustersFactory(
.setConnectTimeout(Durations.fromMillis(properties.edsConnectionTimeout.toMillis()))
.setEdsClusterConfig(
Cluster.EdsClusterConfig.newBuilder().setEdsConfig(
when (communicationMode) {
// here we do not have group information
ADS -> ConfigSource.newBuilder()
.setResourceApiVersion(ApiVersion.V3)
.setAds(AggregatedConfigSource.newBuilder())
XDS ->
ConfigSource.newBuilder()
.setResourceApiVersion(ApiVersion.V3)
.setApiConfigSource(
ApiConfigSource.newBuilder()
.setApiType(
if (properties.deltaXdsEnabled) {
ApiConfigSource.ApiType.DELTA_GRPC
} else {
ApiConfigSource.ApiType.GRPC
}
)
.setTransportApiVersion(ApiVersion.V3)
.addGrpcServices(
0, GrpcService.newBuilder().setEnvoyGrpc(
GrpcService.EnvoyGrpc.newBuilder()
.setClusterName(properties.xdsClusterName)
)
)
)
}
ConfigSource.newBuilder()
.setResourceApiVersion(ApiVersion.V3)
.setAds(AggregatedConfigSource.newBuilder())
).setServiceName(clusterConfiguration.serviceName)
)
.setLbPolicy(properties.loadBalancing.policy)
Expand Down Expand Up @@ -494,7 +464,7 @@ class EnvoyClustersFactory(
thresholdsBuilder.maxPendingRequests = UInt32Value.of(threshold.maxPendingRequests)
thresholdsBuilder.maxRequests = UInt32Value.of(threshold.maxRequests)
thresholdsBuilder.maxRetries = UInt32Value.of(threshold.maxRetries)
when (threshold.priority.toUpperCase()) {
when (threshold.priority.uppercase()) {
"DEFAULT" -> thresholdsBuilder.priority = RoutingPriority.DEFAULT
"HIGH" -> thresholdsBuilder.priority = RoutingPriority.HIGH
else -> thresholdsBuilder.priority = RoutingPriority.UNRECOGNIZED
Expand Down
Loading