fix: translator reports errors for existing clusters and secretes#4707
fix: translator reports errors for existing clusters and secretes#4707zhaohuabing merged 19 commits intoenvoyproxy:mainfrom
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4707 +/- ##
==========================================
+ Coverage 65.63% 65.65% +0.02%
==========================================
Files 211 211
Lines 32017 31996 -21
==========================================
- Hits 21014 21008 -6
+ Misses 9761 9751 -10
+ Partials 1242 1237 -5 ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
87b5867 to
15264f6
Compare
15264f6 to
bda736c
Compare
21c1901 to
a7d7e6b
Compare
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
a7d7e6b to
bd01257
Compare
|
hey @zhaohuabing is the issue that we are generating the same name for the jwks and oidc clusters if both are set in the policy ? shouldnt we be using an additional string value to differentiate them ? |
For the cluster generated by a url, EG uses the host and port for the cluster name to avoid creating duplicated clusters for the same host+port combination. The name of the generated cluster: oidc_example_com_443. We could change this logic to generate an unique name for each single oidc or jwt configuration. However, we should also ensure that the translator shouldn't throw error if the cluster already exists. |
is it safe to reuse the same cluster configuration ? is the naming different when use the backendRefs field ? |
It's safe to reuse the asme cluster for ulr generated cluster as the cluster confiugration is identical for the same host+port combination. For OIDC provider with backendRefs, EG generate an unique cluster name like |
Ha, there is also a bug here, the index is always 0, which generates duplicated name for different clusters if there're both ext auth and oidc whithin a SecurityPolicy. Will fix it in this PR as well. |
nice catch, prob needs another prefix like |
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
| prefix := irRoutePrefix(route) | ||
| parentRefs := GetParentReferences(route) | ||
| var ( | ||
| extAutClusterIndex = 0 |
There was a problem hiding this comment.
A cluster is created for each parent, so an index is added to the cluster name to avoid name conflict.
var (
extAutClusterIndex = 0
oidcClusterIndex = 0
)
for _, p := range parentRefs {
parentRefCtx := GetRouteParentContext(route, p)
gtwCtx := parentRefCtx.GetGateway()
if gtwCtx == nil {
continue
}
var extAuth *ir.ExtAuth
if policy.Spec.ExtAuth != nil {
if extAuth, err = t.buildExtAuth(
policy,
resources,
gtwCtx.envoyProxy,
extAutClusterIndex,
); err != nil {
err = perr.WithMessage(err, "ExtAuth")
errs = errors.Join(errs, err)
}
extAutClusterIndex++
}
var oidc *ir.OIDC
if policy.Spec.OIDC != nil {
if oidc, err = t.buildOIDC(
policy,
resources,
gtwCtx.envoyProxy, // TODO zhaohuabing: Only the last EnvoyProxy will be used as the OIDC name doesn't include the cluster index
oidcClusterIndex,
); err != nil {
err = perr.WithMessage(err, "OIDC")
errs = errors.Join(errs, err)
}
oidcClusterIndex++
}
...
}
return errs
}There was a problem hiding this comment.
It's the same policy though, can't the clusters be reused ?
There was a problem hiding this comment.
It's because the EnvoyProxy configuration is different for each parent.
There's still an issue here, only the last one will be applied as the OIDC name is identical, I've added a TODO and will address this later in a follow-up PR.
There was a problem hiding this comment.
if its due to envoy proxy resource attributes that make the cluster unique, then lets append /<ns>-<name>/ of EP instead to maximize reuse ?
There was a problem hiding this comment.
or listener name, the index here is not used to debug and is not useful for reuse
There was a problem hiding this comment.
Rethinking on this, since EnvoyProxy is an optional parameter, its name may not be suitable to be used as part of the generated cluster name. We can always use EndpointRoutingType or ServiceRoutingType for OIDC, ExtProc, and other none-route backend clusters and don't need to use the RoutingType in the EnvoyProxy.
@arkodg Could we address this in a follow-up PR for #4720? This is a minor issue and won't break OIDC. Addressing it in a separate PR will make cherry-picking to v1.2.2 easier.
There was a problem hiding this comment.
@zhaohuabing I'd prefer if we removed the index altogether and raised another GH issue for dealing with policies targeting routes linked to multiple envoy proxies that are impacting the upstream TLS.
Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
…voyproxy#4707) * fix: existing clusters and secretes Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix cluster index for SP Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add comment Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * remove index Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com>
* fix: tcp listener is rejected when no route attached (#4681) * fix: tcp listener is rejected when no route attached Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * change cluter name Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix listener connection limit test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix listener connetcp keepalive test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix tcp endpoint stats test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix tcp-route-enable-req-resp-sizes-stats Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix extensionpolicy-tcp-udp-http test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit f99c36c) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix: remove backendrefs validation (#4705) * remove backendrefs validation Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add tests Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add tests Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> (cherry picked from commit 5068698) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix: translator reports errors for existing clusters and secretes (#4707) * fix: existing clusters and secretes Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix cluster index for SP Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add comment Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * remove index Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * xds: always use `::` and `IPv4Compact` for dynamic listener (#4743) * enable IPv4Compact Signed-off-by: zirain <zirain2009@gmail.com> * fix xds test Signed-off-by: zirain <zirain2009@gmail.com> * release-notes Signed-off-by: zirain <zirain2009@gmail.com> * nit Signed-off-by: zirain <zirain2009@gmail.com> * gen Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> (cherry picked from commit 78da42c) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * Fix: frequent 503 errors when connecting to a Service experiencing high Pod churn (#4754) * Revert "fix: some status updates are discarded by the status updater (#4337)" This reverts commit 14830c7. Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * store update events and process it later Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * rename method Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add release note Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * xds: use V4_PREFERRED dnsLookupFamily by default (#4745) * use Cluster_V4_PREFERRED Signed-off-by: zirain <zirain2009@gmail.com> * release notes Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com>
) * fix: tcp listener is rejected when no route attached (envoyproxy#4681) * fix: tcp listener is rejected when no route attached Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * change cluter name Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix listener connection limit test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix listener connetcp keepalive test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix tcp endpoint stats test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix tcp-route-enable-req-resp-sizes-stats Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix extensionpolicy-tcp-udp-http test Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> (cherry picked from commit f99c36c) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix: remove backendrefs validation (envoyproxy#4705) * remove backendrefs validation Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add tests Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add tests Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com> (cherry picked from commit 5068698) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix: translator reports errors for existing clusters and secretes (envoyproxy#4707) * fix: existing clusters and secretes Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix cluster index for SP Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * minor change Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add comment Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * remove index Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * fix lint Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * xds: always use `::` and `IPv4Compact` for dynamic listener (envoyproxy#4743) * enable IPv4Compact Signed-off-by: zirain <zirain2009@gmail.com> * fix xds test Signed-off-by: zirain <zirain2009@gmail.com> * release-notes Signed-off-by: zirain <zirain2009@gmail.com> * nit Signed-off-by: zirain <zirain2009@gmail.com> * gen Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> (cherry picked from commit 78da42c) Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * Fix: frequent 503 errors when connecting to a Service experiencing high Pod churn (envoyproxy#4754) * Revert "fix: some status updates are discarded by the status updater (envoyproxy#4337)" This reverts commit 14830c7. Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * store update events and process it later Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * rename method Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * add release note Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> * xds: use V4_PREFERRED dnsLookupFamily by default (envoyproxy#4745) * use Cluster_V4_PREFERRED Signed-off-by: zirain <zirain2009@gmail.com> * release notes Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: Huabing Zhao <zhaohuabing@gmail.com> Signed-off-by: zirain <zirain2009@gmail.com> Co-authored-by: zirain <zirain2009@gmail.com>
Fixes #4706 xDS translation failed when oidc tokenEndpoint and jwt remoteJWKS are specified within the same security policy and using the same hostname
Refactor: skips adding the cluster/secrets and returns nil to make the code cleaner and easier to maintain. It's safe to remove
ErrXdsClusterExistsandErrXdsSecretsExistsas they don't need to be handled in any places.Release Notes: Yes
Test before the fix:
After: