Skip to content

Commit 5348c6e

Browse files
bugfix, multiple parentref for http/https (#163)
1 parent e48446d commit 5348c6e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

pkg/gateway/model_build_listener.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ func (t *latticeServiceModelBuildTask) extractListnerInfo(ctx context.Context, p
8686
}
8787

8888
func (t *latticeServiceModelBuildTask) buildListener(ctx context.Context) error {
89-
// when a service is associate to multiple service network(s), all listener config MUST be same
90-
// so here we are only using the 1st parentRe
9189

92-
if len(t.httpRoute.Spec.ParentRefs) > 0 {
93-
parentRef := t.httpRoute.Spec.ParentRefs[0]
90+
for _, parentRef := range t.httpRoute.Spec.ParentRefs {
91+
if parentRef.Name != t.httpRoute.Spec.ParentRefs[0].Name {
92+
// when a service is associate to multiple service network(s), all listener config MUST be same
93+
// so here we are only using the 1st gateway
94+
glog.V(2).Infof("Ignore parentref of different gateway %v", parentRef.Name)
95+
96+
continue
97+
}
9498

9599
port, protocol, certARN, err := t.extractListnerInfo(ctx, parentRef)
96100

pkg/gateway/model_build_rule.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,16 @@ const (
3030
)
3131

3232
func (t *latticeServiceModelBuildTask) buildRules(ctx context.Context) error {
33-
// when a service is associate to multiple service network(s), all listener config MUST be same
34-
// so here we are only using the 1st parentRef
33+
3534
var ruleID = 1
36-
if len(t.httpRoute.Spec.ParentRefs) > 0 {
37-
parentRef := t.httpRoute.Spec.ParentRefs[0]
35+
for _, parentRef := range t.httpRoute.Spec.ParentRefs {
36+
if parentRef.Name != t.httpRoute.Spec.ParentRefs[0].Name {
37+
// when a service is associate to multiple service network(s), all listener config MUST be same
38+
// so here we are only using the 1st gateway
39+
glog.V(2).Infof("Ignore parentref of different gateway %v", parentRef.Name)
40+
41+
continue
42+
}
3843
port, protocol, _, err := t.extractListnerInfo(ctx, parentRef)
3944

4045
if err != nil {

0 commit comments

Comments
 (0)