Skip to content

Commit e002b4e

Browse files
committed
Fix route_controller_test
1 parent c4a6cae commit e002b4e

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build and Deploy Apps
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
jobs:
7+
build:
8+
name: Build and Push to ECR with Docker Buildx Cache
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
12+
id-token: write
13+
14+
strategy:
15+
matrix:
16+
service: [aws-gateway-controller]
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Docker Buildx
23+
uses: docker/setup-buildx-action@v3
24+
25+
- name: Configure AWS credentials from OIDC
26+
uses: aws-actions/configure-aws-credentials@v4
27+
with:
28+
aws-region: ap-northeast-1
29+
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
30+
role-session-name: GitHubActions
31+
32+
- name: Login to Amazon ECR
33+
uses: aws-actions/amazon-ecr-login@v2
34+
35+
- name: Build and push Docker image with Buildx
36+
run: |
37+
docker buildx build \
38+
-t "${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-1.amazonaws.com/${{ matrix.service }}:${{github.sha}}" \
39+
-t "${{ vars.AWS_ACCOUNT_ID }}.dkr.ecr.ap-northeast-1.amazonaws.com/${{ matrix.service }}:latest" \
40+
--push \
41+
.

pkg/controllers/route_controller.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,32 +85,16 @@ func RegisterAllRouteControllers(
8585
mgr ctrl.Manager,
8686
) error {
8787
mgrClient := mgr.GetClient()
88-
8988
gwEventHandler := eventhandlers.NewEnqueueRequestGatewayEvent(log, mgrClient)
9089
svcEventHandler := eventhandlers.NewServiceEventHandler(log, mgrClient)
9190

9291
routeInfos := []struct {
9392
routeType core.RouteType
9493
gatewayApiType client.Object
9594
}{
96-
{core.HttpRouteType, &gwv1.HTTPRoute{
97-
TypeMeta: metav1.TypeMeta{
98-
APIVersion: gwv1.GroupVersion.String(),
99-
Kind: "HTTPRoute",
100-
},
101-
}},
102-
{core.GrpcRouteType, &gwv1.GRPCRoute{
103-
TypeMeta: metav1.TypeMeta{
104-
APIVersion: gwv1.GroupVersion.String(),
105-
Kind: "GRPCRoute",
106-
},
107-
}},
108-
{core.TlsRouteType, &gwv1alpha2.TLSRoute{
109-
TypeMeta: metav1.TypeMeta{
110-
APIVersion: gwv1.GroupVersion.String(),
111-
Kind: "TLSRoute",
112-
},
113-
}},
95+
{core.HttpRouteType, &gwv1.HTTPRoute{}},
96+
{core.GrpcRouteType, &gwv1.GRPCRoute{}},
97+
{core.TlsRouteType, &gwv1alpha2.TLSRoute{}},
11498
}
11599

116100
for _, routeInfo := range routeInfos {
@@ -185,6 +169,7 @@ func (r *routeReconciler) reconcile(ctx context.Context, req ctrl.Request) error
185169
if err != nil {
186170
return client.IgnoreNotFound(err)
187171
}
172+
188173
if err = r.client.Get(ctx, req.NamespacedName, route.K8sObject()); err != nil {
189174
return client.IgnoreNotFound(err)
190175
}

pkg/controllers/route_controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package controllers
22

33
import (
44
"context"
5+
"testing"
6+
57
mock_client "github.com/aws/aws-application-networking-k8s/mocks/controller-runtime/client"
68
anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1"
79
aws2 "github.com/aws/aws-application-networking-k8s/pkg/aws"
@@ -27,7 +29,6 @@ import (
2729
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2830
"sigs.k8s.io/external-dns/endpoint"
2931
gwv1 "sigs.k8s.io/gateway-api/apis/v1"
30-
"testing"
3132
)
3233

3334
func TestRouteReconciler_ReconcileCreates(t *testing.T) {
@@ -52,8 +53,7 @@ func TestRouteReconciler_ReconcileCreates(t *testing.T) {
5253

5354
gwClass := &gwv1.GatewayClass{
5455
ObjectMeta: metav1.ObjectMeta{
55-
Name: "amazon-vpc-lattice",
56-
Namespace: defaultNamespace,
56+
Name: "amazon-vpc-lattice",
5757
},
5858
Spec: gwv1.GatewayClassSpec{
5959
ControllerName: config.LatticeGatewayControllerName,

pkg/gateway/model_build_lattice_service.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,20 +131,18 @@ func (t *latticeServiceModelBuildTask) buildLatticeService(ctx context.Context)
131131
}
132132
err := t.client.Get(ctx, client.ObjectKey{Name: string(parentRef.Name), Namespace: parentNamespace}, gw)
133133
if err != nil {
134-
//TODO: error message
135-
t.log.Infof(ctx, "Ignore %s route because failed to get gateway %s: %v", t.route.Name(), parentRef.Name, err)
134+
t.log.Infof(ctx, "Ignoring route %s because failed to get gateway %s: %v", t.route.Name(), gw.Spec.GatewayClassName, err)
136135
continue
137136
}
138137
gwClass := &gwv1.GatewayClass{}
139138
// GatewayClass is cluster-scoped resource, so we don't need to specify namespace
140139
err = t.client.Get(ctx, client.ObjectKey{Name: string(gw.Spec.GatewayClassName)}, gwClass)
141140
if err != nil {
142-
//TODO: error message
143-
t.log.Infof(ctx, "Ignore %s route because failed to get gateway class %s: %v", t.route.Name(), gw.Spec.GatewayClassName, err)
141+
t.log.Infof(ctx, "Ignoring route %s because failed to get gateway class %s: %v", t.route.Name(), gw.Spec.GatewayClassName, err)
144142
continue
145143
}
146144
if gwClass.Spec.ControllerName != config.LatticeGatewayControllerName {
147-
t.log.Infof(ctx, "Ignore %s route because gateway class %s is not for lattice gateway", t.route.Name(), gw.Spec.GatewayClassName)
145+
t.log.Infof(ctx, "Ignoring route %s because gateway class %s is not for a VPCLattice", t.route.Name(), gw.Spec.GatewayClassName)
148146
continue
149147
}
150148
spec.ServiceNetworkNames = append(spec.ServiceNetworkNames, string(parentRef.Name))

0 commit comments

Comments
 (0)