Skip to content

Commit e721c79

Browse files
committed
fix
Signed-off-by: zirain <zirain2009@gmail.com>
1 parent cc58069 commit e721c79

5 files changed

Lines changed: 10 additions & 14 deletions

File tree

internal/xds/translator/jsonpatch.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
120120
}
121121

122122
var patchErrors error
123-
var anyPatched bool
124123
for _, dest := range dests {
125124
var (
126125
resourceJSON []byte
@@ -170,15 +169,10 @@ func processJSONPatches(tCtx *types.ResourceVersionTable, envoyPatchPolicies []*
170169
patchErrors = errors.Join(patchErrors, tErr)
171170
continue
172171
}
173-
174-
// Mark that at least one dest has been patched successfully,
175-
// so that we can report partial success if there are multiple dests and some of them fail
176-
anyPatched = true
177172
}
178173

179-
// If there are multiple dests and some of them fail,
180-
// consider it as successful and ignore the failures to patch other dests.
181-
if !anyPatched && patchErrors != nil {
174+
// Report all patch errors, including partial failures
175+
if patchErrors != nil {
182176
tErrs = errors.Join(tErrs, patchErrors)
183177
}
184178
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ envoyPatchPolicies:
1111
jsonPatches:
1212
- type: "type.googleapis.com/envoy.config.listener.v3.Listener"
1313
name:
14-
safeRegex: ".*"
14+
# patch first-* listeners
15+
prefix: "first"
1516
operation:
1617
op: add
1718
path: "/filter_chains/0/filters/0/typed_config/preserve_external_request_id"

internal/xds/translator/testdata/in/xds-ir/jsonpatch-with-jsonpath.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ envoyPatchPolicies:
131131
from: "/endpoints/1/load_balancing_weight"
132132
path: "/endpoints/0/load_balancing_weight"
133133
# Patch route.typed_per_filter_config property.
134-
- name: envoy-gateway/gateway-1/http
134+
- name:
135+
exact: "envoy-gateway/gateway-1/http"
135136
operation:
136137
jsonPath: ..routes[?(@.name=~"httproute/default/httproute-1")]
137138
op: add

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
namespace: envoy-gateway
1010
conditions:
1111
- lastTransitionTime: null
12-
message: Patches have been successfully applied.
13-
reason: Programmed
14-
status: "True"
12+
message: 'Unable to unmarshal xds resource {"name":"second-listener","address":{"socket_address":{"address":"0.0.0.0","port_value":10080}},"default_filter_chain":{"filters":[{"name":"envoy.filters.network.http_connection_manager","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager","stat_prefix":"http-10080","rds":{"config_source":{"ads":{},"resource_api_version":"V3"},"route_config_name":"second-listener"},"http_filters":[{"name":"envoy.filters.http.router","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.router.v3.Router","suppress_envoy_headers":true}}],"common_http_protocol_options":{"headers_with_underscores_action":"REJECT_REQUEST"},"http2_protocol_options":{"max_concurrent_streams":100,"initial_stream_window_size":65536,"initial_connection_window_size":1048576},"server_header_transformation":"PASS_THROUGH","use_remote_address":true,"normalize_path":true,"merge_slashes":true,"path_with_escaped_slashes_action":"UNESCAPE_AND_REDIRECT"}}],"name":"second-listener"},"per_connection_buffer_limit_bytes":32768,"max_connections_to_accept_per_socket_event":1,"filter_chains":[{"filters":[{"typed_config":{"http_filters":[{"name":"envoy.filters.http.ratelimit","typed_config":{"@type":"type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit","domain":"eg-ratelimit","failure_mode_deny":true,"rate_limit_service":{"grpc_service":{"envoy_grpc":{"cluster_name":"rate-limit-cluster"}},"transport_api_version":"V3"},"timeout":"1s"}}]}}]}]},
13+
err:proto: (line 1:1175): missing "@type" field.'
14+
reason: Invalid
15+
status: "False"
1516
type: Programmed
1617
controllerName: ""

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
typedConfig:
3333
'@type': type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
3434
suppressEnvoyHeaders: true
35-
preserveExternalRequestId: true
3635
routeConfig:
3736
name: ready_route
3837
virtualHosts:

0 commit comments

Comments
 (0)