From 36f618990f920cb426dc7944c71eac2cc3b81129 Mon Sep 17 00:00:00 2001 From: Niall D <4562759+driev@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:07:19 +0100 Subject: [PATCH] create a CDS cluster per model (#5916) --- scheduler/pkg/envoy/processor/hash.go | 32 ------------------- scheduler/pkg/envoy/processor/incremental.go | 3 +- .../pkg/envoy/processor/incremental_test.go | 8 ++--- 3 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 scheduler/pkg/envoy/processor/hash.go diff --git a/scheduler/pkg/envoy/processor/hash.go b/scheduler/pkg/envoy/processor/hash.go deleted file mode 100644 index b09725a524..0000000000 --- a/scheduler/pkg/envoy/processor/hash.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -Copyright (c) 2024 Seldon Technologies Ltd. - -Use of this software is governed by -(1) the license included in the LICENSE file or -(2) if the license included in the LICENSE file is the Business Source License 1.1, -the Change License after the Change Date as each is defined in accordance with the LICENSE file. -*/ - -package processor - -import ( - "bytes" - "crypto/sha256" - "encoding/base64" - "sort" - "strconv" -) - -func computeHashKeyForList(list []int) string { - var buffer bytes.Buffer - sort.Ints(list) - for _, v := range list { - buffer.WriteString( - strconv.Itoa(v)) - buffer.WriteString(",") - } - h := sha256.New() - _, _ = h.Write(buffer.Bytes()) - b := h.Sum(nil) - return base64.StdEncoding.EncodeToString(b) -} diff --git a/scheduler/pkg/envoy/processor/incremental.go b/scheduler/pkg/envoy/processor/incremental.go index ce90179824..fd167081c1 100644 --- a/scheduler/pkg/envoy/processor/incremental.go +++ b/scheduler/pkg/envoy/processor/incremental.go @@ -196,7 +196,6 @@ func (p *IncrementalProcessor) setListeners() error { // newSnapshotVersion increments the current snapshotVersion // and returns as a string. func (p *IncrementalProcessor) newSnapshotVersion() string { - // Reset the snapshotVersion if it ever hits max size. if p.snapshotVersion == math.MaxInt64 { p.snapshotVersion = 0 @@ -256,7 +255,7 @@ func (p *IncrementalProcessor) updateEnvoyForModelVersion(modelRouteName string, return } - clusterNameBase := server.Name + "_" + computeHashKeyForList(assignment) + clusterNameBase := modelVersion.GetMeta().GetName() + "_" + strconv.FormatInt(int64(modelVersion.GetVersion()), 10) httpClusterName := clusterNameBase + "_http" grpcClusterName := clusterNameBase + "_grpc" p.xdsCache.AddCluster(httpClusterName, modelRouteName, modelVersion.GetModel().GetMeta().GetName(), modelVersion.GetVersion(), false) diff --git a/scheduler/pkg/envoy/processor/incremental_test.go b/scheduler/pkg/envoy/processor/incremental_test.go index 630039d750..575c38054d 100644 --- a/scheduler/pkg/envoy/processor/incremental_test.go +++ b/scheduler/pkg/envoy/processor/incremental_test.go @@ -229,7 +229,7 @@ func TestUpdateEnvoyForModelVersion(t *testing.T) { }, traffic: 100, expectedRoutes: 2, - expectedClusters: 2, + expectedClusters: 4, }, { name: "TwoRoutesDifferentClusters", @@ -593,7 +593,7 @@ func TestEnvoySettings(t *testing.T) { createTestModel("model3", "server", 1, []int{1}, 1, []store.ModelReplicaState{store.Available}), createTestExperiment("exp", []string{"model1", "model2"}, getStrPtr("model1"), getStrPtr("model3")), }, - numExpectedClusters: 4, + numExpectedClusters: 6, numExpectedRoutes: 4, experimentActive: true, experimentExists: true, @@ -607,7 +607,7 @@ func TestEnvoySettings(t *testing.T) { createTestModel("model3", "server", 1, []int{1}, 1, []store.ModelReplicaState{store.Available}), createTestPipeline("pipe", []string{"model1", "model2", "model3"}, 1), }, - numExpectedClusters: 4, + numExpectedClusters: 6, numExpectedRoutes: 3, numExpectedPipelines: 1, }, @@ -710,7 +710,7 @@ func TestRollingUpdate(t *testing.T) { createTestModel("model", "server", 1, []int{0}, 1, []store.ModelReplicaState{store.Available}), createTestModel("model", "server", 2, []int{0, 1}, 2, []store.ModelReplicaState{store.Available, store.Loading}), }, - numExpectedClusters: 2, + numExpectedClusters: 4, numExpectedRoutes: 1, numTrafficSplits: map[string]int{"model": 2}, },