Skip to content

Commit

Permalink
fix: odd number of arguments passed to logger in Konnect ops (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo authored Jan 9, 2025
1 parent ea43fb9 commit 8088f8d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
1 change: 1 addition & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ linters:
- unparam
- unused
- wastedassign
- loggercheck
linters-settings:
gci:
sections:
Expand Down
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@

## Unreleased

### Fixes

- Fix watch predicates for types shared between KGO and KIC.
[#948](https://github.com/Kong/gateway-operator/pull/948)

### Changed

- `KonnectExtension` does not require `spec.serverHostname` to be set by a user
Expand All @@ -46,6 +41,11 @@
- Remove `RunAsUser` specification in jobs to create webhook certificates
because Openshift does not specifying `RunAsUser` by default.
[#964](https://github.com/Kong/gateway-operator/pull/964)
- Fix watch predicates for types shared between KGO and KIC.
[#948](https://github.com/Kong/gateway-operator/pull/948)
- Fix unexpected error logs caused by passing an odd number of arguments to the logger
in the `KongConsumer` reconciler.
[#983](https://github.com/Kong/gateway-operator/pull/983)

## [v1.4.1]

Expand Down
2 changes: 1 addition & 1 deletion controller/controlplane/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
log.Debug(
logger,
"conflict found when trying to ensure ControlPlane's DataPlane configuration was up to date, retrying",
cp,
"controlPlane", cp,
)
return ctrl.Result{Requeue: true, RequeueAfter: controller.RequeueWithoutBackoff}, nil
}
Expand Down
2 changes: 1 addition & 1 deletion controller/dataplane/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func listDataPlanesReferencingKonnectExtension(
if err := c.List(ctx, &dataPlaneList, client.MatchingFields{
index.KonnectExtensionIndex: ext.Namespace + "/" + ext.Name,
}); err != nil {
logger.Error(err, "Failed to list DataPlanes in watch", operatorv1alpha1.KonnectExtensionKind)
logger.Error(err, "Failed to list DataPlanes in watch", "extensionKind", operatorv1alpha1.KonnectExtensionKind)
return nil
}
return lo.Map(dataPlaneList.Items, func(dp operatorv1beta1.DataPlane, _ int) reconcile.Request {
Expand Down
8 changes: 5 additions & 3 deletions controller/konnect/ops/ops_kongconsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ func reconcileConsumerGroupsWithKonnect(
cpID string,
consumer *configurationv1.KongConsumer,
) error {
logger := ctrllog.FromContext(ctx).WithValues("kongconsumer", client.ObjectKeyFromObject(consumer).String())

// List the ConsumerGroups that the Consumer is assigned to in Konnect.
cgsResp, err := cgSDK.ListConsumerGroupsForConsumer(ctx, sdkkonnectops.ListConsumerGroupsForConsumerRequest{
ControlPlaneID: cpID,
Expand All @@ -177,14 +179,14 @@ func reconcileConsumerGroupsWithKonnect(

// Calculate the difference between the desired and actual ConsumerGroups.
consumerGroupsToBeAddedTo, consumerGroupsToBeRemovedFrom := lo.Difference(desiredConsumerGroupsIDs, actualConsumerGroupsIDs)
log.Debug(ctrllog.FromContext(ctx), "reconciling ConsumerGroups for KongConsumer", consumer,
log.Debug(logger, "reconciling ConsumerGroups for KongConsumer",
"groupsToBeAddedTo", consumerGroupsToBeAddedTo,
"groupsToBeRemovedFrom", consumerGroupsToBeRemovedFrom,
)

// Adding consumer to consumer groups that it is not assigned to yet.
for _, cgID := range consumerGroupsToBeAddedTo {
log.Debug(ctrllog.FromContext(ctx), "adding KongConsumer to group", consumer,
log.Debug(ctrllog.FromContext(ctx), "adding KongConsumer to group",
"group", cgID,
)
_, err := cgSDK.AddConsumerToGroup(ctx, sdkkonnectops.AddConsumerToGroupRequest{
Expand All @@ -201,7 +203,7 @@ func reconcileConsumerGroupsWithKonnect(

// Removing consumer from consumer groups that it is not assigned to anymore.
for _, cgID := range consumerGroupsToBeRemovedFrom {
log.Debug(ctrllog.FromContext(ctx), "removing KongConsumer from group", consumer,
log.Debug(logger, "removing KongConsumer from group",
"group", cgID,
)
_, err := cgSDK.RemoveConsumerFromGroup(ctx, sdkkonnectops.RemoveConsumerFromGroupRequest{
Expand Down
2 changes: 1 addition & 1 deletion controller/konnect/reconciler_keysetref.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func handleKongKeySetRef[T constraints.SupportedKonnectEntityType, TEnt constrai
}

if keySetRef.Type != configurationv1alpha1.KeySetRefNamespacedRef {
ctrllog.FromContext(ctx).Error(fmt.Errorf("unsupported KeySet ref type %q", keySetRef.Type), "entity", ent)
ctrllog.FromContext(ctx).Error(fmt.Errorf("unsupported KeySet ref type %q", keySetRef.Type), "unsupported KeySet ref type", "entity", ent)
return ctrl.Result{}, nil
}

Expand Down

0 comments on commit 8088f8d

Please sign in to comment.