This is an automated email from the ASF dual-hosted git repository.
alinsran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-ingress-controller.git
The following commit(s) were added to refs/heads/master by this push:
new 16f43280 fix: incorrect parameters in log message (#2613)
16f43280 is described below
commit 16f43280defa01186e3b88d94638cfa9b15bbf43
Author: AlinsRan <[email protected]>
AuthorDate: Fri Oct 24 15:03:51 2025 +0800
fix: incorrect parameters in log message (#2613)
---
internal/controller/apisixconsumer_controller.go | 4 ++--
internal/controller/apisixroute_controller.go | 22 ++++++++++++++--------
internal/controller/httproute_controller.go | 11 +++++++++--
3 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/internal/controller/apisixconsumer_controller.go
b/internal/controller/apisixconsumer_controller.go
index 2cb473ca..c40345a5 100644
--- a/internal/controller/apisixconsumer_controller.go
+++ b/internal/controller/apisixconsumer_controller.go
@@ -209,10 +209,10 @@ func (r *ApisixConsumerReconciler) processSpec(ctx
context.Context, tctx *provid
secret := &corev1.Secret{}
if err := r.Get(ctx, namespacedName, secret); err != nil {
if k8serrors.IsNotFound(err) {
- r.Log.Info("secret not found", "secret",
namespacedName.String())
+ r.Log.Info("secret not found", "secret", namespacedName)
return nil
} else {
- r.Log.Error(err, "failed to get secret", "secret",
namespacedName.String())
+ r.Log.Error(err, "failed to get secret", "secret",
namespacedName)
return err
}
}
diff --git a/internal/controller/apisixroute_controller.go
b/internal/controller/apisixroute_controller.go
index c6e3afda..d8c225dc 100644
--- a/internal/controller/apisixroute_controller.go
+++ b/internal/controller/apisixroute_controller.go
@@ -28,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
networkingv1 "k8s.io/api/networking/v1"
+ k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
k8stypes "k8s.io/apimachinery/pkg/types"
@@ -399,10 +400,11 @@ func (r *ApisixRouteReconciler) validateHTTPBackend(tctx
*provider.TranslateCont
)
if err := r.Get(tctx, serviceNN, &service); err != nil {
- if err = client.IgnoreNotFound(err); err == nil {
- r.Log.Error(errors.New("service not found"), "Service",
serviceNN)
+ if k8serrors.IsNotFound(err) {
+ r.Log.Info("service not found", "Service", serviceNN)
return nil
}
+ r.Log.Error(err, "failed to get service", "Service", serviceNN)
return err
}
@@ -426,7 +428,11 @@ func (r *ApisixRouteReconciler) validateHTTPBackend(tctx
*provider.TranslateCont
}
if backend.ResolveGranularity == apiv2.ResolveGranularityService &&
service.Spec.ClusterIP == "" {
- r.Log.Error(errors.New("service has no ClusterIP"), "Service",
serviceNN, "ResolveGranularity", backend.ResolveGranularity)
+ r.Log.Error(errors.New("service has no ClusterIP"),
+ "service missing ClusterIP",
+ "Service", serviceNN,
+ "ResolveGranularity", backend.ResolveGranularity,
+ )
return nil
}
@@ -440,11 +446,11 @@ func (r *ApisixRouteReconciler) validateHTTPBackend(tctx
*provider.TranslateCont
}
return false
}) {
- if backend.ServicePort.Type == intstr.Int {
- r.Log.Error(errors.New("port not found in service"),
"Service", serviceNN, "port", backend.ServicePort.IntValue())
- } else {
- r.Log.Error(errors.New("named port not found in
service"), "Service", serviceNN, "port", backend.ServicePort.StrVal)
- }
+ r.Log.Error(errors.New("service port not found"),
+ "failed to match service port",
+ "Service", serviceNN,
+ "ServicePort", backend.ServicePort,
+ )
return nil
}
tctx.Services[serviceNN] = &service
diff --git a/internal/controller/httproute_controller.go
b/internal/controller/httproute_controller.go
index 1c449e79..34615b9f 100644
--- a/internal/controller/httproute_controller.go
+++ b/internal/controller/httproute_controller.go
@@ -408,7 +408,10 @@ func (r *HTTPRouteReconciler)
listHTTPRouteByHTTPRoutePolicy(ctx context.Context
var httpRoute gatewayv1.HTTPRoute
if err := r.Get(ctx, key, &httpRoute); err != nil {
- r.Log.Error(err, "failed to get HTTPRoute by
HTTPRoutePolicy targetRef", "namespace", key.Namespace, "name", key.Name)
+ r.Log.Error(errors.New("httproute not found"),
+ "failed to get HTTPRoute rule for
HTTPRoutePolicy targetRef",
+ "httproute", key,
+ )
continue
}
if ref.SectionName != nil {
@@ -420,7 +423,11 @@ func (r *HTTPRouteReconciler)
listHTTPRouteByHTTPRoutePolicy(ctx context.Context
}
}
if !matchRuleName {
- r.Log.Error(errors.Errorf("failed to get
HTTPRoute rule by HTTPRoutePolicy targetRef"), "namespace", key.Namespace,
"name", key.Name, "sectionName", *ref.SectionName)
+ r.Log.Error(errors.New("httproute section name
not found"),
+ "failed to get HTTPRoute rule by
HTTPRoutePolicy targetRef",
+ "httproute", key,
+ "sectionName", *ref.SectionName,
+ )
continue
}
}