Skip to content

Commit 00dcc1a

Browse files
committed
Fix failing e2e test
1 parent dd7d259 commit 00dcc1a

File tree

6 files changed

+52
-2
lines changed

6 files changed

+52
-2
lines changed

pkg/deploy/elbv2/target_group_binding_manager.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ func buildK8sTargetGroupBindingSpec(ctx context.Context, resTGB *elbv2model.Targ
187187
}
188188
k8sTGBSpec.NodeSelector = resTGB.Spec.Template.Spec.NodeSelector
189189
k8sTGBSpec.IPAddressType = resTGB.Spec.Template.Spec.IPAddressType
190+
k8sTGBSpec.VpcId = resTGB.Spec.Template.Spec.VpcId
190191
return k8sTGBSpec, nil
191192
}
192193

pkg/ingress/model_build_target_group.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingSpec(ctx context.Context,
7777
Networking: tgbNetworking,
7878
NodeSelector: nodeSelector,
7979
IPAddressType: (*elbv2api.TargetGroupIPAddressType)(tg.Spec.IPAddressType),
80+
VpcId: t.vpcID,
8081
},
8182
},
8283
}

pkg/ingress/model_builder_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ const baseStackJSON = `
308308
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/ns-1/ing-1-svc-1:http/status/targetGroupARN"
309309
},
310310
"targetType":"instance",
311+
"vpcId": "vpc-dummy",
311312
"ipAddressType":"ipv4",
312313
"serviceRef":{
313314
"name":"svc-1",
@@ -350,6 +351,7 @@ const baseStackJSON = `
350351
},
351352
"targetType":"instance",
352353
"ipAddressType":"ipv4",
354+
"vpcId": "vpc-dummy",
353355
"serviceRef":{
354356
"name":"svc-2",
355357
"port":"http"
@@ -390,6 +392,7 @@ const baseStackJSON = `
390392
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/ns-1/ing-1-svc-3:https/status/targetGroupARN"
391393
},
392394
"targetType":"ip",
395+
"vpcId": "vpc-dummy",
393396
"ipAddressType":"ipv4",
394397
"serviceRef":{
395398
"name":"svc-3",
@@ -1131,7 +1134,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
11311134
"port": 443,
11321135
"protocol": "HTTPS",
11331136
"sslPolicy": "ELBSecurityPolicy-2016-08",
1134-
"mutualAuthentication" : {
1137+
"mutualAuthentication" : {
11351138
"mode" : "off"
11361139
}
11371140
}
@@ -1442,6 +1445,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
14421445
},
14431446
"spec": {
14441447
"ipAddressType": "ipv4",
1448+
"vpcId": "vpc-dummy",
14451449
"networking": {
14461450
"ingress": [
14471451
{
@@ -2429,6 +2433,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
24292433
},
24302434
"spec": {
24312435
"ipAddressType": "ipv6",
2436+
"vpcId": "vpc-dummy",
24322437
"networking": {
24332438
"ingress": [
24342439
{
@@ -2695,6 +2700,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
26952700
},
26962701
"spec": {
26972702
"ipAddressType": "ipv4",
2703+
"vpcId": "vpc-dummy",
26982704
"networking": {
26992705
"ingress": [
27002706
{
@@ -2854,6 +2860,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
28542860
},
28552861
"spec": {
28562862
"ipAddressType": "ipv4",
2863+
"vpcId": "vpc-dummy",
28572864
"networking": {
28582865
"ingress": [
28592866
{

pkg/model/elbv2/target_group_binding.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ type TargetGroupBindingSpec struct {
103103
// ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
104104
// +optional
105105
IPAddressType *elbv2api.TargetGroupIPAddressType `json:"ipAddressType,omitempty"`
106+
107+
// VpcId is the VPC of the TargetGroup. If unspecified, it will be automatically inferred.
108+
// +optional
109+
VpcId string `json:"vpcId,omitempty"`
106110
}
107111

108112
// Template for TargetGroupBinding Custom Resource.

pkg/service/model_build_target_group.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingSpec(ctx context.Context,
444444
Networking: tgbNetworking,
445445
NodeSelector: nodeSelector,
446446
IPAddressType: (*elbv2api.TargetGroupIPAddressType)(targetGroup.Spec.IPAddressType),
447+
VpcId: t.vpcID,
447448
},
448449
},
449450
}, nil

pkg/service/model_builder_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
233233
},
234234
"targetType":"ip",
235235
"ipAddressType":"ipv4",
236+
"vpcId": "vpc-xxx",
236237
"serviceRef":{
237238
"name":"nlb-ip-svc-tls",
238239
"port":80
@@ -380,6 +381,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
380381
},
381382
"targetType":"ip",
382383
"ipAddressType":"ipv4",
384+
"vpcId": "vpc-xxx",
383385
"serviceRef":{
384386
"name":"nlb-ip-svc-tls",
385387
"port":80
@@ -598,6 +600,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
598600
},
599601
"targetType":"ip",
600602
"ipAddressType":"ipv4",
603+
"vpcId": "vpc-xxx",
601604
"serviceRef":{
602605
"name":"nlb-ip-svc",
603606
"port":80
@@ -664,6 +667,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
664667
},
665668
"targetType":"ip",
666669
"ipAddressType":"ipv4",
670+
"vpcId": "vpc-xxx",
667671
"serviceRef":{
668672
"name":"nlb-ip-svc",
669673
"port":83
@@ -942,6 +946,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
942946
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
943947
},
944948
"targetType":"ip",
949+
"vpcId": "vpc-xxx",
945950
"ipAddressType":"ipv4",
946951
"serviceRef":{
947952
"name":"nlb-ip-svc-tls",
@@ -994,6 +999,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
994999
},
9951000
"targetType":"ip",
9961001
"ipAddressType":"ipv4",
1002+
"vpcId": "vpc-xxx",
9971003
"serviceRef":{
9981004
"name":"nlb-ip-svc-tls",
9991005
"port":83
@@ -1276,6 +1282,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
12761282
},
12771283
"targetType":"instance",
12781284
"ipAddressType":"ipv4",
1285+
"vpcId": "vpc-xxx",
12791286
"serviceRef":{
12801287
"name":"instance-mode",
12811288
"port":80
@@ -1317,6 +1324,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
13171324
},
13181325
"targetType":"instance",
13191326
"ipAddressType":"ipv4",
1327+
"vpcId": "vpc-xxx",
13201328
"serviceRef":{
13211329
"name":"instance-mode",
13221330
"port":83
@@ -1554,6 +1562,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
15541562
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/app/traffic-local:80/status/targetGroupARN"
15551563
},
15561564
"targetType":"instance",
1565+
"vpcId": "vpc-xxx",
15571566
"ipAddressType":"ipv4",
15581567
"serviceRef":{
15591568
"name":"traffic-local",
@@ -1626,6 +1635,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
16261635
},
16271636
"targetType":"instance",
16281637
"ipAddressType":"ipv4",
1638+
"vpcId": "vpc-xxx",
16291639
"serviceRef":{
16301640
"name":"traffic-local",
16311641
"port":83
@@ -1815,6 +1825,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
18151825
},
18161826
"targetType":"ip",
18171827
"ipAddressType":"ipv4",
1828+
"vpcId": "vpc-xxx",
18181829
"serviceRef":{
18191830
"name":"nlb-ip-svc-tls",
18201831
"port":80
@@ -1935,6 +1946,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
19351946
"spec": {
19361947
"targetType": "ip",
19371948
"ipAddressType":"ipv4",
1949+
"vpcId": "vpc-xxx",
19381950
"targetGroupARN": {
19391951
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/ip-target:80/status/targetGroupARN"
19401952
},
@@ -2108,6 +2120,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
21082120
"spec": {
21092121
"targetType": "ip",
21102122
"ipAddressType":"ipv4",
2123+
"vpcId": "vpc-xxx",
21112124
"targetGroupARN": {
21122125
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/default-ip-target:80/status/targetGroupARN"
21132126
},
@@ -2473,6 +2486,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
24732486
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
24742487
},
24752488
"targetType": "instance",
2489+
"vpcId": "vpc-xxx",
24762490
"serviceRef": {
24772491
"name": "traffic-local",
24782492
"port": 80
@@ -2622,6 +2636,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
26222636
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
26232637
},
26242638
"targetType": "instance",
2639+
"vpcId": "vpc-xxx",
26252640
"serviceRef": {
26262641
"name": "traffic-local",
26272642
"port": 80
@@ -2824,6 +2839,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
28242839
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/awesome/lb-with-class:80/status/targetGroupARN"
28252840
},
28262841
"targetType": "instance",
2842+
"vpcId": "vpc-xxx",
28272843
"serviceRef": {
28282844
"name": "lb-with-class",
28292845
"port": 80
@@ -2992,6 +3008,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
29923008
},
29933009
"targetType":"ip",
29943010
"ipAddressType":"ipv4",
3011+
"vpcId": "vpc-xxx",
29953012
"serviceRef":{
29963013
"name":"manual-sg-rule",
29973014
"port":80
@@ -3145,6 +3162,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
31453162
},
31463163
"targetType":"ip",
31473164
"ipAddressType":"ipv4",
3165+
"vpcId": "vpc-xxx",
31483166
"serviceRef":{
31493167
"name":"nlb-ip-svc-tls",
31503168
"port":80
@@ -3326,6 +3344,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
33263344
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
33273345
},
33283346
"targetType":"ip",
3347+
"vpcId": "vpc-xxx",
33293348
"ipAddressType":"ipv4",
33303349
"serviceRef":{
33313350
"name":"nlb-ip-svc-tls",
@@ -3580,6 +3599,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
35803599
},
35813600
"targetType":"ip",
35823601
"ipAddressType":"ipv4",
3602+
"vpcId": "vpc-xxx",
35833603
"serviceRef":{
35843604
"name":"nlb-ip-svc",
35853605
"port":80
@@ -3624,6 +3644,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
36243644
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc:83/status/targetGroupARN"
36253645
},
36263646
"targetType":"ip",
3647+
"vpcId": "vpc-xxx",
36273648
"ipAddressType":"ipv4",
36283649
"serviceRef":{
36293650
"name":"nlb-ip-svc",
@@ -3917,6 +3938,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
39173938
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
39183939
},
39193940
"targetType":"ip",
3941+
"vpcId": "vpc-xxx",
39203942
"ipAddressType":"ipv4",
39213943
"serviceRef":{
39223944
"name":"nlb-ip-svc-tls",
@@ -3958,6 +3980,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
39583980
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:83/status/targetGroupARN"
39593981
},
39603982
"targetType":"ip",
3983+
"vpcId": "vpc-xxx",
39613984
"ipAddressType":"ipv4",
39623985
"serviceRef":{
39633986
"name":"nlb-ip-svc-tls",
@@ -4220,6 +4243,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
42204243
},
42214244
"targetType":"instance",
42224245
"ipAddressType":"ipv4",
4246+
"vpcId": "vpc-xxx",
42234247
"serviceRef":{
42244248
"name":"instance-mode",
42254249
"port":80
@@ -4262,6 +4286,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
42624286
},
42634287
"targetType":"instance",
42644288
"ipAddressType":"ipv4",
4289+
"vpcId": "vpc-xxx",
42654290
"serviceRef":{
42664291
"name":"instance-mode",
42674292
"port":83
@@ -4557,6 +4582,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
45574582
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/app/traffic-local:80/status/targetGroupARN"
45584583
},
45594584
"targetType":"instance",
4585+
"vpcId": "vpc-xxx",
45604586
"ipAddressType":"ipv4",
45614587
"serviceRef":{
45624588
"name":"traffic-local",
@@ -4605,6 +4631,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
46054631
},
46064632
"targetType":"instance",
46074633
"ipAddressType":"ipv4",
4634+
"vpcId": "vpc-xxx",
46084635
"serviceRef":{
46094636
"name":"traffic-local",
46104637
"port":83
@@ -4906,6 +4933,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
49064933
},
49074934
"targetType":"instance",
49084935
"ipAddressType":"ipv4",
4936+
"vpcId": "vpc-xxx",
49094937
"serviceRef":{
49104938
"name":"traffic-local",
49114939
"port":80
@@ -4953,6 +4981,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
49534981
},
49544982
"targetType":"instance",
49554983
"ipAddressType":"ipv4",
4984+
"vpcId": "vpc-xxx",
49564985
"serviceRef":{
49574986
"name":"traffic-local",
49584987
"port":83
@@ -5135,6 +5164,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
51355164
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
51365165
},
51375166
"targetType":"ip",
5167+
"vpcId": "vpc-xxx",
51385168
"ipAddressType":"ipv4",
51395169
"serviceRef":{
51405170
"name":"nlb-ip-svc-tls",
@@ -5275,6 +5305,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
52755305
"spec": {
52765306
"targetType": "ip",
52775307
"ipAddressType":"ipv4",
5308+
"vpcId": "vpc-xxx",
52785309
"targetGroupARN": {
52795310
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/ip-target:80/status/targetGroupARN"
52805311
},
@@ -5526,6 +5557,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
55265557
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
55275558
},
55285559
"targetType": "instance",
5560+
"vpcId": "vpc-xxx",
55295561
"serviceRef": {
55305562
"name": "traffic-local",
55315563
"port": 80
@@ -5709,6 +5741,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
57095741
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
57105742
},
57115743
"targetType": "instance",
5744+
"vpcId": "vpc-xxx",
57125745
"serviceRef": {
57135746
"name": "traffic-local",
57145747
"port": 80
@@ -5891,6 +5924,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
58915924
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/awesome/lb-with-class:80/status/targetGroupARN"
58925925
},
58935926
"targetType": "instance",
5927+
"vpcId": "vpc-xxx",
58945928
"serviceRef": {
58955929
"name": "lb-with-class",
58965930
"port": 80
@@ -6085,6 +6119,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
60856119
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/manual-security-groups:80/status/targetGroupARN"
60866120
},
60876121
"targetType": "ip",
6122+
"vpcId": "vpc-xxx",
60886123
"serviceRef": {
60896124
"name": "manual-security-groups",
60906125
"port": 80
@@ -6224,6 +6259,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
62246259
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/manual-security-groups:80/status/targetGroupARN"
62256260
},
62266261
"targetType": "ip",
6262+
"vpcId": "vpc-xxx",
62276263
"serviceRef": {
62286264
"name": "manual-security-groups",
62296265
"port": 80
@@ -6252,7 +6288,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
62526288
}
62536289
}
62546290
}
6255-
}
6291+
}
62566292
}
62576293
}
62586294
`,

0 commit comments

Comments
 (0)