Skip to content

Conversation

@Junnygram
Copy link

refactor: convert IR map fields to slices to ensure deterministic DeepEqual

This PR refactors the Intermediate Representation (IR) to replacing map fields with slices of structs. This ensures consistent ordering of elements, which is critical for deterministic DeepEqual comparisons and preventing unnecessary xDS updates.

Key changes:

  • Replaced map[string]string with []MapEntry in IR structs.
  • Replaced map[string]CustomTag with []CustomTagMapEntry.
  • Decoupled TrafficFeatures.Telemetry from API types to enforce slice usage.
  • Updated gatewayapi translator to convert API maps to sorted IR slices.
  • Updated xds/translator to consume slice-based IR.
  • Updated test data inputs and regenerated output snapshots.

Fixes #7852.

@Junnygram Junnygram requested a review from a team as a code owner January 14, 2026 10:44
@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for cerulean-figolla-1f9435 canceled.

Name Link
🔨 Latest commit 204e34c
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/696bd354b2ea03000838a4e8

@Junnygram Junnygram force-pushed the refactor/ir-map-to-slice branch from a34560c to e1ab70a Compare January 14, 2026 10:45
@Junnygram Junnygram force-pushed the refactor/ir-map-to-slice branch from e1ab70a to e53faad Compare January 14, 2026 10:49
@Junnygram Junnygram force-pushed the refactor/ir-map-to-slice branch from 536eef8 to 0f04f7a Compare January 17, 2026 01:46
@Junnygram Junnygram force-pushed the refactor/ir-map-to-slice branch from 71aa5ec to 8853dd2 Compare January 17, 2026 09:37
for k, v := range m {
res = append(res, MapEntry{Key: k, Value: v})
}
slices.SortFunc(res, func(a, b MapEntry) int {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can you check if this style

sort.Slice(r.Gateways, func(i, j int) bool {
is faster ?

@arkodg
Copy link
Contributor

arkodg commented Jan 17, 2026

thanks @Junnygram this is great !
added a minor comment to avoid cmp and use below style

sort.Slice(mySlice, func(i, j int) bool {
		return mySlice[i].Ky < mySlice[j].Key
	})

Junnygram and others added 2 commits January 17, 2026 19:20
Use sort.Slice instead of slices.SortFunc and cmp.Compare.

Fix undefined apisv1 in zz_generated.deepcopy.go.

Signed-off-by: Junnygram <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants