Skip to content

Commit 055321d

Browse files
committed
remove skip
Signed-off-by: zirain <zirain2009@gmail.com>
1 parent bb37df4 commit 055321d

5 files changed

Lines changed: 27 additions & 44 deletions

File tree

internal/xds/translator/jsonpatch.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (t typedName) String() string {
4747
}
4848

4949
// processJSONPatches applies each JSONPatch to the Xds Resources for a specific type.
50-
func processJSONPatches(tCtx *types.ResourceVersionTable, gResources *ir.GlobalResources, envoyPatchPolicies []*ir.EnvoyPatchPolicy) error {
50+
func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*ir.EnvoyPatchPolicy) error {
5151
var errs error
5252

5353
for _, e := range envoyPatchPolicies {
@@ -107,7 +107,7 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, gResources *ir.GlobalR
107107
}
108108

109109
// find the resources to patch and convert them to JSON
110-
dests, err = findXdsResources(tCtx, gResources, p)
110+
dests, err = findXdsResources(tCtx, p)
111111
if err != nil {
112112
tErrs = errors.Join(tErrs, err)
113113
continue
@@ -226,19 +226,19 @@ var jsonMarshalOpts = protojson.MarshalOptions{
226226
}
227227

228228
// findXdsResources returns XDS resources to patch based on the patch configuration.
229-
func findXdsResources(tCtx *types.ResourceVersionTable, gResources *ir.GlobalResources, p *ir.JSONPatchConfig) ([]cachetypes.Resource, error) {
229+
func findXdsResources(tCtx *types.ResourceVersionTable, p *ir.JSONPatchConfig) ([]cachetypes.Resource, error) {
230230
var resources []cachetypes.Resource
231231
switch p.Type {
232232
case resourcev3.ListenerType:
233233
resources = findXdsListeners(tCtx, &p.Name)
234234
case resourcev3.RouteType:
235235
resources = findXdsRouteConfigs(tCtx, &p.Name)
236236
case resourcev3.ClusterType:
237-
resources = findXdsClusters(tCtx, gResources, &p.Name)
237+
resources = findXdsClusters(tCtx, &p.Name)
238238
case resourcev3.EndpointType:
239-
resources = findXdsEndpoints(tCtx, gResources, &p.Name)
239+
resources = findXdsEndpoints(tCtx, &p.Name)
240240
case resourcev3.SecretType:
241-
resources = findXdsSecrets(tCtx, gResources, &p.Name)
241+
resources = findXdsSecrets(tCtx, &p.Name)
242242
default:
243243
return nil, fmt.Errorf("unsupported patch type %s", p.Type)
244244
}

internal/xds/translator/testdata/out/xds-ir/jsonpatch-patch-multiple-resources.clusters.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
name: second-route-dest
4747
perConnectionBufferLimitBytes: 32768
4848
type: EDS
49-
- circuitBreakers:
49+
- altStatName: altStatName
50+
circuitBreakers:
5051
thresholds:
5152
- maxRetries: 1024
5253
commonLbConfig: {}

internal/xds/translator/testdata/out/xds-ir/jsonpatch-patch-multiple-resources.listeners.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@
99
typedConfig:
1010
'@type': type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
1111
httpFilters:
12+
- name: envoy.filters.http.ratelimit
13+
typedConfig:
14+
'@type': type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit
15+
domain: eg-ratelimit
16+
failureModeDeny: true
17+
rateLimitService:
18+
grpcService:
19+
envoyGrpc:
20+
clusterName: rate-limit-cluster
21+
transportApiVersion: V3
22+
timeout: 1s
1223
- name: envoy.filters.http.health_check
1324
typedConfig:
1425
'@type': type.googleapis.com/envoy.extensions.filters.http.health_check.v3.HealthCheck
@@ -21,6 +32,7 @@
2132
typedConfig:
2233
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
2334
suppressEnvoyHeaders: true
35+
preserveExternalRequestId: true
2436
routeConfig:
2537
name: ready_route
2638
virtualHosts:

internal/xds/translator/testdata/out/xds-ir/jsonpatch-patch-multiple-resources.secrets.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- name: envoy-gateway-system/envoy
1414
tlsC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kxNeGl3TkdqYm1FUFJ6K3c2TngrazBBOEtFY0lEc0tjClNYY2k1OHU0b1didFZKQmx6YS9adWpIUjZQMUJuT3BsK2FveTc4NGJiZDRQMzl3VExvWGZNZmJCQ20xdmV2aDkKQUpLbncyWnRxcjRta2JMY3hFcWxxM3NCTEZBUzlzUUxuS05DZTJjR0xkVHAyYm9HK3FjZ3lRZ0NJTTZmOEVNdgpXUGlmQ01NR3V6Sy9HUkY0YlBPL1lGNDhld0R1M1VlaWgwWFhkVUFPRTlDdFVhOE5JaGMxVVBhT3pQcnRZVnFyClpPR2t2L0t1K0I3OGg4U0VzTzlYclFjdXdiT25KeDZLdFIrYWV5a3ZBcFhDUTNmWkMvYllLQUFSK1A4QUpvUVoKYndJVW1YaTRnajVtK2JLUGhlK2lyK0U9Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0=
16+
inlineBytes: cmVwbGFjZWQtc2VjcmV0
1717
privateKey:
1818
inlineBytes: W3JlZGFjdGVkXQ==
1919
- name: test_secret

internal/xds/translator/translator.go

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ func (t *Translator) Translate(xdsIR *ir.Xds) (*types.ResourceVersionTable, erro
160160
}
161161

162162
// All XDS resources is ready, let's do the patch.
163-
if err := processJSONPatches(tCtx, xdsIR.GlobalResources, xdsIR.EnvoyPatchPolicies); err != nil {
163+
if err := processJSONPatches(tCtx, xdsIR.EnvoyPatchPolicies); err != nil {
164164
// Since JSONPatch error is user-triggered, we don't fail the entire xDS translation so that the remaining
165165
// valid xDS resources can be sent to the proxy.
166166
t.Logger.Error(err, "Failed to process JSON patches")
@@ -1008,9 +1008,6 @@ func findXdsListeners(tCtx *types.ResourceVersionTable, name *ir.StringMatch) []
10081008
if !ok {
10091009
continue
10101010
}
1011-
if strings.HasPrefix(listener.Name, readyListenerPrefix) {
1012-
continue
1013-
}
10141011
if stringMatched(name, listener.Name) {
10151012
result = append(result, r)
10161013
}
@@ -1050,33 +1047,25 @@ func findXdsRouteConfigs(tCtx *types.ResourceVersionTable, name *ir.StringMatch)
10501047

10511048
// findXdsCluster finds a xds cluster with the same name, and returns nil if there is no match.
10521049
func findXdsCluster(tCtx *types.ResourceVersionTable, name string) *clusterv3.Cluster {
1053-
resources := findXdsClusters(tCtx, nil, &ir.StringMatch{Exact: &name})
1050+
resources := findXdsClusters(tCtx, &ir.StringMatch{Exact: &name})
10541051
if len(resources) > 0 {
10551052
return resources[0].(*clusterv3.Cluster)
10561053
}
10571054
return nil
10581055
}
10591056

10601057
// findXdsClusters finds xds clusters.
1061-
func findXdsClusters(tCtx *types.ResourceVersionTable, gResources *ir.GlobalResources, name *ir.StringMatch) []cachetypes.Resource {
1058+
func findXdsClusters(tCtx *types.ResourceVersionTable, name *ir.StringMatch) []cachetypes.Resource {
10621059
if tCtx == nil || tCtx.XdsResources == nil || tCtx.XdsResources[resourcev3.ClusterType] == nil {
10631060
return nil
10641061
}
10651062

1066-
skippedClusters := sets.New(getRateLimitServiceClusterName(), wasmHTTPServiceClusterName)
1067-
// skip. proxy service cluster
1068-
if gResources != nil && gResources.ProxyServiceCluster != nil {
1069-
skippedClusters.Insert(gResources.ProxyServiceCluster.Name)
1070-
}
10711063
var result []cachetypes.Resource
10721064
for _, r := range tCtx.XdsResources[resourcev3.ClusterType] {
10731065
cluster, ok := r.(*clusterv3.Cluster)
10741066
if !ok {
10751067
continue
10761068
}
1077-
if skippedClusters.Has(cluster.Name) {
1078-
continue
1079-
}
10801069
if stringMatched(name, cluster.Name) {
10811070
result = append(result, r)
10821071
}
@@ -1086,24 +1075,16 @@ func findXdsClusters(tCtx *types.ResourceVersionTable, gResources *ir.GlobalReso
10861075
}
10871076

10881077
// findXdsEndpoints finds xds endpoints.
1089-
func findXdsEndpoints(tCtx *types.ResourceVersionTable, gResources *ir.GlobalResources, name *ir.StringMatch) []cachetypes.Resource {
1078+
func findXdsEndpoints(tCtx *types.ResourceVersionTable, name *ir.StringMatch) []cachetypes.Resource {
10901079
if tCtx == nil || tCtx.XdsResources == nil || tCtx.XdsResources[resourcev3.EndpointType] == nil {
10911080
return nil
10921081
}
1093-
skippedClusters := sets.New(getRateLimitServiceClusterName(), wasmHTTPServiceClusterName)
1094-
// skip. proxy service cluster
1095-
if gResources != nil && gResources.ProxyServiceCluster != nil {
1096-
skippedClusters.Insert(gResources.ProxyServiceCluster.Name)
1097-
}
10981082
var result []cachetypes.Resource
10991083
for _, r := range tCtx.XdsResources[resourcev3.EndpointType] {
11001084
endpoint, ok := r.(*endpointv3.ClusterLoadAssignment)
11011085
if !ok {
11021086
continue
11031087
}
1104-
if skippedClusters.Has(endpoint.ClusterName) {
1105-
continue
1106-
}
11071088
if stringMatched(name, endpoint.ClusterName) {
11081089
result = append(result, r)
11091090
}
@@ -1114,35 +1095,24 @@ func findXdsEndpoints(tCtx *types.ResourceVersionTable, gResources *ir.GlobalRes
11141095

11151096
// findXdsSecret finds a xds secret with the same name, and returns nil if there is no match.
11161097
func findXdsSecret(tCtx *types.ResourceVersionTable, name string) *tlsv3.Secret {
1117-
resources := findXdsSecrets(tCtx, nil, &ir.StringMatch{Exact: &name})
1098+
resources := findXdsSecrets(tCtx, &ir.StringMatch{Exact: &name})
11181099
if len(resources) > 0 {
11191100
return resources[0].(*tlsv3.Secret)
11201101
}
11211102
return nil
11221103
}
11231104

11241105
// findXdsSecrets finds xds secrets.
1125-
func findXdsSecrets(tCtx *types.ResourceVersionTable, gResources *ir.GlobalResources, name *ir.StringMatch) []cachetypes.Resource {
1106+
func findXdsSecrets(tCtx *types.ResourceVersionTable, name *ir.StringMatch) []cachetypes.Resource {
11261107
if tCtx == nil || tCtx.XdsResources == nil || tCtx.XdsResources[resourcev3.SecretType] == nil {
11271108
return nil
11281109
}
1129-
// skip secrets that are used for
1130-
skippedSecrets := sets.New(
1131-
"xds_trusted_ca", "jwt-sa-bearer",
1132-
)
1133-
// envoy client certificate
1134-
if gResources != nil && gResources.EnvoyClientCertificate != nil {
1135-
skippedSecrets.Insert(gResources.EnvoyClientCertificate.Name)
1136-
}
11371110
var result []cachetypes.Resource
11381111
for _, r := range tCtx.XdsResources[resourcev3.SecretType] {
11391112
secret, ok := r.(*tlsv3.Secret)
11401113
if !ok {
11411114
continue
11421115
}
1143-
if skippedSecrets.Has(secret.Name) {
1144-
continue
1145-
}
11461116
if stringMatched(name, secret.Name) {
11471117
result = append(result, r)
11481118
}

0 commit comments

Comments
 (0)