Skip to content

Commit

Permalink
Fix failing e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
ikosenn committed Feb 12, 2024
1 parent dd7d259 commit 85c80f2
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9
1 change: 1 addition & 0 deletions pkg/deploy/elbv2/target_group_binding_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ func buildK8sTargetGroupBindingSpec(ctx context.Context, resTGB *elbv2model.Targ
}
k8sTGBSpec.NodeSelector = resTGB.Spec.Template.Spec.NodeSelector
k8sTGBSpec.IPAddressType = resTGB.Spec.Template.Spec.IPAddressType
k8sTGBSpec.VpcId = resTGB.Spec.Template.Spec.VpcId
return k8sTGBSpec, nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/ingress/model_build_target_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingSpec(ctx context.Context,
Networking: tgbNetworking,
NodeSelector: nodeSelector,
IPAddressType: (*elbv2api.TargetGroupIPAddressType)(tg.Spec.IPAddressType),
VpcId: t.vpcID,
},
},
}
Expand Down
9 changes: 8 additions & 1 deletion pkg/ingress/model_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ const baseStackJSON = `
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/ns-1/ing-1-svc-1:http/status/targetGroupARN"
},
"targetType":"instance",
"vpcId": "vpc-dummy",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"svc-1",
Expand Down Expand Up @@ -350,6 +351,7 @@ const baseStackJSON = `
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-dummy",
"serviceRef":{
"name":"svc-2",
"port":"http"
Expand Down Expand Up @@ -390,6 +392,7 @@ const baseStackJSON = `
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/ns-1/ing-1-svc-3:https/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-dummy",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"svc-3",
Expand Down Expand Up @@ -1131,7 +1134,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
"port": 443,
"protocol": "HTTPS",
"sslPolicy": "ELBSecurityPolicy-2016-08",
"mutualAuthentication" : {
"mutualAuthentication" : {
"mode" : "off"
}
}
Expand Down Expand Up @@ -1442,6 +1445,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
},
"spec": {
"ipAddressType": "ipv4",
"vpcId": "vpc-dummy",
"networking": {
"ingress": [
{
Expand Down Expand Up @@ -2429,6 +2433,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
},
"spec": {
"ipAddressType": "ipv6",
"vpcId": "vpc-dummy",
"networking": {
"ingress": [
{
Expand Down Expand Up @@ -2695,6 +2700,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
},
"spec": {
"ipAddressType": "ipv4",
"vpcId": "vpc-dummy",
"networking": {
"ingress": [
{
Expand Down Expand Up @@ -2854,6 +2860,7 @@ func Test_defaultModelBuilder_Build(t *testing.T) {
},
"spec": {
"ipAddressType": "ipv4",
"vpcId": "vpc-dummy",
"networking": {
"ingress": [
{
Expand Down
4 changes: 4 additions & 0 deletions pkg/model/elbv2/target_group_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ type TargetGroupBindingSpec struct {
// ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
// +optional
IPAddressType *elbv2api.TargetGroupIPAddressType `json:"ipAddressType,omitempty"`

// VpcId is the VPC of the TargetGroup. If unspecified, it will be automatically inferred.
// +optional
VpcId string `json:"vpcId,omitempty"`
}

// Template for TargetGroupBinding Custom Resource.
Expand Down
1 change: 1 addition & 0 deletions pkg/service/model_build_target_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingSpec(ctx context.Context,
Networking: tgbNetworking,
NodeSelector: nodeSelector,
IPAddressType: (*elbv2api.TargetGroupIPAddressType)(targetGroup.Spec.IPAddressType),
VpcId: t.vpcID,
},
},
}, nil
Expand Down
39 changes: 38 additions & 1 deletion pkg/service/model_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc-tls",
"port":80
Expand Down Expand Up @@ -380,6 +381,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc-tls",
"port":80
Expand Down Expand Up @@ -598,6 +600,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc",
"port":80
Expand Down Expand Up @@ -664,6 +667,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc",
"port":83
Expand Down Expand Up @@ -942,6 +946,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc-tls",
Expand Down Expand Up @@ -994,6 +999,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc-tls",
"port":83
Expand Down Expand Up @@ -1276,6 +1282,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"instance-mode",
"port":80
Expand Down Expand Up @@ -1317,6 +1324,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"instance-mode",
"port":83
Expand Down Expand Up @@ -1554,6 +1562,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/app/traffic-local:80/status/targetGroupARN"
},
"targetType":"instance",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"traffic-local",
Expand Down Expand Up @@ -1626,6 +1635,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"traffic-local",
"port":83
Expand Down Expand Up @@ -1815,6 +1825,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc-tls",
"port":80
Expand Down Expand Up @@ -1935,6 +1946,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"spec": {
"targetType": "ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"targetGroupARN": {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/ip-target:80/status/targetGroupARN"
},
Expand Down Expand Up @@ -2108,6 +2120,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"spec": {
"targetType": "ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"targetGroupARN": {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/default-ip-target:80/status/targetGroupARN"
},
Expand Down Expand Up @@ -2473,6 +2486,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "traffic-local",
"port": 80
Expand Down Expand Up @@ -2622,6 +2636,8 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "traffic-local",
"port": 80
Expand Down Expand Up @@ -2824,6 +2840,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/awesome/lb-with-class:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "lb-with-class",
"port": 80
Expand Down Expand Up @@ -2992,6 +3009,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"manual-sg-rule",
"port":80
Expand Down Expand Up @@ -3145,6 +3163,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc-tls",
"port":80
Expand Down Expand Up @@ -3326,6 +3345,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc-tls",
Expand Down Expand Up @@ -3580,6 +3600,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"nlb-ip-svc",
"port":80
Expand Down Expand Up @@ -3624,6 +3645,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc:83/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc",
Expand Down Expand Up @@ -3917,6 +3939,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc-tls",
Expand Down Expand Up @@ -3958,6 +3981,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:83/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc-tls",
Expand Down Expand Up @@ -4220,6 +4244,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"instance-mode",
"port":80
Expand Down Expand Up @@ -4262,6 +4287,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"instance-mode",
"port":83
Expand Down Expand Up @@ -4557,6 +4583,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/app/traffic-local:80/status/targetGroupARN"
},
"targetType":"instance",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"traffic-local",
Expand Down Expand Up @@ -4605,6 +4632,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"traffic-local",
"port":83
Expand Down Expand Up @@ -4906,6 +4934,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"traffic-local",
"port":80
Expand Down Expand Up @@ -4953,6 +4982,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
},
"targetType":"instance",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"serviceRef":{
"name":"traffic-local",
"port":83
Expand Down Expand Up @@ -5135,6 +5165,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref":"#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/nlb-ip-svc-tls:80/status/targetGroupARN"
},
"targetType":"ip",
"vpcId": "vpc-xxx",
"ipAddressType":"ipv4",
"serviceRef":{
"name":"nlb-ip-svc-tls",
Expand Down Expand Up @@ -5275,6 +5306,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"spec": {
"targetType": "ip",
"ipAddressType":"ipv4",
"vpcId": "vpc-xxx",
"targetGroupARN": {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/ip-target:80/status/targetGroupARN"
},
Expand Down Expand Up @@ -5526,6 +5558,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "traffic-local",
"port": 80
Expand Down Expand Up @@ -5709,6 +5742,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/traffic-local:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "traffic-local",
"port": 80
Expand Down Expand Up @@ -5891,6 +5925,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/awesome/lb-with-class:80/status/targetGroupARN"
},
"targetType": "instance",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "lb-with-class",
"port": 80
Expand Down Expand Up @@ -6085,6 +6120,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/manual-security-groups:80/status/targetGroupARN"
},
"targetType": "ip",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "manual-security-groups",
"port": 80
Expand Down Expand Up @@ -6224,6 +6260,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
"$ref": "#/resources/AWS::ElasticLoadBalancingV2::TargetGroup/default/manual-security-groups:80/status/targetGroupARN"
},
"targetType": "ip",
"vpcId": "vpc-xxx",
"serviceRef": {
"name": "manual-security-groups",
"port": 80
Expand Down Expand Up @@ -6252,7 +6289,7 @@ func Test_defaultModelBuilderTask_Build(t *testing.T) {
}
}
}
}
}
}
}
`,
Expand Down

0 comments on commit 85c80f2

Please sign in to comment.