Skip to content

bug: non-deterministic proto marshaling republishes equivalent xDS resources on every translation #10018

Closed

Description

@nguyenptk

Description:

Envoy Gateway wraps every filter typed_config into a google.protobuf.Any via ToAnyWithValidation (internal/utils/proto/proto.go), which calls anypb.New. anypb.New uses the default, non-deterministic marshaler, so proto map fields serialize in a random
key order on each translation.

As a result, a semantically unchanged resource is emitted with different wire bytes on nearly every reconcile. Consumers that key off the serialized bytes then see a constant stream of equivalent updates: go-control-plane's delta-ADS per-resource hash and Envoy's own config hash both compare the encoded bytes. For map fields Envoy normalizes the config and treats the update as a no-op (continuous no-op LDS/CDS pushes, no traffic impact); the same class of non-determinism in a repeated field instead causes filter-chain replacement and connection drains (#8889).

Concrete example: with a JSON access log configured, the Listener's HttpConnectionManager access log json_format (a google.protobuf.Struct, i.e. a map) reorders its keys on every translation. Decoding two consecutive Listener payloads shows the same set of fields in a different order (byte-different, semantically identical). The same happens for other map-bearing configs (JWT providers, filter metadata, per-route typed_per_filter_config).

This is the general root cause behind the narrowly-scoped fixes already merged for individual fields (#9042 sorted api key auth credentials; #9430 deduplicates JWT providers). Making the marshaling deterministic addresses the whole class at the source.

Repro steps:

  1. Configure a Gateway/HTTPRoute with a JSON access log (or any config carrying a map field).
  2. Trigger repeated reconciles (e.g. unrelated endpoint/route churn in the cluster).
  3. Capture the Listener xDS resource on two consecutive reconciles and compare the raw bytes (not the decoded JSON, which re-sorts map keys).
  4. Observe the json_format map entries in a different order: byte-different, semantically identical, republished each reconcile.

Expected behavior:

An unchanged effective configuration produces byte-stable xDS resources, so equivalent resources are not republished on every reconcile.

Environment:

  • Envoy Gateway version: v1.8.1

Relevant Links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions