Skip to content

Commit e05aca6

Browse files
committed
fix: r
Signed-off-by: Ashing Zheng <[email protected]>
1 parent a9fe90f commit e05aca6

File tree

3 files changed

+40
-39
lines changed

3 files changed

+40
-39
lines changed

internal/controller/apisixconsumer_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ func (r *ApisixConsumerReconciler) Reconcile(ctx context.Context, req ctrl.Reque
100100

101101
if err = ProcessIngressClassParameters(tctx, r.Client, r.Log, ac, ingressClass); err != nil {
102102
r.Log.Error(err, "failed to process IngressClass parameters", "ingressClass", ingressClass.Name)
103-
return ctrl.Result{}, err
103+
return ctrl.Result{}, client.IgnoreNotFound(err)
104104
}
105105

106106
if err = r.processSpec(ctx, tctx, ac); err != nil {
107107
r.Log.Error(err, "failed to process ApisixConsumer spec", "object", ac)
108-
return ctrl.Result{}, err
108+
return ctrl.Result{}, client.IgnoreNotFound(err)
109109
}
110110

111111
if err = r.Provider.Update(ctx, tctx, ac); err != nil {

internal/controller/apisixroute_controller.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ func (r *ApisixRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
168168
defer func() { r.updateStatus(&ar, err) }()
169169

170170
if err = ProcessIngressClassParameters(tctx, r.Client, r.Log, &ar, ic); err != nil {
171-
return ctrl.Result{}, err
171+
r.Log.Error(err, "failed to process IngressClass parameters", "ingressClass", ic.Name)
172+
return ctrl.Result{}, client.IgnoreNotFound(err)
172173
}
173174
if err = r.processApisixRoute(ctx, tctx, &ar); err != nil {
174175
return ctrl.Result{}, err

internal/controller/utils.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,42 +1644,6 @@ func filterEndpointSliceByTargetPod(ctx context.Context, c client.Client, item d
16441644
return item
16451645
}
16461646

1647-
func MatchesIngressClassPredicate(c client.Client, log logr.Logger, apiVersion string) predicate.Funcs {
1648-
predicateFuncs := predicate.NewPredicateFuncs(func(obj client.Object) bool {
1649-
return MatchesIngressClass(c, log, obj, apiVersion)
1650-
})
1651-
predicateFuncs.UpdateFunc = func(e event.UpdateEvent) bool {
1652-
return MatchesIngressClass(c, log, e.ObjectOld, apiVersion) || MatchesIngressClass(c, log, e.ObjectNew, apiVersion)
1653-
}
1654-
return predicateFuncs
1655-
}
1656-
1657-
func MatchesIngressClass(c client.Client, log logr.Logger, obj client.Object, apiVersion string) bool {
1658-
_, err := FindMatchingIngressClassByObject(context.Background(), c, log, obj, apiVersion)
1659-
return err == nil
1660-
}
1661-
1662-
func ExtractIngressClass(obj client.Object) string {
1663-
switch v := obj.(type) {
1664-
case *networkingv1.Ingress:
1665-
return ptr.Deref(v.Spec.IngressClassName, "")
1666-
case *apiv2.ApisixConsumer:
1667-
return v.Spec.IngressClassName
1668-
case *apiv2.ApisixRoute:
1669-
return v.Spec.IngressClassName
1670-
case *apiv2.ApisixTls:
1671-
return v.Spec.IngressClassName
1672-
case *apiv2.ApisixPluginConfig:
1673-
return v.Spec.IngressClassName
1674-
case *apiv2.ApisixUpstream:
1675-
return v.Spec.IngressClassName
1676-
case *apiv2.ApisixGlobalRule:
1677-
return v.Spec.IngressClassName
1678-
default:
1679-
panic(fmt.Errorf("unhandled object type %T for extracting ingress class", obj))
1680-
}
1681-
}
1682-
16831647
func GetGatewayProxyByIngressClass(ctx context.Context, r client.Client, ingressClass *networkingv1.IngressClass) (*v1alpha1.GatewayProxy, error) {
16841648
if ingressClass.Spec.Parameters == nil {
16851649
return nil, nil
@@ -1729,3 +1693,39 @@ func GetGatewayProxyByGateway(ctx context.Context, r client.Client, gateway *gat
17291693
}
17301694
return gatewayProxy, nil
17311695
}
1696+
1697+
func MatchesIngressClassPredicate(c client.Client, log logr.Logger, apiVersion string) predicate.Funcs {
1698+
predicateFuncs := predicate.NewPredicateFuncs(func(obj client.Object) bool {
1699+
return MatchesIngressClass(c, log, obj, apiVersion)
1700+
})
1701+
predicateFuncs.UpdateFunc = func(e event.UpdateEvent) bool {
1702+
return MatchesIngressClass(c, log, e.ObjectOld, apiVersion) || MatchesIngressClass(c, log, e.ObjectNew, apiVersion)
1703+
}
1704+
return predicateFuncs
1705+
}
1706+
1707+
func MatchesIngressClass(c client.Client, log logr.Logger, obj client.Object, apiVersion string) bool {
1708+
_, err := FindMatchingIngressClassByObject(context.Background(), c, log, obj, apiVersion)
1709+
return err == nil
1710+
}
1711+
1712+
func ExtractIngressClass(obj client.Object) string {
1713+
switch v := obj.(type) {
1714+
case *networkingv1.Ingress:
1715+
return ptr.Deref(v.Spec.IngressClassName, "")
1716+
case *apiv2.ApisixConsumer:
1717+
return v.Spec.IngressClassName
1718+
case *apiv2.ApisixRoute:
1719+
return v.Spec.IngressClassName
1720+
case *apiv2.ApisixTls:
1721+
return v.Spec.IngressClassName
1722+
case *apiv2.ApisixPluginConfig:
1723+
return v.Spec.IngressClassName
1724+
case *apiv2.ApisixUpstream:
1725+
return v.Spec.IngressClassName
1726+
case *apiv2.ApisixGlobalRule:
1727+
return v.Spec.IngressClassName
1728+
default:
1729+
panic(fmt.Errorf("unhandled object type %T for extracting ingress class", obj))
1730+
}
1731+
}

0 commit comments

Comments
 (0)