Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/controller/apisixconsumer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,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
}
}
Expand Down
25 changes: 17 additions & 8 deletions internal/controller/apisixroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ import (
corev1 "k8s.io/api/core/v1"
discoveryv1 "k8s.io/api/discovery/v1"
networkingv1 "k8s.io/api/networking/v1"
<<<<<<< HEAD
networkingv1beta1 "k8s.io/api/networking/v1beta1"
=======
k8serrors "k8s.io/apimachinery/pkg/api/errors"
>>>>>>> 16f43280 (fix: incorrect parameters in log message (#2613))
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -433,10 +437,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
}

Expand All @@ -460,7 +465,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
}

Expand All @@ -474,11 +483,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
Expand Down
11 changes: 9 additions & 2 deletions internal/controller/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,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 {
Expand All @@ -472,7 +475,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
}
}
Expand Down