Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ILB forwarding rule bug #906

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/loadbalancers/features/l7ilb.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ func isSameNetwork(l, r string) (bool, error) {
return lID.Equal(rID), nil
}

// IsCustomModeNetwork is a helper for determining if a network is a custom mode network
// (as opposed to a auto mode network). This is used for l7-ilb since custom mode networks
// require an additional field on the forwarding rule
func IsCustomModeNetwork(c *gce.Cloud, networkURL string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might want to cache this at some point to avoid doing too many GCE calls

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Originally this was thought to be the proxy subnet which would change, but now that it's the cluster subnet, we do only need to do it once.

netID, err := cloud.ParseResourceURL(networkURL)
if err != nil {
return false, err
}

network, err := c.Compute().Networks().Get(context.Background(), netID.Key)
if err != nil {
return false, err
}

return !network.AutoCreateSubnetworks, nil
}

// L7ILBVersion is a helper to get the version of L7-ILB
func L7ILBVersions() *ResourceVersions {
return versionsFromFeatures([]string{FeatureL7ILB})
Expand Down
12 changes: 11 additions & 1 deletion pkg/loadbalancers/forwarding_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package loadbalancers

import (
"fmt"
"k8s.io/ingress-gce/pkg/flags"
"k8s.io/ingress-gce/pkg/loadbalancers/features"

"k8s.io/ingress-gce/pkg/composite"
"k8s.io/ingress-gce/pkg/utils"
Expand Down Expand Up @@ -91,9 +93,17 @@ func (l *L7) checkForwardingRule(name, proxyLink, ip, portRange string) (fw *com
}

// Update rule for L7-ILB
if utils.IsGCEL7ILBIngress(l.runtimeInfo.Ingress) {
if flags.F.EnableL7Ilb && utils.IsGCEL7ILBIngress(l.runtimeInfo.Ingress) {
rule.LoadBalancingScheme = "INTERNAL_MANAGED"

// Custom mode networks require adding the cluster subnetwork
if isCustomMode, err := features.IsCustomModeNetwork(l.cloud, l.cloud.NetworkURL()); err != nil {
return nil, err
} else if isCustomMode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you are returning, you don't need the else

rule.Subnetwork = l.cloud.SubnetworkURL()
}
}

if err = composite.CreateForwardingRule(l.cloud, key, rule); err != nil {
return nil, err
}
Expand Down