Skip to content
Merged
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
22 changes: 20 additions & 2 deletions .github/workflows/conformance-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
go install sigs.k8s.io/[email protected]

e2e-test:
conformance-test:
needs:
- prepare
runs-on: buildjet-2vcpu-ubuntu-2204
Expand Down Expand Up @@ -85,11 +85,29 @@ jobs:
shell: bash
env:
API7_EE_LICENSE: ${{ secrets.API7_EE_LICENSE }}
continue-on-error: true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在一致性测试中,用例中会使用不同的 gateway 进行,以隔离环境。
由于目前只支持一个 gateway,配置的路由规则会互相影响,很大概率会失败。
后续随着 ingress 完善,集中修复即可。

run: |
make conformance-test

- name: Upload Gateway API Conformance Report
if: ${{ github.event_name == 'push' }}
uses: actions/upload-artifact@v4
with:
name: api7-ingress-controller-conformance-report.yaml
path: api7-ingress-controller-conformance-report.yaml

- name: Format Conformance Test Report
if: ${{ github.event_name == 'pull_request' }}
run: |
echo '# conformance test report' > report.md
echo '```yaml' >> report.md
cat api7-ingress-controller-conformance-report.yaml >> report.md
echo '```' >> report.md

- name: Report Conformance Test Result to PR Comment
if: ${{ github.event_name == 'pull_request' }}
uses: mshick/add-pr-comment@v2
with:
message-id: '${{ matrix.target }}'
message-path: |
report.md
45 changes: 45 additions & 0 deletions internal/controller/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand Down Expand Up @@ -47,6 +49,25 @@ func (r *HTTPRouteReconciler) SetupWithManager(mgr ctrl.Manager) error {
Watches(&v1alpha1.PluginConfig{},
handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesByExtensionRef),
).
Watches(&gatewayv1.Gateway{},
handler.EnqueueRequestsFromMapFunc(r.listHTTPRoutesForGateway),
builder.WithPredicates(
predicate.Funcs{
GenericFunc: func(e event.GenericEvent) bool {
return false
},
DeleteFunc: func(e event.DeleteEvent) bool {
return false
},
CreateFunc: func(e event.CreateEvent) bool {
return true
},
UpdateFunc: func(e event.UpdateEvent) bool {
return true
},
},
),
).
Complete(r)
}

Expand Down Expand Up @@ -190,6 +211,30 @@ func (r *HTTPRouteReconciler) listHTTPRoutesByExtensionRef(ctx context.Context,
return requests
}

func (r *HTTPRouteReconciler) listHTTPRoutesForGateway(ctx context.Context, obj client.Object) []reconcile.Request {
gateway, ok := obj.(*gatewayv1.Gateway)
if !ok {
r.Log.Error(fmt.Errorf("unexpected object type"), "failed to convert object to Gateway")
}
hrList := &gatewayv1.HTTPRouteList{}
if err := r.List(ctx, hrList, client.MatchingFields{
indexer.ParentRefs: indexer.GenIndexKey(gateway.Namespace, gateway.Name),
}); err != nil {
r.Log.Error(err, "failed to list httproutes by gateway", "gateway", gateway.Name)
return nil
}
requests := make([]reconcile.Request, 0, len(hrList.Items))
for _, hr := range hrList.Items {
requests = append(requests, reconcile.Request{
NamespacedName: client.ObjectKey{
Namespace: hr.Namespace,
Name: hr.Name,
},
})
}
return requests
}

func (r *HTTPRouteReconciler) processHTTPRouteBackendRefs(tctx *provider.TranslateContext) error {
var terr error
for _, backend := range tctx.BackendRefs {
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/adc/adc.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
log.Debugw("deleting object", zap.Any("object", obj))

var resourceTypes []string
var labels map[string]string
switch obj.(type) {
case *gatewayv1.HTTPRoute:
resourceTypes = append(resourceTypes, "service")
labels = label.GenLabel(obj)
case *gatewayv1.Gateway:
resourceTypes = append(resourceTypes, "global_rule", "ssl", "plugin_metadata")
// delete all resources
}

return d.sync(Task{
Name: obj.GetName(),
Labels: label.GenLabel(obj),
Labels: labels,
ResourceTypes: resourceTypes,
})
}
Expand Down
24 changes: 23 additions & 1 deletion test/e2e/gatewayapi/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ spec:
})

Context("HTTPRoute Base", func() {

var exactRouteByGet = `
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
Expand Down Expand Up @@ -223,6 +222,29 @@ spec:
Expect().
Status(404)
})

It("Delete Gateway after apply HTTPRoute", func() {
By("create HTTPRoute")
ResourceApplied("HTTPRoute", "httpbin", exactRouteByGet, 1)

By("access daataplane to check the HTTPRoute")
s.NewAPISIXClient().
GET("/get").
WithHost("httpbin.example").
Expect().
Status(200)

By("delete Gateway")
err := s.DeleteResource("Gateway", "api7ee")
Expect(err).NotTo(HaveOccurred(), "deleting Gateway")
time.Sleep(5 * time.Second)

s.NewAPISIXClient().
GET("/get").
WithHost("httpbin.example").
Expect().
Status(404)
})
})
Context("HTTPRoute Rule Match", func() {
var exactRouteByGet = `
Expand Down
Loading