From cea1315d29af4ed80364dc746c984d0b3b669cab Mon Sep 17 00:00:00 2001 From: Tao Yi Date: Wed, 10 Jul 2024 02:18:27 +0800 Subject: [PATCH] chore(logging) create logging package (#6304) * chore(*) create logging package Move log utilities out of util into their own package, to avoid import cycles. * chore(*) update generator and re-generate code --------- Co-authored-by: Travis Raines <571832+rainest@users.noreply.github.com> --- controllers/license/konglicense_controller.go | 18 +- .../generators/controllers/networking/main.go | 24 +-- internal/admission/handler_test.go | 4 +- internal/admission/validator.go | 9 +- internal/clients/manager.go | 12 +- internal/clients/readiness.go | 10 +- .../configuration/kongadminapi_controller.go | 6 +- .../kongupstreampolicy_controller.go | 6 +- .../configuration/secret_controller.go | 6 +- .../configuration/zz_generated_controllers.go | 166 +++++++++--------- .../controllers/crds/dynamic_controller.go | 12 +- .../controllers/gateway/gateway_controller.go | 8 +- .../gateway/gatewayclass_controller.go | 5 +- internal/controllers/gateway/route_utils.go | 15 +- internal/controllers/gateway/utils.go | 6 +- internal/controllers/reference/indexer.go | 7 +- .../dataplane/configfetcher/config_fetcher.go | 8 +- internal/dataplane/fallback/fallback.go | 4 +- internal/dataplane/kong_client.go | 37 ++-- .../dataplane/sendconfig/backoff_strategy.go | 4 +- internal/dataplane/sendconfig/dbmode.go | 4 +- internal/dataplane/sendconfig/inmemory.go | 4 +- .../sendconfig/inmemory_error_handling.go | 3 +- internal/dataplane/sendconfig/sendconfig.go | 9 +- internal/dataplane/translator/ingressrules.go | 3 +- .../dataplane/translator/translate_certs.go | 3 +- .../translator/translate_upstreams.go | 17 +- internal/diagnostics/server.go | 4 +- internal/konnect/node_agent.go | 24 +-- internal/license/agent.go | 16 +- internal/{util => logging}/logging.go | 2 +- internal/manager/setup.go | 4 +- internal/store/store.go | 6 +- test/envtest/log.go | 4 +- 34 files changed, 240 insertions(+), 230 deletions(-) rename internal/{util => logging}/logging.go (99%) diff --git a/controllers/license/konglicense_controller.go b/controllers/license/konglicense_controller.go index ca9772d218..213819c0fb 100644 --- a/controllers/license/konglicense_controller.go +++ b/controllers/license/konglicense_controller.go @@ -28,7 +28,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/crds" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/kubernetes/object/status" kongv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1alpha1" ) @@ -183,7 +183,7 @@ func (r *KongV1Alpha1KongLicenseReconciler) Reconcile(ctx context.Context, req c } if objectExistsInCache { // Delete the object in the cache first. - log.V(util.DebugLevel).Info("KongLicense deleted in cluster, delete it in cache") + log.V(logging.DebugLevel).Info("KongLicense deleted in cluster, delete it in cache") if err := r.LicenseCache.Delete(obj); err != nil { return ctrl.Result{}, err } @@ -197,11 +197,11 @@ func (r *KongV1Alpha1KongLicenseReconciler) Reconcile(ctx context.Context, req c } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongLicense") + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongLicense") _, objectExistsInCache, err := r.LicenseCache.Get(obj) if err != nil { @@ -230,7 +230,7 @@ func (r *KongV1Alpha1KongLicenseReconciler) Reconcile(ctx context.Context, req c // Trigger a compare on stored KongLicenses in cache and pick the newest. chosenLicense := r.pickLicenseInCache() if chosenLicense.Name == obj.Name { - log.V(util.DebugLevel).Info("Picked KongLicense being reconciled", "name", obj.Name) + log.V(logging.DebugLevel).Info("Picked KongLicense being reconciled", "name", obj.Name) err := r.ensureControllerStatusConditions(ctx, obj, metav1.ConditionTrue, ConditionReasonPickedAsLatest, "") if err != nil { return ctrl.Result{}, err @@ -238,7 +238,7 @@ func (r *KongV1Alpha1KongLicenseReconciler) Reconcile(ctx context.Context, req c oldChosenLicense := r.getChosenLicense() if oldChosenLicense != nil && oldChosenLicense.Name != chosenLicense.Name { - r.Log.V(util.DebugLevel).Info("Originally picked KongLicense replaced", "name", oldChosenLicense.Name) + r.Log.V(logging.DebugLevel).Info("Originally picked KongLicense replaced", "name", oldChosenLicense.Name) err := r.ensureControllerStatusConditions(ctx, oldChosenLicense, metav1.ConditionFalse, ConditionReasonReplacedByNewer, "Replaced by newer created KongLicense") if err != nil { return ctrl.Result{}, err @@ -264,10 +264,10 @@ type License struct { func (r *KongV1Alpha1KongLicenseReconciler) GetValidatedLicense() mo.Option[License] { chosenLicense := r.getChosenLicense() if chosenLicense == nil { - r.Log.V(util.DebugLevel).Info("No KongLicense available") + r.Log.V(logging.DebugLevel).Info("No KongLicense available") return mo.None[License]() } - r.Log.V(util.DebugLevel).Info("Get license from KongLicense resource", "name", chosenLicense.Name) + r.Log.V(logging.DebugLevel).Info("Get license from KongLicense resource", "name", chosenLicense.Name) isValid := mo.None[bool]() if r.licenseValidator != nil { isValid = mo.Some(r.licenseValidator(chosenLicense.RawLicenseString) == nil) @@ -362,7 +362,7 @@ func (r *KongV1Alpha1KongLicenseReconciler) repickLicenseOnDelete(ctx context.Co chosenLicense := r.pickLicenseInCache() r.setChosenLicense(chosenLicense) if chosenLicense != nil { - r.Log.V(util.DebugLevel).Info("Picked KongLicense remaining in cache", "name", chosenLicense.Name) + r.Log.V(logging.DebugLevel).Info("Picked KongLicense remaining in cache", "name", chosenLicense.Name) return r.ensureControllerStatusConditions(ctx, chosenLicense, metav1.ConditionTrue, ConditionReasonPickedAsLatest, "") } } diff --git a/hack/generators/controllers/networking/main.go b/hack/generators/controllers/networking/main.go index 9676166637..c5525f1233 100644 --- a/hack/generators/controllers/networking/main.go +++ b/hack/generators/controllers/networking/main.go @@ -483,7 +483,7 @@ import ( ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" ctrlutils "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/kubernetes/object/status" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" @@ -632,11 +632,11 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "{{.Kind}}", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "{{.Kind}}", "namespace", req.Namespace, "name", req.Name) {{if .NeedsUpdateReferences}} // remove reference record where the {{.Kind}} is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -663,16 +663,16 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } {{end}} @@ -704,20 +704,20 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { {{- if .IngressAddressUpdatesEnabled }} - log.V(util.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) if !r.DataplaneClient.KubernetesObjectIsConfigured(obj) { - log.V(util.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) return ctrl.Result{Requeue: true}, nil // requeue until the object has been properly configured } - log.V(util.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) addrs, err := r.DataplaneAddressFinder.GetLoadBalancerAddresses(ctx) if err != nil { return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) updateNeeded, err := ctrlutils.UpdateLoadBalancerIngress(obj, addrs) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to update load balancer address: %w", err) @@ -725,7 +725,7 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re {{- end }} {{- if .ProgrammedCondition.UpdatesEnabled }} - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -740,7 +740,7 @@ func (r *{{.PackageAlias}}{{.Kind}}Reconciler) Reconcile(ctx context.Context, re if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } {{- end}} diff --git a/internal/admission/handler_test.go b/internal/admission/handler_test.go index eaf266fb46..9c8b943bcb 100644 --- a/internal/admission/handler_test.go +++ b/internal/admission/handler_test.go @@ -21,7 +21,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/annotations" ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" "github.com/kong/kubernetes-ingress-controller/v3/internal/labels" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" ) @@ -414,7 +414,7 @@ func TestHandleSecret(t *testing.T) { Operation: admissionv1.Update, } - logger := testr.NewWithOptions(t, testr.Options{Verbosity: util.DebugLevel}) + logger := testr.NewWithOptions(t, testr.Options{Verbosity: logging.DebugLevel}) referenceIndexer := ctrlref.NewCacheIndexers(logger) handler := RequestHandler{ diff --git a/internal/admission/validator.go b/internal/admission/validator.go index aeb6c52d07..c3372b5f92 100644 --- a/internal/admission/validator.go +++ b/internal/admission/validator.go @@ -23,6 +23,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/translator" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" @@ -237,12 +238,12 @@ func (validator KongHTTPValidator) ValidateConsumerGroup( } info, err := infoSvc.Get(ctx) if err != nil { - validator.Logger.V(util.DebugLevel).Info("Failed to fetch Kong info", "error", err) + validator.Logger.V(logging.DebugLevel).Info("Failed to fetch Kong info", "error", err) return false, ErrTextAdminAPIUnavailable, nil } version, err := kong.NewVersion(info.Version) if err != nil { - validator.Logger.V(util.DebugLevel).Info("Failed to parse Kong version", "error", err) + validator.Logger.V(logging.DebugLevel).Info("Failed to parse Kong version", "error", err) } else if !version.IsKongGatewayEnterprise() { return false, ErrTextConsumerGroupUnsupported, nil } @@ -637,7 +638,7 @@ func (validator KongHTTPValidator) ValidateCustomEntity(ctx context.Context, ent schemaService, hasClient := validator.AdminAPIServicesProvider.GetSchemasService() // Skip validation on Kong gateway if we do not have available client. if !hasClient { - logger.V(util.DebugLevel).Info("Skipped because no schema service available") + logger.V(logging.DebugLevel).Info("Skipped because no schema service available") return true, "", nil } @@ -645,7 +646,7 @@ func (validator KongHTTPValidator) ValidateCustomEntity(ctx context.Context, ent entityType := entity.Spec.EntityType schema, err := schemaService.Get(ctx, entityType) if err != nil { - logger.V(util.DebugLevel).Info("Failed to get schema of entity", "entity_type", entityType, "error", err) + logger.V(logging.DebugLevel).Info("Failed to get schema of entity", "entity_type", entityType, "error", err) return false, fmt.Sprintf(ErrTextCustomEntityGetSchemaFailed, entityType, err), nil } diff --git a/internal/clients/manager.go b/internal/clients/manager.go index 42c63cbf03..6b2c5fbbf5 100644 --- a/internal/clients/manager.go +++ b/internal/clients/manager.go @@ -11,7 +11,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/adminapi" dpconf "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/config" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/clock" ) @@ -246,7 +246,7 @@ func (c *AdminAPIClientsManager) gatewayClientsReconciliationLoop() { for { select { case <-c.ctx.Done(): - c.logger.V(util.InfoLevel).Info("Closing AdminAPIClientsManager", "reason", c.ctx.Err()) + c.logger.V(logging.InfoLevel).Info("Closing AdminAPIClientsManager", "reason", c.ctx.Err()) c.closeGatewayClientsSubscribers() return case discoveredAdminAPIs := <-c.discoveredAdminAPIsNotifyChan: @@ -261,7 +261,7 @@ func (c *AdminAPIClientsManager) gatewayClientsReconciliationLoop() { // It will adjust lists of gateway clients and notify subscribers about the change if readyGatewayClients list has // changed. func (c *AdminAPIClientsManager) onDiscoveredAdminAPIsNotification(discoveredAdminAPIs []adminapi.DiscoveredAdminAPI) { - c.logger.V(util.DebugLevel).Info("Received notification about Admin API addresses change") + c.logger.V(logging.DebugLevel).Info("Received notification about Admin API addresses change") clientsChanged := c.adjustGatewayClients(discoveredAdminAPIs) readinessChanged := c.reconcileGatewayClientsReadiness() @@ -273,7 +273,7 @@ func (c *AdminAPIClientsManager) onDiscoveredAdminAPIsNotification(discoveredAdm // onReadinessReconciliationTick is called on every readinessReconciliationTicker tick. It will reconcile readiness // of all gateway clients and notify subscribers about the change if readyGatewayClients list has changed. func (c *AdminAPIClientsManager) onReadinessReconciliationTick() { - c.logger.V(util.DebugLevel).Info("Reconciling readiness of gateway clients") + c.logger.V(logging.DebugLevel).Info("Reconciling readiness of gateway clients") if changed := c.reconcileGatewayClientsReadiness(); changed { c.notifyGatewayClientsSubscribers() @@ -370,11 +370,11 @@ func (c *AdminAPIClientsManager) reconcileGatewayClientsReadiness() bool { // notifyGatewayClientsSubscribers sends notifications to all subscribers that have called SubscribeToGatewayClientsChanges. func (c *AdminAPIClientsManager) notifyGatewayClientsSubscribers() { - c.logger.V(util.DebugLevel).Info("Notifying subscribers about gateway clients change") + c.logger.V(logging.DebugLevel).Info("Notifying subscribers about gateway clients change") for _, sub := range c.gatewayClientsChangesSubscribers { select { case <-c.ctx.Done(): - c.logger.V(util.InfoLevel).Info("Not sending notification to subscribers as the context is done") + c.logger.V(logging.InfoLevel).Info("Not sending notification to subscribers as the context is done") return case sub <- struct{}{}: } diff --git a/internal/clients/readiness.go b/internal/clients/readiness.go index 8abe640c70..6283b224c9 100644 --- a/internal/clients/readiness.go +++ b/internal/clients/readiness.go @@ -10,7 +10,7 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" "github.com/kong/kubernetes-ingress-controller/v3/internal/adminapi" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) const ( @@ -94,7 +94,7 @@ func (c DefaultReadinessChecker) checkPendingClient( pendingClient adminapi.DiscoveredAdminAPI, ) (client *adminapi.Client) { defer func() { - c.logger.V(util.DebugLevel). + c.logger.V(logging.DebugLevel). Info(fmt.Sprintf("Checking readiness of pending client for %q", pendingClient.Address), "ok", client != nil, ) @@ -105,7 +105,7 @@ func (c DefaultReadinessChecker) checkPendingClient( client, err := c.factory.CreateAdminAPIClient(ctx, pendingClient) if err != nil { // Despite the error reason we still want to keep the client in the pending list to retry later. - c.logger.V(util.DebugLevel).Info("Pending client is not ready yet", + c.logger.V(logging.DebugLevel).Info("Pending client is not ready yet", "reason", err.Error(), "address", pendingClient.Address, ) @@ -142,7 +142,7 @@ func (c DefaultReadinessChecker) checkAlreadyExistingClients(ctx context.Context func (c DefaultReadinessChecker) checkAlreadyCreatedClient(ctx context.Context, client AlreadyCreatedClient) (ready bool) { defer func() { - c.logger.V(util.DebugLevel).Info( + c.logger.V(logging.DebugLevel).Info( fmt.Sprintf("Checking readiness of already created client for %q", client.BaseRootURL()), "ok", ready, ) @@ -152,7 +152,7 @@ func (c DefaultReadinessChecker) checkAlreadyCreatedClient(ctx context.Context, defer cancel() if err := client.IsReady(ctx); err != nil { // Despite the error reason we still want to keep the client in the pending list to retry later. - c.logger.V(util.DebugLevel).Info( + c.logger.V(logging.DebugLevel).Info( "Already created client is not ready, moving to pending", "address", client.BaseRootURL(), "reason", err.Error(), diff --git a/internal/controllers/configuration/kongadminapi_controller.go b/internal/controllers/configuration/kongadminapi_controller.go index 92806e516e..3afd786410 100644 --- a/internal/controllers/configuration/kongadminapi_controller.go +++ b/internal/controllers/configuration/kongadminapi_controller.go @@ -22,7 +22,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/adminapi" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) // KongAdminAPIServiceReconciler reconciles Kong Admin API Service Endpointslices @@ -126,7 +126,7 @@ func (r *KongAdminAPIServiceReconciler) Reconcile(ctx context.Context, req ctrl. r.Log.Info("Reconciling Admin API EndpointSlice", "namespace", req.Namespace, "name", req.Name) if !endpoints.DeletionTimestamp.IsZero() { - r.Log.V(util.DebugLevel).Info("EndpointSlice is being deleted", + r.Log.V(logging.DebugLevel).Info("EndpointSlice is being deleted", "type", "EndpointSlice", "namespace", req.Namespace, "name", req.Name, ) @@ -177,7 +177,7 @@ func (r *KongAdminAPIServiceReconciler) Reconcile(ctx context.Context, req ctrl. func (r *KongAdminAPIServiceReconciler) notify() { discovered := flattenDiscoveredAdminAPIs(r.Cache) addresses := lo.Map(discovered, func(d adminapi.DiscoveredAdminAPI, _ int) string { return d.Address }) - r.Log.V(util.DebugLevel). + r.Log.V(logging.DebugLevel). Info("Notifying about newly detected Admin APIs", "admin_apis", addresses) r.EndpointsNotifier.Notify(discovered) } diff --git a/internal/controllers/configuration/kongupstreampolicy_controller.go b/internal/controllers/configuration/kongupstreampolicy_controller.go index 3b0fcffa20..9105ba5f39 100644 --- a/internal/controllers/configuration/kongupstreampolicy_controller.go +++ b/internal/controllers/configuration/kongupstreampolicy_controller.go @@ -22,7 +22,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/kubernetes/object/status" kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" incubatorv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/incubator/v1alpha1" @@ -328,11 +328,11 @@ func (r *KongUpstreamPolicyReconciler) Reconcile(ctx context.Context, req ctrl.R } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !kongUpstreamPolicy.DeletionTimestamp.IsZero() && time.Now().After(kongUpstreamPolicy.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongUpstreamPolicy", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongUpstreamPolicy", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(kongUpstreamPolicy) if err != nil { diff --git a/internal/controllers/configuration/secret_controller.go b/internal/controllers/configuration/secret_controller.go index 1cddb9627a..628625e0ef 100644 --- a/internal/controllers/configuration/secret_controller.go +++ b/internal/controllers/configuration/secret_controller.go @@ -20,7 +20,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" "github.com/kong/kubernetes-ingress-controller/v3/internal/labels" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) // ----------------------------------------------------------------------------- @@ -119,11 +119,11 @@ func (r *CoreV1SecretReconciler) Reconcile(ctx context.Context, req ctrl.Request return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !secret.DeletionTimestamp.IsZero() && time.Now().After(secret.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Secret", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Secret", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(secret) if err != nil { return ctrl.Result{}, err diff --git a/internal/controllers/configuration/zz_generated_controllers.go b/internal/controllers/configuration/zz_generated_controllers.go index 16398f0135..d3fb101f8e 100644 --- a/internal/controllers/configuration/zz_generated_controllers.go +++ b/internal/controllers/configuration/zz_generated_controllers.go @@ -44,7 +44,7 @@ import ( ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" ctrlutils "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/kubernetes/object/status" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" kongv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1alpha1" @@ -113,11 +113,11 @@ func (r *CoreV1ServiceReconciler) Reconcile(ctx context.Context, req ctrl.Reques } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Service", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Service", "namespace", req.Namespace, "name", req.Name) // remove reference record where the Service is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -209,11 +209,11 @@ func (r *DiscoveryV1EndpointSliceReconciler) Reconcile(ctx context.Context, req } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "EndpointSlice", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "EndpointSlice", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -347,11 +347,11 @@ func (r *NetV1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Ingress", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "Ingress", "namespace", req.Namespace, "name", req.Name) // remove reference record where the Ingress is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -378,16 +378,16 @@ func (r *NetV1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -407,20 +407,20 @@ func (r *NetV1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) if !r.DataplaneClient.KubernetesObjectIsConfigured(obj) { - log.V(util.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) return ctrl.Result{Requeue: true}, nil // requeue until the object has been properly configured } - log.V(util.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) addrs, err := r.DataplaneAddressFinder.GetLoadBalancerAddresses(ctx) if err != nil { return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) updateNeeded, err := ctrlutils.UpdateLoadBalancerIngress(obj, addrs) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to update load balancer address: %w", err) @@ -428,7 +428,7 @@ func (r *NetV1IngressReconciler) Reconcile(ctx context.Context, req ctrl.Request if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -488,11 +488,11 @@ func (r *NetV1IngressClassReconciler) Reconcile(ctx context.Context, req ctrl.Re } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "IngressClass", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "IngressClass", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -570,11 +570,11 @@ func (r *KongV1KongIngressReconciler) Reconcile(ctx context.Context, req ctrl.Re } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongIngress", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongIngress", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -658,11 +658,11 @@ func (r *KongV1KongPluginReconciler) Reconcile(ctx context.Context, req ctrl.Req } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongPlugin", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongPlugin", "namespace", req.Namespace, "name", req.Name) // remove reference record where the KongPlugin is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -795,11 +795,11 @@ func (r *KongV1KongClusterPluginReconciler) Reconcile(ctx context.Context, req c } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongClusterPlugin", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongClusterPlugin", "namespace", req.Namespace, "name", req.Name) // remove reference record where the KongClusterPlugin is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -826,16 +826,16 @@ func (r *KongV1KongClusterPluginReconciler) Reconcile(ctx context.Context, req c // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -966,11 +966,11 @@ func (r *KongV1KongConsumerReconciler) Reconcile(ctx context.Context, req ctrl.R } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongConsumer", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongConsumer", "namespace", req.Namespace, "name", req.Name) // remove reference record where the KongConsumer is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -997,16 +997,16 @@ func (r *KongV1KongConsumerReconciler) Reconcile(ctx context.Context, req ctrl.R // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1016,7 +1016,7 @@ func (r *KongV1KongConsumerReconciler) Reconcile(ctx context.Context, req ctrl.R } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -1027,7 +1027,7 @@ func (r *KongV1KongConsumerReconciler) Reconcile(ctx context.Context, req ctrl.R if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } // update reference relationship from the KongConsumer to other objects. if err := updateReferredObjects(ctx, r.Client, r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -1152,11 +1152,11 @@ func (r *KongV1Beta1KongConsumerGroupReconciler) Reconcile(ctx context.Context, } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongConsumerGroup", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongConsumerGroup", "namespace", req.Namespace, "name", req.Name) // remove reference record where the KongConsumerGroup is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -1183,16 +1183,16 @@ func (r *KongV1Beta1KongConsumerGroupReconciler) Reconcile(ctx context.Context, // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1202,7 +1202,7 @@ func (r *KongV1Beta1KongConsumerGroupReconciler) Reconcile(ctx context.Context, } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -1213,7 +1213,7 @@ func (r *KongV1Beta1KongConsumerGroupReconciler) Reconcile(ctx context.Context, if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } // update reference relationship from the KongConsumerGroup to other objects. if err := updateReferredObjects(ctx, r.Client, r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -1340,11 +1340,11 @@ func (r *KongV1Beta1TCPIngressReconciler) Reconcile(ctx context.Context, req ctr } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "TCPIngress", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "TCPIngress", "namespace", req.Namespace, "name", req.Name) // remove reference record where the TCPIngress is the referrer if err := ctrlref.DeleteReferencesByReferrer(r.ReferenceIndexers, r.DataplaneClient, obj); err != nil { @@ -1371,16 +1371,16 @@ func (r *KongV1Beta1TCPIngressReconciler) Reconcile(ctx context.Context, req ctr // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1400,20 +1400,20 @@ func (r *KongV1Beta1TCPIngressReconciler) Reconcile(ctx context.Context, req ctr } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) if !r.DataplaneClient.KubernetesObjectIsConfigured(obj) { - log.V(util.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) return ctrl.Result{Requeue: true}, nil // requeue until the object has been properly configured } - log.V(util.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) addrs, err := r.DataplaneAddressFinder.GetLoadBalancerAddresses(ctx) if err != nil { return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) updateNeeded, err := ctrlutils.UpdateLoadBalancerIngress(obj, addrs) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to update load balancer address: %w", err) @@ -1421,7 +1421,7 @@ func (r *KongV1Beta1TCPIngressReconciler) Reconcile(ctx context.Context, req ctr if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -1532,11 +1532,11 @@ func (r *KongV1Beta1UDPIngressReconciler) Reconcile(ctx context.Context, req ctr } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "UDPIngress", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "UDPIngress", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -1558,16 +1558,16 @@ func (r *KongV1Beta1UDPIngressReconciler) Reconcile(ctx context.Context, req ctr // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1577,20 +1577,20 @@ func (r *KongV1Beta1UDPIngressReconciler) Reconcile(ctx context.Context, req ctr } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining whether data-plane configuration has succeeded", "namespace", req.Namespace, "name", req.Name) if !r.DataplaneClient.KubernetesObjectIsConfigured(obj) { - log.V(util.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource not yet configured in the data-plane", "namespace", req.Namespace, "name", req.Name) return ctrl.Result{Requeue: true}, nil // requeue until the object has been properly configured } - log.V(util.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Determining gateway addresses for object status updates", "namespace", req.Namespace, "name", req.Name) addrs, err := r.DataplaneAddressFinder.GetLoadBalancerAddresses(ctx) if err != nil { return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Found addresses for data-plane updating object status", "namespace", req.Namespace, "name", req.Name) updateNeeded, err := ctrlutils.UpdateLoadBalancerIngress(obj, addrs) if err != nil { return ctrl.Result{}, fmt.Errorf("failed to update load balancer address: %w", err) @@ -1598,7 +1598,7 @@ func (r *KongV1Beta1UDPIngressReconciler) Reconcile(ctx context.Context, req ctr if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -1658,11 +1658,11 @@ func (r *KongV1Alpha1IngressClassParametersReconciler) Reconcile(ctx context.Con } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "IngressClassParameters", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "IngressClassParameters", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -1788,11 +1788,11 @@ func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) Reconcile(ctx context.Con } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongServiceFacade", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongServiceFacade", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -1814,16 +1814,16 @@ func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) Reconcile(ctx context.Con // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1833,7 +1833,7 @@ func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) Reconcile(ctx context.Con } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -1845,7 +1845,7 @@ func (r *IncubatorV1Alpha1KongServiceFacadeReconciler) Reconcile(ctx context.Con if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -1954,11 +1954,11 @@ func (r *KongV1Alpha1KongVaultReconciler) Reconcile(ctx context.Context, req ctr } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongVault", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongVault", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -1980,16 +1980,16 @@ func (r *KongV1Alpha1KongVaultReconciler) Reconcile(ctx context.Context, req ctr // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -1999,7 +1999,7 @@ func (r *KongV1Alpha1KongVaultReconciler) Reconcile(ctx context.Context, req ctr } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -2010,7 +2010,7 @@ func (r *KongV1Alpha1KongVaultReconciler) Reconcile(ctx context.Context, req ctr if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil @@ -2119,11 +2119,11 @@ func (r *KongV1Alpha1KongCustomEntityReconciler) Reconcile(ctx context.Context, } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Reconciling resource", "namespace", req.Namespace, "name", req.Name) // clean the object up if it's being deleted if !obj.DeletionTimestamp.IsZero() && time.Now().After(obj.DeletionTimestamp.Time) { - log.V(util.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongCustomEntity", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Resource is being deleted, its configuration will be removed", "type", "KongCustomEntity", "namespace", req.Namespace, "name", req.Name) objectExistsInCache, err := r.DataplaneClient.ObjectExists(obj) if err != nil { @@ -2145,16 +2145,16 @@ func (r *KongV1Alpha1KongCustomEntityReconciler) Reconcile(ctx context.Context, // used the class annotation and did not create a corresponding IngressClass. We only need this to determine // if the IngressClass is default or to configure default settings, and can assume no/no additional defaults // if none exists. - log.V(util.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) + log.V(logging.DebugLevel).Info("Could not retrieve IngressClass", "ingressclass", r.IngressClassName) } } // if the object is not configured with our ingress.class, then we need to ensure it's removed from the cache if !ctrlutils.MatchesIngressClass(obj, r.IngressClassName, ctrlutils.IsDefaultIngressClass(class)) { - log.V(util.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", + log.V(logging.DebugLevel).Info("Object missing ingress class, ensuring it's removed from configuration", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) return ctrl.Result{}, r.DataplaneClient.DeleteObject(obj) } else { - log.V(util.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, + log.V(logging.DebugLevel).Info("Object has matching ingress class", "namespace", req.Namespace, "name", req.Name, "class", r.IngressClassName) } @@ -2164,7 +2164,7 @@ func (r *KongV1Alpha1KongCustomEntityReconciler) Reconcile(ctx context.Context, } // if status updates are enabled report the status for the object if r.DataplaneClient.AreKubernetesObjectReportsEnabled() { - log.V(util.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Updating programmed condition status", "namespace", req.Namespace, "name", req.Name) configurationStatus := r.DataplaneClient.KubernetesObjectConfigurationStatus(obj) conditions, updateNeeded := ctrlutils.EnsureProgrammedCondition( configurationStatus, @@ -2175,7 +2175,7 @@ func (r *KongV1Alpha1KongCustomEntityReconciler) Reconcile(ctx context.Context, if updateNeeded { return ctrl.Result{}, r.Status().Update(ctx, obj) } - log.V(util.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) + log.V(logging.DebugLevel).Info("Status update not needed", "namespace", req.Namespace, "name", req.Name) } return ctrl.Result{}, nil diff --git a/internal/controllers/crds/dynamic_controller.go b/internal/controllers/crds/dynamic_controller.go index 1b87c48e5b..3a546f38a3 100644 --- a/internal/controllers/crds/dynamic_controller.go +++ b/internal/controllers/crds/dynamic_controller.go @@ -19,7 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) // +kubebuilder:rbac:groups="apiextensions.k8s.io",resources=customresourcedefinitions,verbs=list;watch @@ -45,7 +45,7 @@ type DynamicCRDController struct { func (r *DynamicCRDController) SetupWithManager(mgr ctrl.Manager) error { if r.allRequiredCRDsInstalled() { - r.Log.V(util.DebugLevel).Info("All required CustomResourceDefinitions are installed, skipping DynamicCRDController set up") + r.Log.V(logging.DebugLevel).Info("All required CustomResourceDefinitions are installed, skipping DynamicCRDController set up") return r.setupController(mgr) } @@ -72,21 +72,21 @@ func (r *DynamicCRDController) Reconcile(ctx context.Context, req ctrl.Request) crd := new(apiextensionsv1.CustomResourceDefinition) if err := r.Manager.GetClient().Get(ctx, req.NamespacedName, crd); err != nil { if apierrors.IsNotFound(err) { - log.V(util.DebugLevel).Info("Object enqueued no longer exists, skipping", "name", req.Name) + log.V(logging.DebugLevel).Info("Object enqueued no longer exists, skipping", "name", req.Name) return ctrl.Result{}, nil } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Processing CustomResourceDefinition", "name", req.Name) + log.V(logging.DebugLevel).Info("Processing CustomResourceDefinition", "name", req.Name) if !r.allRequiredCRDsInstalled() { - log.V(util.DebugLevel).Info("Still not all required CustomResourceDefinitions are installed, waiting") + log.V(logging.DebugLevel).Info("Still not all required CustomResourceDefinitions are installed, waiting") return ctrl.Result{}, nil } var startControllerErr error r.startControllerOnce.Do(func() { - log.V(util.InfoLevel).Info("All required CustomResourceDefinitions are installed, setting up the controller") + log.V(logging.InfoLevel).Info("All required CustomResourceDefinitions are installed, setting up the controller") startControllerErr = r.setupController(r.Manager) }) if startControllerErr != nil { diff --git a/internal/controllers/gateway/gateway_controller.go b/internal/controllers/gateway/gateway_controller.go index 0972db0c02..413f4d7411 100644 --- a/internal/controllers/gateway/gateway_controller.go +++ b/internal/controllers/gateway/gateway_controller.go @@ -33,7 +33,7 @@ import ( ctrlref "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/reference" ctrlutils "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) // ----------------------------------------------------------------------------- @@ -376,7 +376,7 @@ func (r *GatewayReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct log := r.Log.WithValues("GatewayV1Gateway", req.NamespacedName) if nn, isSet := r.GatewayNN.Get(); isSet && !r.GatewayNN.MatchesNN(req.NamespacedName) { - r.Log.V(util.DebugLevel).Info( + r.Log.V(logging.DebugLevel).Info( "The request does not match the specified Gateway and will be skipped.", "gateway", nn, "request", req.String(), @@ -515,7 +515,7 @@ func (r *GatewayReconciler) reconcileUnmanagedGateway(ctx context.Context, log l debug(log, gateway, "Gathering the gateway publish service") // this will also be done by the validating webhook, this is a fallback var gatewayServices []*corev1.Service for _, ref := range serviceRefs { - r.Log.V(util.DebugLevel).Info("Determining service for ref", "ref", ref) + r.Log.V(logging.DebugLevel).Info("Determining service for ref", "ref", ref) svc, err := r.determineServiceForGateway(ctx, ref) if err != nil { const annotation = annotations.AnnotationPrefix + annotations.GatewayPublishServiceKey @@ -687,7 +687,7 @@ func (r *GatewayReconciler) determineServiceForGateway(ctx context.Context, ref // retrieve the service for the kong gateway svc := &corev1.Service{} if name.Name == "" && name.Namespace == "" { - r.Log.V(util.DebugLevel).Info("Service not configured, discarding it", "ref", ref) + r.Log.V(logging.DebugLevel).Info("Service not configured, discarding it", "ref", ref) return nil, nil } if err := r.Client.Get(ctx, name, svc); err != nil { diff --git a/internal/controllers/gateway/gatewayclass_controller.go b/internal/controllers/gateway/gatewayclass_controller.go index d22d30eb40..cb12564ab6 100644 --- a/internal/controllers/gateway/gatewayclass_controller.go +++ b/internal/controllers/gateway/gatewayclass_controller.go @@ -19,6 +19,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) @@ -114,13 +115,13 @@ func (r *GatewayClassReconciler) Reconcile(ctx context.Context, req ctrl.Request gwc := new(gatewayapi.GatewayClass) if err := r.Client.Get(ctx, req.NamespacedName, gwc); err != nil { if apierrors.IsNotFound(err) { - log.V(util.DebugLevel).Info("Object enqueued no longer exists, skipping", "name", req.Name) + log.V(logging.DebugLevel).Info("Object enqueued no longer exists, skipping", "name", req.Name) return ctrl.Result{}, nil } return ctrl.Result{}, err } - log.V(util.DebugLevel).Info("Processing gatewayclass", "name", req.Name) + log.V(logging.DebugLevel).Info("Processing gatewayclass", "name", req.Name) if isGatewayClassControlled(gwc) { alreadyAccepted := util.CheckCondition( diff --git a/internal/controllers/gateway/route_utils.go b/internal/controllers/gateway/route_utils.go index cb42bf58ff..dbe2aa78bc 100644 --- a/internal/controllers/gateway/route_utils.go +++ b/internal/controllers/gateway/route_utils.go @@ -19,6 +19,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) @@ -223,7 +224,7 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( listener.Name, route.GetName(), gateway.Name, err, ) } else if !ok { - listenerLogger.V(util.DebugLevel).Info("Route does not match listener's allowed routes") + listenerLogger.V(logging.DebugLevel).Info("Route does not match listener's allowed routes") continue } allowedByAllowedRoutes = true @@ -232,14 +233,14 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( // - Check if a listener status exists with a matching type (via SupportedKinds). // - Check if it matches the requested listener by name (if specified). if err := existsMatchingListenerInStatus(route, listener, gateway.Status.Listeners); err != nil { - listenerLogger.V(util.DebugLevel).Info("Listener does not support this route", "reason", err.Error()) + listenerLogger.V(logging.DebugLevel).Info("Listener does not support this route", "reason", err.Error()) continue } else { //nolint:revive allowedBySupportedKinds = true } if err := listenerProgrammedInStatus(listener.Name, gateway.Status.Listeners); err != nil { - listenerLogger.V(util.DebugLevel).Info("Listener is not ready", "reason", err.Error()) + listenerLogger.V(logging.DebugLevel).Info("Listener is not ready", "reason", err.Error()) continue } else { //nolint:revive listenerReady = true @@ -248,7 +249,7 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( // Check if listener name matches. if parentRef.SectionName != nil { if *parentRef.SectionName != "" && *parentRef.SectionName != listener.Name { - listenerLogger.V(util.DebugLevel).Info( + listenerLogger.V(logging.DebugLevel).Info( "Listener name does not match parentRef.SectionName", "parentRef_sectionName", parentRef.SectionName, ) @@ -262,7 +263,7 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( if *parentRef.Port != listener.Port { // This ParentRef has a port specified and it's different // than current listener's port. - listenerLogger.V(util.DebugLevel).Info( + listenerLogger.V(logging.DebugLevel).Info( "Listener port does not match parentRef.Port", "listener_port", listener.Port, "parentRef_port", parentRef.Port, ) @@ -273,7 +274,7 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( // Check if listener protocol matches if !routeTypeMatchesListenerType(route, listener) { - listenerLogger.V(util.DebugLevel).Info( + listenerLogger.V(logging.DebugLevel).Info( "Route's type does not match listener's type", "route_name", route.GetName(), ) @@ -286,7 +287,7 @@ func getSupportedGatewayForRoute[T gatewayapi.RouteT]( } else { condFalse := metav1.ConditionFalse matchingHostname = &condFalse - listenerLogger.V(util.DebugLevel).Info("Route's hostname does not match listener's hostname") + listenerLogger.V(logging.DebugLevel).Info("Route's hostname does not match listener's hostname") continue } diff --git a/internal/controllers/gateway/utils.go b/internal/controllers/gateway/utils.go index 032d1a847e..45153f5bd6 100644 --- a/internal/controllers/gateway/utils.go +++ b/internal/controllers/gateway/utils.go @@ -4,7 +4,7 @@ import ( "github.com/go-logr/logr" "sigs.k8s.io/controller-runtime/pkg/client" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) // ----------------------------------------------------------------------------- @@ -17,7 +17,7 @@ func debug(log logr.Logger, obj client.Object, msg string, keysAndValues ...inte "namespace", obj.GetNamespace(), "name", obj.GetName(), }, keysAndValues...) - log.V(util.DebugLevel).Info(msg, keysAndValues...) + log.V(logging.DebugLevel).Info(msg, keysAndValues...) } // info is an alias for the longer log.V(util.InfoLevel).Info for convenience. @@ -26,5 +26,5 @@ func info(log logr.Logger, obj client.Object, msg string, keysAndValues ...inter "namespace", obj.GetNamespace(), "name", obj.GetName(), }, keysAndValues...) - log.V(util.InfoLevel).Info(msg, keysAndValues...) + log.V(logging.InfoLevel).Info(msg, keysAndValues...) } diff --git a/internal/controllers/reference/indexer.go b/internal/controllers/reference/indexer.go index 1bdbdc667c..afc4ad1b32 100644 --- a/internal/controllers/reference/indexer.go +++ b/internal/controllers/reference/indexer.go @@ -8,6 +8,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/manager/scheme" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) @@ -123,7 +124,7 @@ func ObjectReferenceIndexerReferent(obj interface{}) ([]string, error) { // SetObjectReference adds or updates a reference record between referrer and referent in reference cache. func (c CacheIndexers) SetObjectReference(referrer client.Object, referent client.Object) error { - c.logger.V(util.DebugLevel).Info("Set reference relation", + c.logger.V(logging.DebugLevel).Info("Set reference relation", "referrer_kind", referrer.GetObjectKind().GroupVersionKind().String(), "referrer_namespace", referrer.GetNamespace(), "referrer_name", referrer.GetName(), @@ -140,7 +141,7 @@ func (c CacheIndexers) SetObjectReference(referrer client.Object, referent clien // DeleteObjectReference deletes the reference record between referrer and referent from reference cache. func (c CacheIndexers) DeleteObjectReference(referrer client.Object, referent client.Object) error { - c.logger.V(util.DebugLevel).Info("Delete reference relation", + c.logger.V(logging.DebugLevel).Info("Delete reference relation", "referrer_kind", referrer.GetObjectKind().GroupVersionKind().String(), "referrer_namespace", referrer.GetNamespace(), "referrer_name", referrer.GetName(), @@ -244,7 +245,7 @@ func (c CacheIndexers) DeleteObjectIfNotReferred(obj client.Object, dataplaneCli return err } if !referred { - c.logger.V(util.DebugLevel).Info("Delete object from cache because it is no longer referred", + c.logger.V(logging.DebugLevel).Info("Delete object from cache because it is no longer referred", "kind", obj.GetObjectKind(), "namespace", obj.GetNamespace(), "name", obj.GetName(), diff --git a/internal/dataplane/configfetcher/config_fetcher.go b/internal/dataplane/configfetcher/config_fetcher.go index d36411fb79..16223c8e40 100644 --- a/internal/dataplane/configfetcher/config_fetcher.go +++ b/internal/dataplane/configfetcher/config_fetcher.go @@ -14,7 +14,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/sendconfig" "github.com/kong/kubernetes-ingress-controller/v3/internal/license" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) type LastValidConfigFetcher interface { @@ -109,7 +109,7 @@ func (cf *DefaultKongLastGoodConfigFetcher) TryFetchingValidConfigFromGateways( logger logr.Logger, gatewayClients []*adminapi.Client, ) error { - logger.V(util.DebugLevel).Info("Fetching last good configuration from gateway clients", "count", len(gatewayClients)) + logger.V(logging.DebugLevel).Info("Fetching last good configuration from gateway clients", "count", len(gatewayClients)) var ( goodKongState *kongstate.KongState @@ -117,7 +117,7 @@ func (cf *DefaultKongLastGoodConfigFetcher) TryFetchingValidConfigFromGateways( clientUsed *adminapi.Client ) for _, client := range gatewayClients { - logger.V(util.DebugLevel).Info("Fetching configuration", "url", client.BaseRootURL()) + logger.V(logging.DebugLevel).Info("Fetching configuration", "url", client.BaseRootURL()) rs, err := cf.getKongRawState(ctx, client.AdminAPIClient()) if err != nil { errs = errors.Join(errs, err) @@ -147,7 +147,7 @@ func (cf *DefaultKongLastGoodConfigFetcher) TryFetchingValidConfigFromGateways( goodKongState.FillIDs(logger, cf.workspace) } cf.lastValidState = goodKongState - logger.V(util.DebugLevel).Info("Last good configuration fetched from Kong node", "url", clientUsed.BaseRootURL()) + logger.V(logging.DebugLevel).Info("Last good configuration fetched from Kong node", "url", clientUsed.BaseRootURL()) } return errs } diff --git a/internal/dataplane/fallback/fallback.go b/internal/dataplane/fallback/fallback.go index 4d0b3b0e06..0b9912b8f2 100644 --- a/internal/dataplane/fallback/fallback.go +++ b/internal/dataplane/fallback/fallback.go @@ -5,8 +5,8 @@ import ( "github.com/go-logr/logr" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) type CacheGraphProvider interface { @@ -97,7 +97,7 @@ func (g *Generator) GenerateBackfillingBrokenObjects( } if lastValidCacheSnapshot == nil { - g.logger.V(util.DebugLevel).Info("No previous valid cache snapshot found, skipping backfilling") + g.logger.V(logging.DebugLevel).Info("No previous valid cache snapshot found, skipping backfilling") return fallbackCache, metadataCollector.Metadata(), nil } diff --git a/internal/dataplane/kong_client.go b/internal/dataplane/kong_client.go index 0641b540bf..27834bb3bd 100644 --- a/internal/dataplane/kong_client.go +++ b/internal/dataplane/kong_client.go @@ -36,6 +36,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/sendconfig" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/translator" "github.com/kong/kubernetes-ingress-controller/v3/internal/diagnostics" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/metrics" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" @@ -457,7 +458,7 @@ func (c *KongClient) Update(ctx context.Context) error { c.prometheusMetrics.RecordProcessedConfigSnapshotCacheMiss() } if hasNewSnapshotToBeProcessed { - c.logger.V(util.DebugLevel).Info("New configuration snapshot detected", "hash", newSnapshotHash) + c.logger.V(logging.DebugLevel).Info("New configuration snapshot detected", "hash", newSnapshotHash) c.lastProcessedSnapshotHash = newSnapshotHash c.kongConfigBuilder.UpdateCache(cacheSnapshot) } @@ -465,22 +466,22 @@ func (c *KongClient) Update(ctx context.Context) error { if allGatewaysAreInSync := lo.EveryBy(c.clientsProvider.GatewayClientsToConfigure(), func(cl *adminapi.Client) bool { return cl.LastCacheStoresHash() == c.lastProcessedSnapshotHash }); allGatewaysAreInSync { - c.logger.V(util.DebugLevel).Info("All gateways are in sync; pushing config is not necessary, skipping") + c.logger.V(logging.DebugLevel).Info("All gateways are in sync; pushing config is not necessary, skipping") return nil } } - c.logger.V(util.DebugLevel).Info("Parsing kubernetes objects into data-plane configuration") + c.logger.V(logging.DebugLevel).Info("Parsing kubernetes objects into data-plane configuration") parsingResult := c.kongConfigBuilder.BuildKongConfig() if failuresCount := len(parsingResult.TranslationFailures); failuresCount > 0 { c.prometheusMetrics.RecordTranslationFailure() c.prometheusMetrics.RecordTranslationBrokenResources(failuresCount) c.recordResourceFailureEvents(parsingResult.TranslationFailures, KongConfigurationTranslationFailedEventReason) - c.logger.V(util.DebugLevel).Info("Translation failures occurred when building data-plane configuration", "count", failuresCount) + c.logger.V(logging.DebugLevel).Info("Translation failures occurred when building data-plane configuration", "count", failuresCount) } else { c.prometheusMetrics.RecordTranslationSuccess() c.prometheusMetrics.RecordTranslationBrokenResources(0) - c.logger.V(util.DebugLevel).Info("Successfully built data-plane configuration") + c.logger.V(logging.DebugLevel).Info("Successfully built data-plane configuration") } const isFallback = false @@ -519,11 +520,11 @@ func (c *KongClient) Update(ctx context.Context) error { // if the configuration SHAs that have just been pushed are different than // what's been previously pushed. if !slices.Equal(shas, c.SHAs) { - c.logger.V(util.DebugLevel).Info("Triggering report for configured Kubernetes objects", "count", + c.logger.V(logging.DebugLevel).Info("Triggering report for configured Kubernetes objects", "count", len(parsingResult.ConfiguredKubernetesObjects)) c.triggerKubernetesObjectReport(parsingResult.ConfiguredKubernetesObjects, parsingResult.TranslationFailures) } else { - c.logger.V(util.DebugLevel).Info("No configuration change; resource status update not necessary, skipping") + c.logger.V(logging.DebugLevel).Info("No configuration change; resource status update not necessary, skipping") } } return nil @@ -533,7 +534,7 @@ func (c *KongClient) Update(ctx context.Context) error { // feature gate is enabled and the `--enable-last-valid-config-fallback` flag is set. func (c *KongClient) maybePreserveTheLastValidConfigCache(lastValidCache store.CacheStores) { if c.kongConfig.FallbackConfiguration && c.kongConfig.UseLastValidConfigForFallback { - c.logger.V(util.DebugLevel).Info("Preserving the last valid configuration cache") + c.logger.V(logging.DebugLevel).Info("Preserving the last valid configuration cache") c.lastValidCacheSnapshot = &lastValidCache } } @@ -557,7 +558,7 @@ func (c *KongClient) maybeTryRecoveringFromGatewaysSyncError( // If the error is not of the expected UpdateError type, we should log it and skip the recovery. updateErr := sendconfig.UpdateError{} if !errors.As(gatewaysSyncErr, &updateErr) { - c.logger.V(util.DebugLevel).Info("Skipping recovery from gateways sync error - not enough details to recover", + c.logger.V(logging.DebugLevel).Info("Skipping recovery from gateways sync error - not enough details to recover", "error", gatewaysSyncErr) return nil } @@ -583,7 +584,7 @@ func (c *KongClient) maybeTryRecoveringFromGatewaysSyncError( if _, fallbackSyncErr := c.sendOutToGatewayClients(ctx, state, c.kongConfig, isFallback); fallbackSyncErr != nil { return errors.Join(gatewaysSyncErr, fallbackSyncErr) } - c.logger.V(util.DebugLevel).Info("Due to errors in the current config, the last valid config has been pushed to Gateways") + c.logger.V(logging.DebugLevel).Info("Due to errors in the current config, the last valid config has been pushed to Gateways") } return nil } @@ -613,7 +614,7 @@ func (c *KongClient) tryRecoveringWithFallbackConfiguration( c.recordResourceFailureEvents(fallbackParsingResult.TranslationFailures, FallbackKongConfigurationTranslationFailedEventReason) c.prometheusMetrics.RecordFallbackTranslationBrokenResources(failuresCount) c.prometheusMetrics.RecordFallbackTranslationFailure() - c.logger.V(util.DebugLevel).Info("Translation failures occurred when building fallback data-plane configuration", "count", failuresCount) + c.logger.V(logging.DebugLevel).Info("Translation failures occurred when building fallback data-plane configuration", "count", failuresCount) } else { c.prometheusMetrics.RecordFallbackTranslationBrokenResources(0) c.prometheusMetrics.RecordFallbackTranslationSuccess() @@ -690,7 +691,7 @@ func (c *KongClient) sendOutToGatewayClients( gatewayClientsToConfigure := c.clientsProvider.GatewayClientsToConfigure() configureGatewayClientURLs := lo.Map(gatewayClientsToConfigure, func(cl *adminapi.Client, _ int) string { return cl.BaseRootURL() }) - c.logger.V(util.DebugLevel).Info("Sending configuration to gateway clients", "urls", configureGatewayClientURLs) + c.logger.V(logging.DebugLevel).Info("Sending configuration to gateway clients", "urls", configureGatewayClientURLs) shas, err := iter.MapErr(gatewayClientsToConfigure, func(client **adminapi.Client) (string, error) { return c.sendToClient(ctx, *client, s, config, isFallback) @@ -916,7 +917,7 @@ func prepareSendDiagnosticFn( Config: *config, RawResponseBody: rawResponseBody, }: - logger.V(util.DebugLevel).Info("Shipping config to diagnostic server") + logger.V(logging.DebugLevel).Info("Shipping config to diagnostic server") default: logger.Error(nil, "Config diagnostic buffer full, dropping diagnostic config") } @@ -1037,11 +1038,11 @@ func (c *KongClient) recordApplyConfigurationEvents(err error, rootURL string, i func (c *KongClient) updateConfigStatus(ctx context.Context, configStatus clients.ConfigStatus) { if c.currentConfigStatus == configStatus { // No change in config status, nothing to do. - c.logger.V(util.DebugLevel).Info("No change in config status, not notifying") + c.logger.V(logging.DebugLevel).Info("No change in config status, not notifying") return } - c.logger.V(util.DebugLevel).Info("Config status changed, notifying", "configStatus", configStatus) + c.logger.V(logging.DebugLevel).Info("Config status changed, notifying", "configStatus", configStatus) c.currentConfigStatus = configStatus c.configStatusNotifier.NotifyConfigStatus(ctx, configStatus) } @@ -1056,7 +1057,7 @@ func (c *KongClient) logFallbackCacheMetadata(metadata fallback.GeneratedCacheMe causingObjects := lo.Map(excluded.CausingObjects, func(causing fallback.ObjectHash, _ int) string { return causing.String() }) - log.V(util.DebugLevel).Info("Excluded object from fallback cache", + log.V(logging.DebugLevel).Info("Excluded object from fallback cache", "kind", gvk.Kind, "group", gvk.Group, "namespace", obj.GetNamespace(), @@ -1072,7 +1073,7 @@ func (c *KongClient) logFallbackCacheMetadata(metadata fallback.GeneratedCacheMe causingObjects := lo.Map(backfilled.CausingObjects, func(causing fallback.ObjectHash, _ int) string { return causing.String() }) - log.V(util.DebugLevel).Info("Backfilled object in fallback cache", + log.V(logging.DebugLevel).Info("Backfilled object in fallback cache", "kind", gvk.Kind, "group", gvk.Group, "namespace", obj.GetNamespace(), @@ -1086,7 +1087,7 @@ func (c *KongClient) maybeSendFallbackConfigDiagnostics(ctx context.Context, gen if ch := c.diagnostic.FallbackCacheMetadata; ch != nil { select { case ch <- generatedCacheMetadata: - c.logger.V(util.DebugLevel).Info("Shipping fallback cache metadata to diagnostics server") + c.logger.V(logging.DebugLevel).Info("Shipping fallback cache metadata to diagnostics server") case <-ctx.Done(): return ctx.Err() default: diff --git a/internal/dataplane/sendconfig/backoff_strategy.go b/internal/dataplane/sendconfig/backoff_strategy.go index 96dfc01217..ce09dbd4f7 100644 --- a/internal/dataplane/sendconfig/backoff_strategy.go +++ b/internal/dataplane/sendconfig/backoff_strategy.go @@ -7,8 +7,8 @@ import ( "github.com/go-logr/logr" "github.com/kong/kubernetes-ingress-controller/v3/internal/adminapi" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/metrics" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) type UpdateSkippedDueToBackoffStrategyError struct { @@ -54,7 +54,7 @@ func (s UpdateStrategyWithBackoff) Update(ctx context.Context, targetContent Con err = s.decorated.Update(ctx, targetContent) if err != nil { - s.logger.V(util.DebugLevel).Info("Update failed, registering it for backoff strategy", "reason", err.Error()) + s.logger.V(logging.DebugLevel).Info("Update failed, registering it for backoff strategy", "reason", err.Error()) s.backoffStrategy.RegisterUpdateFailure(err, targetContent.Hash) return err } diff --git a/internal/dataplane/sendconfig/dbmode.go b/internal/dataplane/sendconfig/dbmode.go index 5d0e35bacc..11e9b8a8f2 100644 --- a/internal/dataplane/sendconfig/dbmode.go +++ b/internal/dataplane/sendconfig/dbmode.go @@ -17,8 +17,8 @@ import ( "github.com/kong/go-kong/kong" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/deckerrors" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/metrics" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) // UpdateStrategyDBMode implements the UpdateStrategy interface. It updates Kong's data-plane @@ -123,7 +123,7 @@ func (s *UpdateStrategyDBMode) HandleEvents(ctx context.Context, events chan dif select { case event := <-events: if event.Error == nil { - s.logger.V(util.DebugLevel).Info("updated gateway entity", "action", event.Action, "kind", event.Entity.Kind, "name", event.Entity.Name) + s.logger.V(logging.DebugLevel).Info("updated gateway entity", "action", event.Action, "kind", event.Entity.Kind, "name", event.Entity.Name) } else { s.logger.Error(event.Error, "failed updating gateway entity", "action", event.Action, "kind", event.Entity.Kind, "name", event.Entity.Name) parsed, err := resourceErrorFromEntityAction(event) diff --git a/internal/dataplane/sendconfig/inmemory.go b/internal/dataplane/sendconfig/inmemory.go index 45aec07d53..df35ca1256 100644 --- a/internal/dataplane/sendconfig/inmemory.go +++ b/internal/dataplane/sendconfig/inmemory.go @@ -13,8 +13,8 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/go-kong/kong" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/metrics" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) type ConfigService interface { @@ -66,7 +66,7 @@ func (s UpdateStrategyInMemory) Update(ctx context.Context, targetState ContentW } for entityType, entities := range targetState.CustomEntities { unmarshaledConfig[entityType] = entities - s.logger.V(util.DebugLevel).Info("Filled custom entities", "entity_type", entityType) + s.logger.V(logging.DebugLevel).Info("Filled custom entities", "entity_type", entityType) } config, err = json.Marshal(unmarshaledConfig) if err != nil { diff --git a/internal/dataplane/sendconfig/inmemory_error_handling.go b/internal/dataplane/sendconfig/inmemory_error_handling.go index 169232f569..d956943a1a 100644 --- a/internal/dataplane/sendconfig/inmemory_error_handling.go +++ b/internal/dataplane/sendconfig/inmemory_error_handling.go @@ -11,6 +11,7 @@ import ( k8stypes "k8s.io/apimachinery/pkg/types" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/failures" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" kongv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1alpha1" @@ -222,7 +223,7 @@ func resourceErrorsToResourceFailures(resourceErrors []ResourceError, logger log }, } for problemSource, problem := range ee.Problems { - logger.V(util.DebugLevel).Info("Adding failure", "resource_name", ee.Name, "source", problemSource, "problem", problem) + logger.V(logging.DebugLevel).Info("Adding failure", "resource_name", ee.Name, "source", problemSource, "problem", problem) resourceFailure, failureCreateErr := failures.NewResourceFailure( fmt.Sprintf("invalid %s: %s", problemSource, problem), &obj, diff --git a/internal/dataplane/sendconfig/sendconfig.go b/internal/dataplane/sendconfig/sendconfig.go index adf114f31a..719623fd8e 100644 --- a/internal/dataplane/sendconfig/sendconfig.go +++ b/internal/dataplane/sendconfig/sendconfig.go @@ -11,6 +11,7 @@ import ( "github.com/kong/go-kong/kong" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/deckgen" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/metrics" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" @@ -63,9 +64,9 @@ func PerformUpdate( } if !configurationChanged { if client.IsKonnect() { - logger.V(util.DebugLevel).Info("No configuration change, skipping sync to Konnect") + logger.V(logging.DebugLevel).Info("No configuration change, skipping sync to Konnect") } else { - logger.V(util.DebugLevel).Info("No configuration change, skipping sync to Kong") + logger.V(logging.DebugLevel).Info("No configuration change, skipping sync to Kong") } return oldSHA, nil } @@ -105,9 +106,9 @@ func PerformUpdate( } if client.IsKonnect() { - logger.V(util.InfoLevel).Info("Successfully synced configuration to Konnect") + logger.V(logging.InfoLevel).Info("Successfully synced configuration to Konnect") } else { - logger.V(util.InfoLevel).Info("Successfully synced configuration to Kong") + logger.V(logging.InfoLevel).Info("Successfully synced configuration to Kong") } return newSHA, nil diff --git a/internal/dataplane/translator/ingressrules.go b/internal/dataplane/translator/ingressrules.go index 16cb034aa1..93016e21d2 100644 --- a/internal/dataplane/translator/ingressrules.go +++ b/internal/dataplane/translator/ingressrules.go @@ -16,6 +16,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/annotations" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/failures" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) @@ -158,7 +159,7 @@ func (ir *ingressRules) generateKongServiceTags( // Service doesn't actually exist. attempting to generate tags for that Service would trigger a panic. // The translator should discard this invalid route later, but this adds a placeholder value in case it doesn't. // If you encounter an actual config where a service has these tags, something strange has happened. - logger.V(util.DebugLevel).Info("Service has zero k8sServices backends, cannot generate tags for it properly", + logger.V(logging.DebugLevel).Info("Service has zero k8sServices backends, cannot generate tags for it properly", "service", *service.Name) return kong.StringSlice( util.K8sNameTagPrefix+"UNKNOWN", diff --git a/internal/dataplane/translator/translate_certs.go b/internal/dataplane/translator/translate_certs.go index 47c0254ff0..4c2fcf4897 100644 --- a/internal/dataplane/translator/translate_certs.go +++ b/internal/dataplane/translator/translate_certs.go @@ -14,6 +14,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" ) @@ -62,7 +63,7 @@ func (t *Translator) getGatewayCerts() []certWrapper { for _, listener := range gateway.Spec.Listeners { status, ok := statuses[listener.Name] if !ok { - logger.V(util.DebugLevel).Info("Listener missing status information", + logger.V(logging.DebugLevel).Info("Listener missing status information", "gateway", gateway.Name, "listener", listener.Name, "listener_protocol", listener.Protocol, diff --git a/internal/dataplane/translator/translate_upstreams.go b/internal/dataplane/translator/translate_upstreams.go index 0b4cc62ea4..976ca7ee2b 100644 --- a/internal/dataplane/translator/translate_upstreams.go +++ b/internal/dataplane/translator/translate_upstreams.go @@ -13,6 +13,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/annotations" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/kongstate" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" "github.com/kong/kubernetes-ingress-controller/v3/internal/util" kongv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1alpha1" @@ -79,7 +80,7 @@ func (t *Translator) getUpstreams(serviceMap map[string]kongstate.Service) ([]ko newTargets := getServiceEndpoints(t.logger, t.storer, k8sService, port) if len(newTargets) == 0 { - t.logger.V(util.InfoLevel).Info("No targets could be found for kubernetes service", + t.logger.V(logging.InfoLevel).Info("No targets could be found for kubernetes service", "namespace", k8sService.Namespace, "name", k8sService.Name, "kong_service", *service.Name) } @@ -117,7 +118,7 @@ func (t *Translator) getUpstreams(serviceMap map[string]kongstate.Service) ([]ko targets := lo.Values(targetMap) // warn if an upstream was created with 0 targets if len(targets) == 0 { - t.logger.V(util.InfoLevel).Info("No targets found to create upstream", "service_name", *service.Name) + t.logger.V(logging.InfoLevel).Info("No targets found to create upstream", "service_name", *service.Name) } // define the upstream including all the newly populated targets @@ -207,7 +208,7 @@ func getServiceEndpoints( var isSvcUpstream bool ingressClassParameters, err := getIngressClassParametersOrDefault(s) if err != nil { - logger.V(util.DebugLevel).Info("Unable to retrieve IngressClassParameters", "error", err) + logger.V(logging.DebugLevel).Info("Unable to retrieve IngressClassParameters", "error", err) } else { isSvcUpstream = ingressClassParameters.ServiceUpstream } @@ -219,7 +220,7 @@ func getServiceEndpoints( endpoints = append(endpoints, newEndpoints...) } if len(endpoints) == 0 { - logger.V(util.DebugLevel).Info("No active endpoints") + logger.V(logging.DebugLevel).Info("No active endpoints") } return targetsForEndpoints(endpoints) @@ -277,7 +278,7 @@ func getEndpoints( // ExternalName services if service.Spec.Type == corev1.ServiceTypeExternalName { - logger.V(util.DebugLevel).Info("Found service of type=ExternalName") + logger.V(logging.DebugLevel).Info("Found service of type=ExternalName") return []util.Endpoint{ { Address: service.Spec.ExternalName, @@ -286,13 +287,13 @@ func getEndpoints( } } - logger.V(util.DebugLevel).Info("Fetching EndpointSlices") + logger.V(logging.DebugLevel).Info("Fetching EndpointSlices") endpointSlices, err := getEndpointSlices(service.Namespace, service.Name) if err != nil { logger.Error(err, "Error fetching EndpointSlices") return []util.Endpoint{} } - logger.V(util.DebugLevel).Info("Fetched EndpointSlices", "count", len(endpointSlices)) + logger.V(logging.DebugLevel).Info("Fetched EndpointSlices", "count", len(endpointSlices)) // Avoid duplicated upstream servers when the service contains // multiple port definitions sharing the same target port. @@ -327,7 +328,7 @@ func getEndpoints( } } } - logger.V(util.DebugLevel).Info("Found endpoints", "endpoints", upstreamServers) + logger.V(logging.DebugLevel).Info("Found endpoints", "endpoints", upstreamServers) return upstreamServers } diff --git a/internal/diagnostics/server.go b/internal/diagnostics/server.go index e642a3aef5..00d7d8a6d4 100644 --- a/internal/diagnostics/server.go +++ b/internal/diagnostics/server.go @@ -14,7 +14,7 @@ import ( "github.com/kong/go-database-reconciler/pkg/file" "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/fallback" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) const ( @@ -138,7 +138,7 @@ func (s *Server) receiveConfig(ctx context.Context) { s.logger.Error(err, "Shutting down diagnostic config collection: context completed with error") return } - s.logger.V(util.InfoLevel).Info("Shutting down diagnostic config collection: context completed") + s.logger.V(logging.InfoLevel).Info("Shutting down diagnostic config collection: context completed") return } } diff --git a/internal/konnect/node_agent.go b/internal/konnect/node_agent.go index 2e3060120a..8ac8a717a6 100644 --- a/internal/konnect/node_agent.go +++ b/internal/konnect/node_agent.go @@ -13,7 +13,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/clients" "github.com/kong/kubernetes-ingress-controller/v3/internal/konnect/nodes" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/clock" ) @@ -162,7 +162,7 @@ func (a *NodeAgent) updateNodeLoop(ctx context.Context) { a.logger.Info("Update node loop stopped", "message", err.Error()) return case <-a.refreshTicker.Channel(): - a.logger.V(util.DebugLevel).Info("Updating nodes on tick") + a.logger.V(logging.DebugLevel).Info("Updating nodes on tick") err := a.updateNodes(ctx) if err != nil { a.logger.Error(err, "Failed to update nodes") @@ -191,11 +191,11 @@ func (a *NodeAgent) subscribeConfigStatus(ctx context.Context) { return case configStatus := <-ch: if configStatus == a.configStatus.Load() { - a.logger.V(util.DebugLevel).Info("Config status not changed, skipping update") + a.logger.V(logging.DebugLevel).Info("Config status not changed, skipping update") continue } - a.logger.V(util.DebugLevel).Info("Config status changed, updating nodes") + a.logger.V(logging.DebugLevel).Info("Config status changed, updating nodes") a.configStatus.Store(configStatus) if err := a.updateNodes(ctx); err != nil { a.logger.Error(err, "Failed to update nodes after config status changed") @@ -217,7 +217,7 @@ func (a *NodeAgent) subscribeToGatewayClientsChanges(ctx context.Context) { a.logger.Info("Subscribe gateway clients changes loop stopped", "message", ctx.Err().Error()) return case <-gatewayClientsChangedCh: - a.logger.V(util.DebugLevel).Info("Gateway clients changed, updating nodes") + a.logger.V(logging.DebugLevel).Info("Gateway clients changed, updating nodes") if err := a.updateNodes(ctx); err != nil { a.logger.Error(err, "Failed to update nodes after gateway clients changed") } @@ -238,7 +238,7 @@ func (a *NodeAgent) updateKICNode(ctx context.Context, existingNodes []*nodes.No nodesWithSameName = append(nodesWithSameName, node) } else { // delete the nodes with different name of the current node, since only on KIC node is allowed in the control plane. - a.logger.V(util.DebugLevel).Info("Remove outdated KIC node", "node_id", node.ID, "hostname", node.Hostname) + a.logger.V(logging.DebugLevel).Info("Remove outdated KIC node", "node_id", node.ID, "hostname", node.Hostname) err := a.nodeClient.DeleteNode(ctx, node.ID) if err != nil { a.logger.Error(err, "Failed to delete KIC node", "node_id", node.ID, "hostname", node.Hostname) @@ -271,7 +271,7 @@ func (a *NodeAgent) updateKICNode(ctx context.Context, existingNodes []*nodes.No // create a new node if there is no existing node with same name as the current KIC node. if len(nodesWithSameName) == 0 { - a.logger.V(util.DebugLevel).Info("No nodes found for KIC pod, should create one", "hostname", a.hostname) + a.logger.V(logging.DebugLevel).Info("No nodes found for KIC pod, should create one", "hostname", a.hostname) createNodeReq := &nodes.CreateNodeRequest{ ID: a.managerInstanceIDProvider.GetID().String(), Hostname: a.hostname, @@ -302,7 +302,7 @@ func (a *NodeAgent) updateKICNode(ctx context.Context, existingNodes []*nodes.No a.logger.Error(err, "Failed to update node for KIC") return err } - a.logger.V(util.DebugLevel).Info("Updated last ping time of node for KIC", "node_id", latestNode.ID, "hostname", a.hostname) + a.logger.V(logging.DebugLevel).Info("Updated last ping time of node for KIC", "node_id", latestNode.ID, "hostname", a.hostname) // treat more nodes with the same name as outdated, and remove them. for i := 1; i < len(nodesWithSameName); i++ { @@ -312,7 +312,7 @@ func (a *NodeAgent) updateKICNode(ctx context.Context, existingNodes []*nodes.No a.logger.Error(err, "Failed to delete outdated KIC node", "node_id", node.ID, "hostname", node.Hostname) continue } - a.logger.V(util.DebugLevel).Info("Removed outdated KIC node", "node_id", node.ID, "hostname", node.Hostname) + a.logger.V(logging.DebugLevel).Info("Removed outdated KIC node", "node_id", node.ID, "hostname", node.Hostname) } return nil } @@ -371,7 +371,7 @@ func (a *NodeAgent) updateGatewayNodes(ctx context.Context, existingNodes []*nod a.logger.Error(err, "Failed to update kong gateway node", "hostname", gateway.Hostname, "node_id", latestNode.ID) continue } - a.logger.V(util.DebugLevel).Info("Updated kong gateway node", "hostname", gateway.Hostname, "node_id", latestNode.ID) + a.logger.V(logging.DebugLevel).Info("Updated kong gateway node", "hostname", gateway.Hostname, "node_id", latestNode.ID) // succeeded to update node, remove the other outdated nodes. for i := 1; i < len(ns); i++ { node := ns[i] @@ -380,7 +380,7 @@ func (a *NodeAgent) updateGatewayNodes(ctx context.Context, existingNodes []*nod a.logger.Error(err, "Failed to delete outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) continue } - a.logger.V(util.DebugLevel).Info("Removed outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) + a.logger.V(logging.DebugLevel).Info("Removed outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) } } @@ -394,7 +394,7 @@ func (a *NodeAgent) updateGatewayNodes(ctx context.Context, existingNodes []*nod a.logger.Error(err, "Failed to delete outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) continue } - a.logger.V(util.DebugLevel).Info("Removed outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) + a.logger.V(logging.DebugLevel).Info("Removed outdated kong gateway node", "node_id", node.ID, "hostname", node.Hostname) } } } diff --git a/internal/license/agent.go b/internal/license/agent.go index 6a46e026c1..1d1cc84f11 100644 --- a/internal/license/agent.go +++ b/internal/license/agent.go @@ -10,7 +10,7 @@ import ( "github.com/samber/lo" "github.com/samber/mo" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/clock" ) @@ -119,7 +119,7 @@ func (a *Agent) NeedLeaderElection() bool { // Start starts the Agent. It attempts to pull an initial license from upstream, and then polls for updates on a // regular period, either the agent's initialPollingPeriod if it has not yet obtained a license or regularPollingPeriod if it has. func (a *Agent) Start(ctx context.Context) error { - a.logger.V(util.DebugLevel).Info("Starting license agent") + a.logger.V(logging.DebugLevel).Info("Starting license agent") err := a.reconcileLicenseWithKonnect(ctx) if err != nil { @@ -134,7 +134,7 @@ func (a *Agent) Start(ctx context.Context) error { // as Kong will auto-populate these when adding the license to its config database. // It's optional because we may not have retrieved a license yet. func (a *Agent) GetLicense() mo.Option[kong.License] { - a.logger.V(util.DebugLevel).Info("Retrieving license from cache") + a.logger.V(logging.DebugLevel).Info("Retrieving license from cache") a.mutex.RLock() defer a.mutex.RUnlock() @@ -164,7 +164,7 @@ func (a *Agent) runPollingLoop(ctx context.Context) error { for { select { case <-ch: - a.logger.V(util.DebugLevel).Info("Retrieving license from external service") + a.logger.V(logging.DebugLevel).Info("Retrieving license from external service") if err := a.reconcileLicenseWithKonnect(ctx); err != nil { a.logger.Error(err, "Could not reconcile license with Konnect") } @@ -197,23 +197,23 @@ func (a *Agent) reconcileLicenseWithKonnect(ctx context.Context) error { retrievedLicense, retrievedLicenseOk := retrievedLicenseOpt.Get() if !retrievedLicenseOk { // If we get no license from Konnect, we cannot do anything. - a.logger.V(util.DebugLevel).Info("No license found in Konnect") + a.logger.V(logging.DebugLevel).Info("No license found in Konnect") return nil } if a.cachedLicense.IsAbsent() { - a.logger.V(util.InfoLevel).Info("Caching initial license retrieved from the upstream", + a.logger.V(logging.InfoLevel).Info("Caching initial license retrieved from the upstream", "updated_at", retrievedLicense.UpdatedAt.String(), ) a.updateCache(retrievedLicense) } else if cachedLicense, ok := a.cachedLicense.Get(); ok && retrievedLicense.UpdatedAt.After(cachedLicense.UpdatedAt) { - a.logger.V(util.InfoLevel).Info("Caching license retrieved from the upstream as it is newer than the cached one", + a.logger.V(logging.InfoLevel).Info("Caching license retrieved from the upstream as it is newer than the cached one", "cached_updated_at", cachedLicense.UpdatedAt.String(), "retrieved_updated_at", retrievedLicense.UpdatedAt.String(), ) a.updateCache(retrievedLicense) } else { - a.logger.V(util.DebugLevel).Info("License cache is up to date") + a.logger.V(logging.DebugLevel).Info("License cache is up to date") } return nil diff --git a/internal/util/logging.go b/internal/logging/logging.go similarity index 99% rename from internal/util/logging.go rename to internal/logging/logging.go index d0b90d5e93..0fba1da6da 100644 --- a/internal/util/logging.go +++ b/internal/logging/logging.go @@ -1,4 +1,4 @@ -package util +package logging import ( "fmt" diff --git a/internal/manager/setup.go b/internal/manager/setup.go index ec61cbae02..4322d1ae71 100644 --- a/internal/manager/setup.go +++ b/internal/manager/setup.go @@ -33,9 +33,9 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/translator" konnectLicense "github.com/kong/kubernetes-ingress-controller/v3/internal/konnect/license" "github.com/kong/kubernetes-ingress-controller/v3/internal/license" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" "github.com/kong/kubernetes-ingress-controller/v3/internal/manager/scheme" "github.com/kong/kubernetes-ingress-controller/v3/internal/store" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" "github.com/kong/kubernetes-ingress-controller/v3/internal/util/kubernetes/object/status" ) @@ -45,7 +45,7 @@ import ( // SetupLoggers sets up the loggers for the controller manager. func SetupLoggers(c *Config, output io.Writer) (logr.Logger, error) { - zapBase, err := util.MakeLogger(c.LogLevel, c.LogFormat, output) + zapBase, err := logging.MakeLogger(c.LogLevel, c.LogFormat, output) if err != nil { return logr.Logger{}, fmt.Errorf("failed to make logger: %w", err) } diff --git a/internal/store/store.go b/internal/store/store.go index 32759f0f2b..1e39ae73a2 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -40,7 +40,7 @@ import ( "github.com/kong/kubernetes-ingress-controller/v3/internal/annotations" ctrlutils "github.com/kong/kubernetes-ingress-controller/v3/internal/controllers/utils" "github.com/kong/kubernetes-ingress-controller/v3/internal/gatewayapi" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" kongv1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1" kongv1alpha1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1alpha1" kongv1beta1 "github.com/kong/kubernetes-ingress-controller/v3/pkg/apis/configuration/v1beta1" @@ -180,7 +180,7 @@ func (s Store) ListIngressesV1() []*netv1.Ingress { default: class, err := s.GetIngressClassV1(s.ingressClass) if err != nil { - s.logger.V(util.DebugLevel).Info("IngressClass not found", "class", s.ingressClass) + s.logger.V(logging.DebugLevel).Info("IngressClass not found", "class", s.ingressClass) continue } if !ctrlutils.IsDefaultIngressClass(class) { @@ -704,7 +704,7 @@ func (s Store) ListKongCustomEntities() []*kongv1alpha1.KongCustomEntity { func (s Store) getIngressClassHandling() annotations.ClassMatching { class, err := s.GetIngressClassV1(s.ingressClass) if err != nil { - s.logger.V(util.DebugLevel).Info("IngressClass not found", "class", s.ingressClass) + s.logger.V(logging.DebugLevel).Info("IngressClass not found", "class", s.ingressClass) return annotations.ExactClassMatch } if ctrlutils.IsDefaultIngressClass(class) { diff --git a/test/envtest/log.go b/test/envtest/log.go index f35ca6c7bf..30b0099ef8 100644 --- a/test/envtest/log.go +++ b/test/envtest/log.go @@ -12,7 +12,7 @@ import ( "go.uber.org/zap/zaptest/observer" ctrl "sigs.k8s.io/controller-runtime" - "github.com/kong/kubernetes-ingress-controller/v3/internal/util" + "github.com/kong/kubernetes-ingress-controller/v3/internal/logging" ) type LogsObserver interface { @@ -41,7 +41,7 @@ func DumpLogsIfTestFailed(t *testing.T, logs LogsObserver) { return } - encoder, err := util.GetZapEncoding("text") + encoder, err := logging.GetZapEncoding("text") require.NoError(t, err) t.Logf("Test %s failed: dumping controller logs\n", t.Name())