Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-10 Thread via GitHub


AlinsRan merged PR #2758:
URL: https://github.com/apache/apisix-ingress-controller/pull/2758


-- 
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]



Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-09 Thread via GitHub


AlinsRan commented on code in PR #2758:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2758#discussion_r3212798115


##
internal/webhook/v1/apisixroute_webhook.go:
##
@@ -41,19 +41,24 @@ func SetupApisixRouteWebhookWithManager(mgr ctrl.Manager) 
error {
Complete()
 }
 
-// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=fail,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1,failurePolicy=Ignore
+// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=Ignore,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1

Review Comment:
   Ignoring it is intentional. The current installation is designed to ignore 
this case; the only issue here is that the annotation is incorrect.
   
   If we do not ignore it, then when the controller is unavailable, it may 
prevent resources from being admitted or taking effect at all. For example, 
during startup,
   before the controller is ready, it could intercept standard resources such 
as Ingress and IngressClass, even though those resources may be managed by 
other controllers. That would not be the expected 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]



Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-09 Thread via GitHub


AlinsRan commented on code in PR #2758:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2758#discussion_r3212798115


##
internal/webhook/v1/apisixroute_webhook.go:
##
@@ -41,19 +41,24 @@ func SetupApisixRouteWebhookWithManager(mgr ctrl.Manager) 
error {
Complete()
 }
 
-// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=fail,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1,failurePolicy=Ignore
+// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=Ignore,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1

Review Comment:
   Ignoring it is intentional. The current installation is designed to ignore 
this case; the only issue here is that the annotation is incorrect.
   
   If we do not ignore it, then when the controller is unavailable, it may 
prevent resources from being admitted or taking effect at all. For example, 
during startup,
   before the controller is ready, it could intercept standard resources such 
as Ingress and IngressClass, even though those resources may be managed by other
   controllers. That would not be the expected 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]



Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-09 Thread via GitHub


AlinsRan commented on code in PR #2758:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2758#discussion_r3212763941


##
internal/controller/webhook_validation.go:
##
@@ -0,0 +1,113 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package controller
+
+import (
+   "context"
+
+   "github.com/go-logr/logr"
+   "sigs.k8s.io/controller-runtime/pkg/client"
+
+   v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1"
+   apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
+   "github.com/apache/apisix-ingress-controller/internal/provider"
+   "github.com/apache/apisix-ingress-controller/internal/utils"
+)
+
+func PrepareApisixRouteForValidation(ctx context.Context, c client.Client, log 
logr.Logger, route *apiv2.ApisixRoute) (*provider.TranslateContext, error) {
+   tctx := provider.NewDefaultTranslateContext(ctx)
+
+   ingressClass, err := FindMatchingIngressClass(tctx, c, log, route)
+   if err != nil {
+   return nil, err
+   }
+   if err := ProcessIngressClassParameters(tctx, c, log, route, 
ingressClass); err != nil {
+   return nil, err
+   }
+
+   reconciler := &ApisixRouteReconciler{
+   Client: c,
+   Log:log,
+   }
+   if err := reconciler.processApisixRoute(tctx, route); err != nil {
+   return nil, err
+   }
+   return tctx, nil
+}
+
+func PrepareApisixConsumerForValidation(ctx context.Context, c client.Client, 
log logr.Logger, consumer *apiv2.ApisixConsumer) (*provider.TranslateContext, 
error) {
+   tctx := provider.NewDefaultTranslateContext(ctx)
+
+   ingressClass, err := FindMatchingIngressClass(tctx, c, log, consumer)
+   if err != nil {
+   return nil, err
+   }
+   if err := ProcessIngressClassParameters(tctx, c, log, consumer, 
ingressClass); err != nil {
+   return nil, err
+   }
+
+   reconciler := &ApisixConsumerReconciler{
+   Client: c,
+   Log:log,
+   }
+   if err := reconciler.processSpec(ctx, tctx, consumer); err != nil {
+   return nil, err
+   }
+   return tctx, nil
+}
+
+func PrepareConsumerForValidation(ctx context.Context, c client.Client, log 
logr.Logger, consumer *v1alpha1.Consumer) (*provider.TranslateContext, error) {

Review Comment:
   There are two types of resource `kind: Consumer` and `kind: ApisixConsumer`
   



-- 
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]



Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-09 Thread via GitHub


