bzp2010 commented on code in PR #2543:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2543#discussion_r2324515529


##########
internal/controller/apisixglobalrule_controller.go:
##########
@@ -84,11 +82,15 @@ func (r *ApisixGlobalRuleReconciler) Reconcile(ctx 
context.Context, req ctrl.Req
        tctx := provider.NewDefaultTranslateContext(ctx)
 
        // get the ingress class
-       ingressClass, err := GetIngressClass(tctx, r.Client, r.Log, 
globalRule.Spec.IngressClassName)
+       ingressClass, err := FindMatchingIngressClass(tctx, r.Client, r.Log, 
&globalRule)
        if err != nil {

Review Comment:
   If there is a request error caused by the unavailability of apiserver, will 
it delete the resource unexpectedly?
   
   I see that there is no special treatment for this in your matching function.



##########
internal/controller/utils.go:
##########
@@ -1368,7 +1339,12 @@ func ProcessIngressClassParameters(tctx 
*provider.TranslateContext, c client.Cli
        return nil
 }
 
-func GetIngressClass(ctx context.Context, c client.Client, log logr.Logger, 
ingressClassName string) (*networkingv1.IngressClass, error) {
+func FindMatchingIngressClass(ctx context.Context, c client.Client, log 
logr.Logger, obj client.Object) (*networkingv1.IngressClass, error) {
+       ingressClassName := ExtractIngressClass(obj)
+       return FindMatchingIngressClassByName(ctx, c, log, ingressClassName)
+}
+
+func FindMatchingIngressClassByName(ctx context.Context, c client.Client, log 
logr.Logger, ingressClassName string) (*networkingv1.IngressClass, error) {

Review Comment:
   This function does not handle the request failure caused by network failure. 
This will cause unintented delete behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to