Skip to content

Commit 4d49411

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

File tree

5 files changed

+10
-83
lines changed

5 files changed

+10
-83
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ kind-load-dashboard-images:
200200
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:$(DASHBOARD_VERSION) --name $(KIND_NAME)
201201
@kind load docker-image hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3-integrated:$(DASHBOARD_VERSION) --name $(KIND_NAME)
202202

203+
.PHONY: kind-load-adc-image
204+
kind-load-adc-image:
205+
@kind load docker-image ghcr.io/api7/adc:dev --name $(KIND_NAME)
206+
203207
.PHONY: kind-load-ingress-image
204208
kind-load-ingress-image:
205209
@kind load docker-image $(IMG) --name $(KIND_NAME)

api/adc/types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,6 @@ type StatusEvent struct {
672672
type ResponseDetails struct {
673673
Status int `json:"status"`
674674
Headers map[string]string `json:"headers"`
675-
Data ResponseData `json:"data"`
676675
}
677676

678677
type ResponseData struct {

internal/controller/ingressclass_controller.go

Lines changed: 1 addition & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
networkingv1 "k8s.io/api/networking/v1"
2727
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2828
"k8s.io/apimachinery/pkg/runtime"
29-
"k8s.io/apimachinery/pkg/types"
3029
ctrl "sigs.k8s.io/controller-runtime"
3130
"sigs.k8s.io/controller-runtime/pkg/builder"
3231
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -37,7 +36,6 @@ import (
3736
"github.com/apache/apisix-ingress-controller/api/v1alpha1"
3837
"github.com/apache/apisix-ingress-controller/internal/controller/indexer"
3938
"github.com/apache/apisix-ingress-controller/internal/provider"
40-
"github.com/apache/apisix-ingress-controller/internal/utils"
4139
)
4240

4341
// IngressClassReconciler reconciles a IngressClass object.
@@ -98,7 +96,7 @@ func (r *IngressClassReconciler) Reconcile(ctx context.Context, req ctrl.Request
9896
// Create a translate context
9997
tctx := provider.NewDefaultTranslateContext(ctx)
10098

101-
if err := r.processInfrastructure(tctx, ingressClass); err != nil {
99+
if err := ProcessIngressClassParameters(tctx, r.Client, r.Log, ingressClass, ingressClass); err != nil {
102100
r.Log.Error(err, "failed to process infrastructure for ingressclass", "ingressclass", ingressClass.GetName())
103101
return ctrl.Result{}, err
104102
}
@@ -175,75 +173,3 @@ func (r *IngressClassReconciler) listIngressClassesForSecret(ctx context.Context
175173

176174
return distinctRequests(requests)
177175
}
178-
179-
func (r *IngressClassReconciler) processInfrastructure(tctx *provider.TranslateContext, ingressClass *networkingv1.IngressClass) error {
180-
if ingressClass.Spec.Parameters == nil {
181-
return nil
182-
}
183-
184-
if ingressClass.Spec.Parameters.APIGroup == nil ||
185-
*ingressClass.Spec.Parameters.APIGroup != v1alpha1.GroupVersion.Group ||
186-
ingressClass.Spec.Parameters.Kind != KindGatewayProxy {
187-
return nil
188-
}
189-
190-
namespace := ingressClass.Namespace
191-
if ingressClass.Spec.Parameters.Namespace != nil {
192-
namespace = *ingressClass.Spec.Parameters.Namespace
193-
}
194-
// Check for annotation override
195-
if annotationNamespace, exists := ingressClass.Annotations[parametersNamespaceAnnotation]; exists && annotationNamespace != "" {
196-
namespace = annotationNamespace
197-
}
198-
199-
gatewayProxy := new(v1alpha1.GatewayProxy)
200-
if err := r.Get(context.Background(), client.ObjectKey{
201-
Namespace: namespace,
202-
Name: ingressClass.Spec.Parameters.Name,
203-
}, gatewayProxy); err != nil {
204-
return fmt.Errorf("failed to get gateway proxy: %w", err)
205-
}
206-
207-
rk := utils.NamespacedNameKind(ingressClass)
208-
209-
tctx.GatewayProxies[rk] = *gatewayProxy
210-
tctx.ResourceParentRefs[rk] = append(tctx.ResourceParentRefs[rk], rk)
211-
212-
// Load secrets if needed
213-
if gatewayProxy.Spec.Provider != nil && gatewayProxy.Spec.Provider.ControlPlane != nil {
214-
auth := gatewayProxy.Spec.Provider.ControlPlane.Auth
215-
if auth.Type == v1alpha1.AuthTypeAdminKey && auth.AdminKey != nil && auth.AdminKey.ValueFrom != nil {
216-
if auth.AdminKey.ValueFrom.SecretKeyRef != nil {
217-
secretRef := auth.AdminKey.ValueFrom.SecretKeyRef
218-
secret := &corev1.Secret{}
219-
if err := r.Get(context.Background(), client.ObjectKey{
220-
Namespace: namespace,
221-
Name: secretRef.Name,
222-
}, secret); err != nil {
223-
r.Log.Error(err, "failed to get secret for gateway proxy", "namespace", namespace, "name", secretRef.Name)
224-
return err
225-
}
226-
tctx.Secrets[client.ObjectKey{
227-
Namespace: namespace,
228-
Name: secretRef.Name,
229-
}] = secret
230-
}
231-
}
232-
}
233-
234-
if service := gatewayProxy.Spec.Provider.ControlPlane.Service; service != nil {
235-
if err := addProviderEndpointsToTranslateContext(tctx, r.Client, types.NamespacedName{
236-
Namespace: gatewayProxy.GetNamespace(),
237-
Name: service.Name,
238-
}); err != nil {
239-
return err
240-
}
241-
}
242-
243-
_, ok := tctx.GatewayProxies[rk]
244-
if !ok {
245-
return fmt.Errorf("no gateway proxy found for ingress class")
246-
}
247-
248-
return nil
249-
}

internal/provider/adc/executor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ func (e *HTTPADCExecutor) handleHTTPResponse(resp *http.Response, serverAddr str
413413
zap.String("response", string(body)),
414414
)
415415

416-
if resp.StatusCode != http.StatusOK {
416+
// not only 200, HTTP 202 is also accepted
417+
if resp.StatusCode/100 != 2 {
417418
return types.ADCExecutionServerAddrError{
418419
ServerAddr: serverAddr,
419420
Err: fmt.Sprintf("HTTP %d: %s", resp.StatusCode, string(body)),

test/e2e/framework/manifests/ingress.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,20 +434,18 @@ spec:
434434
args:
435435
- "server"
436436
- "--listen"
437-
- "http://127.0.0.1:3000"
437+
- "http://0.0.0.0:3000"
438438
ports:
439439
- name: http
440440
containerPort: 3000
441441
protocol: TCP
442442
livenessProbe:
443-
httpGet:
444-
path: /healthz
443+
tcpSocket:
445444
port: 3000
446445
initialDelaySeconds: 10
447446
periodSeconds: 10
448447
readinessProbe:
449-
httpGet:
450-
path: /healthz
448+
tcpSocket:
451449
port: 3000
452450
initialDelaySeconds: 5
453451
periodSeconds: 5
@@ -456,7 +454,6 @@ spec:
456454
capabilities:
457455
drop:
458456
- ALL
459-
runAsNonRoot: true
460457
volumes:
461458
- name: ingress-config
462459
configMap:

0 commit comments

Comments
 (0)