Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Mattia Lavacca <lavacca.mattia@gmail.com>
  • Loading branch information
mlavacca committed Jul 16, 2024
1 parent 06c6be0 commit 77b2220
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
14 changes: 7 additions & 7 deletions internal/adminapi/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,30 @@ func NewTestClient(address string) (*Client, error) {

type KonnectClient struct {
Client
disableConsumersSync bool
backoffStrategy UpdateBackoffStrategy
consumersSyncDisabled bool
backoffStrategy UpdateBackoffStrategy
}

// NewKonnectClient creates an Admin API client that is to be used with a Konnect Control Plane Admin API.
func NewKonnectClient(c *kong.Client, controlPlane string, disableConsumersSync bool) *KonnectClient {
func NewKonnectClient(c *kong.Client, controlPlane string, consumersSyncDisabled bool) *KonnectClient {
return &KonnectClient{
Client: Client{
adminAPIClient: c,
isKonnect: true,
konnectControlPlane: controlPlane,
pluginSchemaStore: util.NewPluginSchemaStore(c),
},
backoffStrategy: NewKonnectBackoffStrategy(clock.System{}),
disableConsumersSync: disableConsumersSync,
backoffStrategy: NewKonnectBackoffStrategy(clock.System{}),
consumersSyncDisabled: consumersSyncDisabled,
}
}

func (c *KonnectClient) BackoffStrategy() UpdateBackoffStrategy {
return c.backoffStrategy
}

func (c *KonnectClient) DisableConsumersSync() bool {
return c.disableConsumersSync
func (c *KonnectClient) ConsumersSyncDisabled() bool {
return c.consumersSyncDisabled
}

// AdminAPIClient returns an underlying go-kong's Admin API client.
Expand Down
4 changes: 2 additions & 2 deletions internal/adminapi/konnect.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type KonnectConfig struct {
LicenseSynchronizationEnabled bool
InitialLicensePollingPeriod time.Duration
LicensePollingPeriod time.Duration
DisableConsumersSync bool
ConsumersSyncDisabled bool
}

func NewKongClientForKonnectControlPlane(c KonnectConfig) (*KonnectClient, error) {
Expand Down Expand Up @@ -60,7 +60,7 @@ func NewKongClientForKonnectControlPlane(c KonnectConfig) (*KonnectClient, error
if err != nil {
return nil, err
}
return NewKonnectClient(client, c.ControlPlaneID, c.DisableConsumersSync), nil
return NewKonnectClient(client, c.ControlPlaneID, c.ConsumersSyncDisabled), nil
}

// EnsureKonnectConnection ensures that the client is able to connect to Konnect.
Expand Down
7 changes: 3 additions & 4 deletions internal/dataplane/kong_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,9 @@ func (c *KongClient) maybeSendOutToKonnectClient(
return nil
}

// Some users may want to configure the controller to not sync consumers
// as they may have a lot of them. This can make Konnect sync very slow and
// cause dataplane sync issues.
if konnectClient.DisableConsumersSync() {
// In case users have many consumers, konnect sync can be very slow and cause dataplane sync issues.
// For this reason, if the --disable-consumers-sync flag is set, we do not send consumers to Konnect.
if konnectClient.ConsumersSyncDisabled() {
s.Consumers = nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/manager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func (c *Config) FlagSet() *pflag.FlagSet {
flagSet.StringVar(&c.Konnect.TLSClient.Key, "konnect-tls-client-key", "", "Konnect TLS client key.")
flagSet.StringVar(&c.Konnect.TLSClient.KeyFile, "konnect-tls-client-key-file", "", "Konnect TLS client key file path.")
flagSet.DurationVar(&c.Konnect.RefreshNodePeriod, "konnect-refresh-node-period", konnect.DefaultRefreshNodePeriod, "Period of uploading status of KIC and controlled Kong instances.")
flagSet.BoolVar(&c.Konnect.DisableConsumersSync, "konnect-disable-consumers-sync", false, "Disable synchronization of consumers with Konnect.")
flagSet.BoolVar(&c.Konnect.ConsumersSyncDisabled, "konnect-disable-consumers-sync", false, "Disable synchronization of consumers with Konnect.")

// Deprecated flags.
flagSet.StringVar(&c.Konnect.ControlPlaneID, "konnect-runtime-group-id", "", "Use --konnect-control-plane-id instead.")
Expand Down

0 comments on commit 77b2220

Please sign in to comment.