diff --git a/agent/structs/config_entry_discoverychain.go b/agent/structs/config_entry_discoverychain.go index 8f55c6dbba7d..1c929bc90ae5 100644 --- a/agent/structs/config_entry_discoverychain.go +++ b/agent/structs/config_entry_discoverychain.go @@ -115,9 +115,8 @@ func (e *ServiceRouterConfigEntry) Validate() error { if hdr.Suffix != "" { hdrParts++ } - // "absent" is the bare invert=true - if (hdrParts == 0 && !hdr.Invert) || (hdrParts > 1) { - return fmt.Errorf("Route[%d] Header[%d] should only contain one of Present, Exact, Prefix, Suffix, or Regex (or just Invert)", i, j) + if hdrParts != 1 { + return fmt.Errorf("Route[%d] Header[%d] should only contain one of Present, Exact, Prefix, Suffix, or Regex", i, j) } } diff --git a/agent/structs/config_entry_discoverychain_test.go b/agent/structs/config_entry_discoverychain_test.go index 48610607fb13..8e3310e5663b 100644 --- a/agent/structs/config_entry_discoverychain_test.go +++ b/agent/structs/config_entry_discoverychain_test.go @@ -883,9 +883,9 @@ func TestServiceRouterConfigEntry(t *testing.T) { { name: "route with header not present", entry: makerouter(routeMatch(httpMatchHeader(ServiceRouteHTTPMatchHeader{ - Name: "foo", - Invert: true, - //Present: false, + Name: "foo", + Present: true, + Invert: true, }))), }, { diff --git a/agent/xds/routes.go b/agent/xds/routes.go index 1954d7f970d0..d8569db862b1 100644 --- a/agent/xds/routes.go +++ b/agent/xds/routes.go @@ -240,12 +240,6 @@ func makeRouteMatchForDiscoveryRoute(discoveryRoute *structs.DiscoveryRoute, pro eh.HeaderMatchSpecifier = &envoyroute.HeaderMatcher_PresentMatch{ PresentMatch: true, } - case hdr.Invert: // THIS HAS TO BE LAST - eh.HeaderMatchSpecifier = &envoyroute.HeaderMatcher_PresentMatch{ - // We set this to the misleading value of 'true' here - // because we'll generically invert it next. - PresentMatch: true, - } default: continue // skip this impossible situation } diff --git a/agent/xds/routes_test.go b/agent/xds/routes_test.go index 5c3d15c3ffdb..23c241ce3f88 100644 --- a/agent/xds/routes_test.go +++ b/agent/xds/routes_test.go @@ -156,8 +156,9 @@ func TestRoutesFromSnapshot(t *testing.T) { }, { Match: httpMatchHeader(structs.ServiceRouteHTTPMatchHeader{ - Name: "x-debug", - Invert: true, + Name: "x-debug", + Present: true, + Invert: true, }), Destination: toService("hdr-not-present"), },