Skip to content

Commit aa45ad0

Browse files
committed
update route bug
1 parent 1308590 commit aa45ad0

File tree

9 files changed

+271
-2891
lines changed

9 files changed

+271
-2891
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ permissions:
44
contents: read
55
on:
66
# TODO: Find a secure enough way to run e2e tests from PR on-demand.
7-
push:
8-
branches:
9-
- main
7+
#push:
8+
# branches:
9+
# - main
1010
workflow_dispatch:
1111
jobs:
1212
e2e-test:

helm/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
image:
66
repository: 111815285043.dkr.ecr.ap-northeast-1.amazonaws.com/aws-gateway-controller
77
tag: latest
8+
# repository: public.ecr.aws/aws-application-networking-k8s/aws-gateway-controller
9+
# tag: v1.1.0
810
pullPolicy: Always
911
pullSecrets: []
1012

@@ -77,7 +79,9 @@ serviceAccount:
7779
annotations:
7880
{}
7981
# eks.amazonaws.com/role-arn: arn:aws:iam::AWS_ACCOUNT_ID:role/IAM_ROLE_NAME
80-
82+
awsRegion: ap-northeast-1
83+
awsAccountId: 111815285043
84+
clusterVpcId: vpc-04a3485e6f724b770
8185
clusterName: eks-auto-mode-sample
8286
defaultServiceNetwork: lattice-gateway
8387
latticeEndpoint:

helm/zf26z

Lines changed: 0 additions & 2802 deletions
This file was deleted.

pkg/config/controller_config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ func configInit(sess *session.Session, metadata EC2Metadata) error {
6767
}
6868

6969
if ClusterName = os.Getenv(CLUSTER_NAME); ClusterName == "" {
70+
if sess == nil {
71+
return fmt.Errorf("cluster name is not specified")
72+
}
7073
if ClusterName, err = getClusterName(sess, Region); err != nil {
7174
return fmt.Errorf("cannot get cluster name: %s", err)
7275
}

pkg/controllers/route_controller.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,6 @@ func RegisterAllRouteControllers(
114114
}
115115

116116
for _, routeInfo := range routeInfos {
117-
gv := routeInfo.gatewayApiType.GetObjectKind().GroupVersionKind().GroupVersion().String()
118-
kind := routeInfo.gatewayApiType.GetObjectKind().GroupVersionKind().Kind
119-
log.Infof(context.TODO(), "GVK: %s, %s", gv, kind)
120-
if ok, err := k8s.IsGVKSupported(mgr, gv, kind); !ok {
121-
log.Infof(context.TODO(), "GVK not supported gv: %s, kind: %s", gv, kind)
122-
if err != nil {
123-
log.Infof(context.TODO(), "GVK not supported error: %s", err)
124-
return nil
125-
}
126-
} else {
127-
log.Infof(context.TODO(), "GVK supported gv: %s, kind: %s", gv, kind)
128-
if err != nil {
129-
return err
130-
}
131-
}
132117
brTgBuilder := gateway.NewBackendRefTargetGroupBuilder(log, mgrClient)
133118
reconciler := routeReconciler{
134119
routeType: routeInfo.routeType,
@@ -200,8 +185,6 @@ func (r *routeReconciler) reconcile(ctx context.Context, req ctrl.Request) error
200185
if err != nil {
201186
return client.IgnoreNotFound(err)
202187
}
203-
r.log.Debugw(ctx, "u-kai reconcile after getRoute", "route", route)
204-
205188
if err = r.client.Get(ctx, req.NamespacedName, route.K8sObject()); err != nil {
206189
return client.IgnoreNotFound(err)
207190
}
@@ -293,8 +276,7 @@ func (r *routeReconciler) isRouteRelevant(ctx context.Context, route core.Route)
293276
// make sure gateway is an aws-vpc-lattice
294277
gwClass := &gwv1.GatewayClass{}
295278
gwClassName := types.NamespacedName{
296-
Namespace: defaultNamespace,
297-
Name: string(gw.Spec.GatewayClassName),
279+
Name: string(gw.Spec.GatewayClassName),
298280
}
299281

300282
if err := r.client.Get(ctx, gwClassName, gwClass); err != nil {

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: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,20 @@ func (t *latticeServiceModelBuildTask) buildLatticeService(ctx context.Context)
125125

126126
for _, parentRef := range t.route.Spec().ParentRefs() {
127127
gw := &gwv1.Gateway{}
128-
err := t.client.Get(ctx, client.ObjectKey{Name: string(parentRef.Name), Namespace: string(*parentRef.Namespace)}, gw)
128+
t.log.Debugf(ctx, "Getting gateway %s-%v", parentRef.Name, parentRef.Namespace)
129+
parentNamespace := t.route.Namespace()
130+
if parentRef.Namespace != nil {
131+
parentNamespace = string(*parentRef.Namespace)
132+
}
133+
err := t.client.Get(ctx, client.ObjectKey{Name: string(parentRef.Name), Namespace: parentNamespace}, gw)
129134
if err != nil {
130-
t.log.Infof(ctx, "u-kai: Failed to get gateway %s-%s: %v", parentRef.Name, *parentRef.Namespace, err)
135+
t.log.Infof(ctx, "u-kai: Failed to get gateway %s-%s: %v", parentRef.Name, parentNamespace, err)
131136
continue
132137
}
133138
gwClass := &gwv1.GatewayClass{}
134-
err = t.client.Get(ctx, client.ObjectKey{Name: string(gw.Spec.GatewayClassName), Namespace: gw.Namespace}, gwClass)
139+
err = t.client.Get(ctx, client.ObjectKey{Name: string(gw.Spec.GatewayClassName)}, gwClass)
135140
if err != nil {
136-
t.log.Infof(ctx, "u-kai: Failed to get gateway class %s-%s: %v", gw.Spec.GatewayClassName, gw.Namespace, err)
141+
t.log.Infof(ctx, "u-kai: Failed to get gateway class %s-%s: %v", gw.Spec.GatewayClassName, "default", err)
137142
continue
138143
}
139144
if gwClass.Spec.ControllerName != config.LatticeGatewayControllerName {

0 commit comments

Comments
 (0)