Skip to content

zoneproxies/meshtrace golden-file test: MTP RBAC race #17429

Description

@Automaat

Motivation

test/e2e_env/universal/envoyconfig/zoneproxies.go's golden-file DescribeTable entry for zoneproxies/meshtrace/otel.input.yaml is disabled (renamed with a P prefix to Potel.*, following the existing EntriesForFolder pending-entry convention) because it fails deterministically on CI (3 different architectures, same failure every time) but is inconsistent locally.

Symptom

The golden file expects an RBAC filter matcher on zone-proxy-demo-client's inbound listener (port 3000) allowing spiffe://envoyconfig-zoneproxies.kuma-3.mesh.local (from the mesh-wide allow-all MeshTrafficPermission, allow-all-envoyconfig-zoneproxies-0). The live-captured snapshot via kumactl inspect dataplane --shadow --include=diff is sometimes missing that matcher content, and the Eventually(..., "180s", "2s") polling loop does not reliably converge to the expected state within that window.

Investigation so far

Extensive live debugging (temporary log lines added directly to pkg/plugins/policies/meshtrafficpermission/plugin/v1alpha1/plugin.go, rebuilt, and inspected via the SSH session logs the test framework captures to a host temp file) confirmed, on every poll during a failing run:

  • mtp.FromRules.InboundRules[key]ok: true, numRules: 1 (the policy match itself is correct)
  • proxy.WorkloadIdentity != niltrue
  • the listener's filter chain has TransportSocket.GetName() == "envoy.transport_sockets.tls" (passes the TLS gate)
  • right after RBACConfigurer.Configure(filterChain) runs, the filter chain's filter names include envoy.filters.network.rbac (the filter is inserted)

Despite all of that being correct, the golden-file comparison still reports the matcher content as different from expected in some runs.

Also found and fixed along the way (real bug, but not sufficient alone to explain this): cleanupAfterTest (shared golden-file suite helper) was reinstalling the allow-all MeshTrafficPermission via the legacy spec.from/targetRef: Mesh helper after each DescribeTable entry, while BeforeAll uses the workload-identity spec.rules/spiffeID helper. Under proxy.WorkloadIdentity != nil (true for this suite), the plugin's legacy-rules fallback never fires, so the legacy-form permission silently contributes nothing. Fixed in commit 4bec50dff8 on #17387 (aligns the cleanup reinstall with the BeforeAll helper).

Repro data points (contradictory, suggesting a genuine race rather than deterministic logic bug)

  • Isolated local runs of zoneproxies/meshtrace/otel alone: 6/6 passed, each converging in ~35s.
  • Isolated local runs of zoneproxies/meshtrace/datadog alone (same suite, sibling entry, inline tracing backend instead of a separate MeshOpenTelemetryBackend): 2/2 failed, each running 200+ seconds without ever converging.
  • CI (3 architectures, 2 separate runs): consistently fails specifically on otel, never datadog/zipkin.
  • Local full-suite reproduction of the meshtrace folder: failed once on otel, another time on datadog (whichever ran first in that particular run).

This pattern (consistent per-environment, inconsistent test-to-test, no clean correlation with test content or the MeshOpenTelemetryBackend resource specifically) points to a genuine, environment/timing-sensitive race in how the zone-proxy dataplane's RBAC rule gets applied following MeshIdentity/MeshTrafficPermission reconcile — not a logic bug in MeshTrafficPermission's own plugin code, which was directly verified to behave correctly at every step observed.

Suggested next steps

  • Trace MeshIdentity certificate issuance timing and the zone-proxy dataplane's own reconcile-loop scheduling relative to when the RBAC rule gets applied, to find the actual race window.
  • Consider whether ci/verify-stability (reruns CI repeatedly to detect flakiness) can be used to get a real failure-rate measurement before re-enabling.

Supporting documentation

Discovered while fixing CI on #17387.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triage/pendingThis issue will be reviewed during the next triage meeting

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions