Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Nov 2, 2023
1 parent 7b784ad commit eca994d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 3 additions & 3 deletions internal/clients/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand Down
3 changes: 0 additions & 3 deletions internal/clients/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ func TestAdminAPIClientsManager_Clients_DBMode(t *testing.T) {
context.Background(),
zapr.NewLogger(zap.NewNop()),
initialClients,

&mockReadinessChecker{},
)
require.NoError(t, err)
Expand Down Expand Up @@ -252,7 +251,6 @@ func TestAdminAPIClientsManager_SubscribeToGatewayClientsChanges(t *testing.T) {
ctx,
zapr.NewLogger(zap.NewNop()),
[]*adminapi.Client{testClient},

readinessChecker)

require.NoError(t, err)
Expand Down Expand Up @@ -472,7 +470,6 @@ func TestAdminAPIClientsManager_PeriodicReadinessReconciliation(t *testing.T) {
ctx,
zapr.NewLogger(zap.NewNop()),
[]*adminapi.Client{testClient},

readinessChecker,
clients.WithReadinessReconciliationTicker(readinessTicker),
)
Expand Down
7 changes: 4 additions & 3 deletions internal/dataplane/kong_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,10 @@ 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]))
}
Expand Down

0 comments on commit eca994d

Please sign in to comment.