Skip to content

Commit e457112

Browse files
authored
Merge pull request #4261 from wweiwei-li/fix-sg
fix frontend NLB security group
2 parents e8cd29a + 6eddb4c commit e457112

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

pkg/ingress/model_build_frontend_nlb.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,9 @@ func (t *defaultModelBuildTask) buildFrontendNlbSecurityGroups(ctx context.Conte
242242
}
243243
for _, sgID := range frontendSGIDs {
244244
lbSGTokens = append(lbSGTokens, core.LiteralStringToken(sgID))
245-
return lbSGTokens, nil
246245
}
247246
}
248-
return nil, nil
247+
return lbSGTokens, nil
249248
}
250249

251250
func (t *defaultModelBuildTask) buildNLBFrontendSGNameOrIDsFromAnnotation(ctx context.Context) ([]string, error) {

pkg/ingress/model_build_frontend_nlb_test.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,44 @@ func Test_defaultModelBuildTask_buildFrontendNlbSecurityGroups(t *testing.T) {
9999
},
100100
wantSGTokens: []core.StringToken{core.LiteralStringToken("sg-manual")},
101101
},
102+
{
103+
name: "with two sgs",
104+
fields: fields{
105+
ingGroup: Group{
106+
ID: GroupID{
107+
Namespace: "awesome-ns",
108+
Name: "my-ingress",
109+
},
110+
Members: []ClassifiedIngress{
111+
{
112+
Ing: &networking.Ingress{
113+
ObjectMeta: metav1.ObjectMeta{
114+
Namespace: "awesome-ns",
115+
Name: "ing-1",
116+
Annotations: map[string]string{
117+
"alb.ingress.kubernetes.io/frontend-nlb-security-groups": "sg-manual1, sg-manual2",
118+
},
119+
},
120+
},
121+
},
122+
},
123+
},
124+
scheme: elbv2.LoadBalancerSchemeInternal,
125+
describeSecurityGroupsResult: []describeSecurityGroupsResult{
126+
{
127+
securityGroups: []ec2types.SecurityGroup{
128+
{
129+
GroupId: awssdk.String("sg-manual1"),
130+
},
131+
{
132+
GroupId: awssdk.String("sg-manual2"),
133+
},
134+
},
135+
},
136+
},
137+
},
138+
wantSGTokens: []core.StringToken{core.LiteralStringToken("sg-manual1"), core.LiteralStringToken("sg-manual2")},
139+
},
102140
}
103141

104142
for _, tt := range tests {

0 commit comments

Comments
 (0)