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 4da55cf3b..3e8d217d4 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 @@ -8,16 +8,13 @@ import io.envoyproxy.envoy.config.core.v3.Metadata 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.logger import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotProperties import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.LuaMetadataProperty.ListPropertyLua import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.LuaMetadataProperty.StringPropertyLua import pl.allegro.tech.servicemesh.envoycontrol.snapshot.resource.listeners.filters.LuaMetadataProperty.StructPropertyLua class LuaFilterFactory(private val snapshotProperties: SnapshotProperties) { - companion object { - private val logger by logger() - } + private val ingressRbacLoggingScript: String = this::class.java.classLoader .getResource("lua/ingress_rbac_logging.lua")!!.readText() @@ -90,7 +87,6 @@ class LuaFilterFactory(private val snapshotProperties: SnapshotProperties) { ), "current_zone" to StringPropertyLua(currentZone) ) + customLuaMetadata - logger.info("LuaFilterMetadata, currentZone: $currentZone") return Metadata.newBuilder() .putFilterMetadata("envoy.filters.http.lua", metadata.toValue().structValue) .build() @@ -99,9 +95,7 @@ class LuaFilterFactory(private val snapshotProperties: SnapshotProperties) { fun ingressClientNameHeaderFilter(): HttpFilter? = ingressClientNameHeaderFilter.takeIf { trustedClientIdentityHeader.isNotEmpty() } - fun ingressCurrentZoneHeaderFilter(): HttpFilter = ingressCurrentZoneHeaderFilter.also { - logger.info("Included ingressCurrentZoneHeaderFilter") - } + fun ingressCurrentZoneHeaderFilter(): HttpFilter = ingressCurrentZoneHeaderFilter } sealed class LuaMetadataProperty(open val value: T) { diff --git a/envoy-control-core/src/main/resources/lua/ingress_current_zone_header.lua b/envoy-control-core/src/main/resources/lua/ingress_current_zone_header.lua index 7d2b7d673..209837971 100644 --- a/envoy-control-core/src/main/resources/lua/ingress_current_zone_header.lua +++ b/envoy-control-core/src/main/resources/lua/ingress_current_zone_header.lua @@ -1,11 +1,8 @@ -function envoy_on_request(handle) - local traffic_splitting_zone_header_name = handle:metadata():get("traffic_splitting_zone_header_name") or "" +function envoy_on_response(handle) + local traffic_splitting_zone_header_name = handle:metadata():get("traffic_splitting_zone_header_name") or "" local current_zone = handle:metadata():get("current_zone") or "" if traffic_splitting_zone_header_name == "" then return end handle:headers():add(traffic_splitting_zone_header_name, current_zone) end - -function envoy_on_response(handle) -end diff --git a/envoy-control-tests/src/main/resources/lua_spec/ingress_current_zone_header_spec.lua b/envoy-control-tests/src/main/resources/lua_spec/ingress_current_zone_header_spec.lua index accac8e8a..d526dacae 100644 --- a/envoy-control-tests/src/main/resources/lua_spec/ingress_current_zone_header_spec.lua +++ b/envoy-control-tests/src/main/resources/lua_spec/ingress_current_zone_header_spec.lua @@ -18,7 +18,7 @@ local function handlerMock(headers, metadata) } end -describe("envoy_on_request:", function() +describe("envoy_on_response:", function() it("should set current zone header", function() -- given local filter_metadata = { @@ -29,7 +29,7 @@ describe("envoy_on_request:", function() local handle = handlerMock(headers, filter_metadata) -- when - envoy_on_request(handle) + envoy_on_response(handle) -- then assert.are.equal('local-dc', headers['x-current-zone']) @@ -45,7 +45,7 @@ describe("envoy_on_request:", function() local handle = handlerMock(headers, filter_metadata) -- when - envoy_on_request(handle) + envoy_on_response(handle) -- then assert.are.equal('local-dc-0,local-dc', headers['x-current-zone']) @@ -60,7 +60,7 @@ describe("envoy_on_request:", function() local handle = handlerMock(headers, filter_metadata) -- when - envoy_on_request(handle) + envoy_on_response(handle) -- then assert.are.equal(nil, headers['x-current-zone']) @@ -77,7 +77,7 @@ describe("envoy_on_request:", function() local handle = handlerMock(headers, filter_metadata) -- when - envoy_on_request(handle) + envoy_on_response(handle) -- then assert.are.equal('', headers['x-current-zone'])