shreemaan-abhishek commented on code in PR #2758:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2758#discussion_r3212761443


##
internal/webhook/v1/apisixroute_webhook.go:
##
@@ -41,19 +41,24 @@ func SetupApisixRouteWebhookWithManager(mgr ctrl.Manager) 
error {
Complete()
 }
 
-// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=fail,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1,failurePolicy=Ignore
+// 
+kubebuilder:webhook:path=/validate-apisix-apache-org-v2-apisixroute,mutating=false,failurePolicy=Ignore,sideEffects=None,groups=apisix.apache.org,resources=apisixroutes,verbs=create;update,versions=v2,name=vapisixroute-v2.kb.io,admissionReviewVersions=v1

Review Comment:
   now why do we just ignore in failure?



-- 
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]



Re: [PR] feat: add ADC-backed admission validation for APISIX CRDs [apisix-ingress-controller]

2026-05-09 Thread via GitHub


shreemaan-abhishek commented on code in PR #2758:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/2758#discussion_r3212732522


##
internal/controller/webhook_validation.go:
##
@@ -0,0 +1,113 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package controller
+
+import (
+   "context"
+
+   "github.com/go-logr/logr"
+   "sigs.k8s.io/controller-runtime/pkg/client"
+
+   v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1"
+   apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
+   "github.com/apache/apisix-ingress-controller/internal/provider"
+   "github.com/apache/apisix-ingress-controller/internal/utils"
+)
+
+func PrepareApisixRouteForValidation(ctx context.Context, c client.Client, log 
logr.Logger, route *apiv2.ApisixRoute) (*provider.TranslateContext, error) {
+   tctx := provider.NewDefaultTranslateContext(ctx)
+
+   ingressClass, err := FindMatchingIngressClass(tctx, c, log, route)
+   if err != nil {
+   return nil, err
+   }
+   if err := ProcessIngressClassParameters(tctx, c, log, route, 
ingressClass); err != nil {
+   return nil, err
+   }
+
+   reconciler := &ApisixRouteReconciler{
+   Client: c,
+   Log:log,
+   }
+   if err := reconciler.processApisixRoute(tctx, route); err != nil {
+   return nil, err
+   }
+   return tctx, nil
+}
+
+func PrepareApisixConsumerForValidation(ctx context.Context, c client.Client, 
log logr.Logger, consumer *apiv2.ApisixConsumer) (*provider.TranslateContext, 
error) {
+   tctx := provider.NewDefaultTranslateContext(ctx)
+
+   ingressClass, err := FindMatchingIngressClass(tctx, c, log, consumer)
+   if err != nil {
+   return nil, err
+   }
+   if err := ProcessIngressClassParameters(tctx, c, log, consumer, 
ingressClass); err != nil {
+   return nil, err
+   }
+
+   reconciler := &ApisixConsumerReconciler{
+   Client: c,
+   Log:log,
+   }
+   if err := reconciler.processSpec(ctx, tctx, consumer); err != nil {
+   return nil, err
+   }
+   return tctx, nil
+}
+
+func PrepareConsumerForValidation(ctx context.Context, c client.Client, log 
logr.Logger, consumer *v1alpha1.Consumer) (*provider.TranslateContext, error) {

Review Comment:
   why are there two similar functions `PrepareApisixConsumerForValidation` and 
`PrepareConsumerForValidation`? and this file does not contain functions for 
all apisix resources, why?



-- 
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]