Skip to content

Commit 679565f

Browse files
xds: remove HashKey field from xdsresource.Endpoint struct (#8844)
Part of : #8757 This PR removes the `HashKey` field from the `xdsresource.Endpoint` struct and adds it as an attribute while un-marshalling EDS instead of setting it as an attribute later on in cluster resolver balancer RELEASE NOTES: None
1 parent bb2073d commit 679565f

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

internal/xds/balancer/clusterresolver/configbuilder.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"google.golang.org/grpc/internal/xds/balancer/wrrlocality"
3535
"google.golang.org/grpc/internal/xds/xdsclient/xdsresource"
3636
"google.golang.org/grpc/resolver"
37-
"google.golang.org/grpc/resolver/ringhash"
3837
)
3938

4039
const million = 1000000
@@ -286,7 +285,6 @@ func priorityLocalitiesToClusterImpl(localities []xdsresource.Locality, priority
286285
ew = endpoint.Weight
287286
}
288287
resolverEndpoint = weight.Set(resolverEndpoint, weight.EndpointInfo{Weight: lw * ew})
289-
resolverEndpoint = ringhash.SetHashKey(resolverEndpoint, endpoint.HashKey)
290288
retEndpoints = append(retEndpoints, resolverEndpoint)
291289
}
292290
}

internal/xds/xdsclient/xdsresource/type_eds.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ type Endpoint struct {
5454
ResolverEndpoint resolver.Endpoint
5555
HealthStatus EndpointHealthStatus
5656
Weight uint32
57-
HashKey string
5857
Metadata map[string]any
5958
}
6059

internal/xds/xdsclient/xdsresource/unmarshal_eds.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
xdsinternal "google.golang.org/grpc/internal/xds"
3232
"google.golang.org/grpc/internal/xds/clients"
3333
"google.golang.org/grpc/resolver"
34+
"google.golang.org/grpc/resolver/ringhash"
3435
"google.golang.org/protobuf/proto"
3536
"google.golang.org/protobuf/types/known/anypb"
3637
)
@@ -154,11 +155,11 @@ func parseEndpoints(lbEndpoints []*v3endpointpb.LbEndpoint, uniqueEndpointAddrs
154155
}
155156
endpoint := resolver.Endpoint{Addresses: address}
156157
endpoint = setHostname(endpoint, lbEndpoint.GetEndpoint().GetHostname())
158+
endpoint = ringhash.SetHashKey(endpoint, hashKey)
157159
endpoints = append(endpoints, Endpoint{
158160
ResolverEndpoint: endpoint,
159161
HealthStatus: EndpointHealthStatus(lbEndpoint.GetHealthStatus()),
160162
Weight: weight,
161-
HashKey: hashKey,
162163
Metadata: endpointMetadata,
163164
})
164165
}

internal/xds/xdsclient/xdsresource/unmarshal_eds_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"google.golang.org/grpc/internal/xds/clients"
3636
"google.golang.org/grpc/internal/xds/xdsclient/xdsresource/version"
3737
"google.golang.org/grpc/resolver"
38+
"google.golang.org/grpc/resolver/ringhash"
3839
"google.golang.org/protobuf/proto"
3940
"google.golang.org/protobuf/types/known/anypb"
4041
"google.golang.org/protobuf/types/known/structpb"
@@ -477,7 +478,7 @@ func (s) TestUnmarshalEndpointHashKey(t *testing.T) {
477478
if err != nil {
478479
t.Fatalf("unmarshalEndpointsResource() got error = %v, want success", err)
479480
}
480-
got := update.Localities[0].Endpoints[0].HashKey
481+
got := ringhash.HashKey(update.Localities[0].Endpoints[0].ResolverEndpoint)
481482
if got != test.wantHashKey {
482483
t.Errorf("unmarshalEndpointResource() endpoint hash key: got %s, want %s", got, test.wantHashKey)
483484
}

0 commit comments

Comments
 (0)