Skip to content

Commit

Permalink
clustetresolver: Copy endpoints.Addresses slice from DNS updates to a…
Browse files Browse the repository at this point in the history
…void data races (#7991)
  • Loading branch information
arjan-bal authored Jan 13, 2025
1 parent f9bc335 commit aad8a12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xds/internal/balancer/clusterresolver/configbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ func buildClusterImplConfigForDNS(g *nameGenerator, endpoints []resolver.Endpoin
pName := fmt.Sprintf("priority-%v", g.prefix)
for i, e := range endpoints {
retEndpoints[i] = hierarchy.SetInEndpoint(e, []string{pName})
// Copy the nested address field as slice fields are shared by the
// iteration variable and the original slice.
retEndpoints[i].Addresses = append([]resolver.Address{}, e.Addresses...)
}
return pName, &clusterimpl.LBConfig{
Cluster: mechanism.Cluster,
Expand Down

0 comments on commit aad8a12

Please sign in to comment.