From f92f12697f66d30657edc65ec2ae8d4816a5d46c Mon Sep 17 00:00:00 2001 From: Yi Tao Date: Thu, 2 Nov 2023 22:24:48 +0800 Subject: [PATCH] address comments --- internal/clients/manager.go | 6 +++--- internal/clients/manager_test.go | 3 --- internal/dataplane/kong_client.go | 6 +++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/internal/clients/manager.go b/internal/clients/manager.go index 545a842e60..5693a0a2cf 100644 --- a/internal/clients/manager.go +++ b/internal/clients/manager.go @@ -188,12 +188,12 @@ func (c *AdminAPIClientsManager) GatewayClientsToConfigure() []*adminapi.Client c.lock.RLock() defer c.lock.RUnlock() readyGatewayClients := lo.Values(c.readyGatewayClients) - // With dbless mode, we should send configuration to ALL Kong gateway instances. + // With DB-less mode, we should send the configuration to ALL gateway instances. if dataplaneutil.IsDBLessMode(c.dbMode) { return readyGatewayClients } - // When Kong gateway is DB backed, we return a random admin API client - // since KIC only need to send requests to one instance. + // When a gateway is DB-backed, we return a random client + // since KIC only needs to send requests to one instance. // If there are no ready gateway clients, we return an empty list. if len(readyGatewayClients) == 0 { return []*adminapi.Client{} diff --git a/internal/clients/manager_test.go b/internal/clients/manager_test.go index 274425b8d1..b109ed7821 100644 --- a/internal/clients/manager_test.go +++ b/internal/clients/manager_test.go @@ -222,7 +222,6 @@ func TestAdminAPIClientsManager_Clients_DBMode(t *testing.T) { context.Background(), zapr.NewLogger(zap.NewNop()), initialClients, - &mockReadinessChecker{}, ) require.NoError(t, err) @@ -252,7 +251,6 @@ func TestAdminAPIClientsManager_SubscribeToGatewayClientsChanges(t *testing.T) { ctx, zapr.NewLogger(zap.NewNop()), []*adminapi.Client{testClient}, - readinessChecker) require.NoError(t, err) @@ -472,7 +470,6 @@ func TestAdminAPIClientsManager_PeriodicReadinessReconciliation(t *testing.T) { ctx, zapr.NewLogger(zap.NewNop()), []*adminapi.Client{testClient}, - readinessChecker, clients.WithReadinessReconciliationTicker(readinessTicker), ) diff --git a/internal/dataplane/kong_client.go b/internal/dataplane/kong_client.go index f303b60ec2..2bfb54222a 100644 --- a/internal/dataplane/kong_client.go +++ b/internal/dataplane/kong_client.go @@ -474,9 +474,9 @@ func (c *KongClient) sendOutToGatewayClients( return nil, err } - // After succeeded to update configurations in DB mode, we should propagate the SHA from - // the chosen gateway client to other clients. - if !dataplaneutil.IsDBLessMode(c.dbmode) && len(shas) > 0 { + // After a successful configuration update in DB mode, we should propagate the SHA from + // the chosen client to other clients as well as they will pick the configuration from the shared database. + if !dataplaneutil.IsDBLessMode(c.dbmode) && len(gatewayClients) > 1 { for _, client := range gatewayClients { client.SetLastConfigSHA([]byte(shas[0])) }