-
Notifications
You must be signed in to change notification settings - Fork 303
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
Cleanup backend namer workflow #861
Conversation
Hi @skmatti. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign freehan |
/ok-to-test |
592da1d
to
90ad989
Compare
pkg/utils/namer/fenamer.go
Outdated
type LegacyIngressFrontendNamer struct { | ||
ing *v1beta1.Ingress | ||
namer LegacyFrontendNamer | ||
lbName string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since lbName is highly coupled with namer.Namer, I would recommend the following 2 options:
- make lbName a specific type. (Can add a TODO and do it separately)
- calculate lbName on the fly.
pkg/utils/namer/fenamer.go
Outdated
// LegacyIngressFrontendNamer implements IngressFrontendNamer. This is a wrapper on top of namer.Namer. | ||
type LegacyIngressFrontendNamer struct { | ||
ing *v1beta1.Ingress | ||
namer LegacyFrontendNamer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything in this package, you do not need to call Namer via interface.
I would recommend anything outside of this package to use an interface to interact with Namer.
pkg/utils/namer/interfaces.go
Outdated
} | ||
|
||
// LegacyFrontendNamer wraps frontend naming policy of namer.Namer. | ||
type LegacyFrontendNamer interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend not to duplicate the methods (e.g. ForwardingRule):
Only open the interface for the following methods. And use it in the L7s.
type LegacyFrontendNamerHelper interface {
// LoadBalancer constructs a loadbalancer name from the given ingress key.
LoadBalancer(ingKey string) string
// LoadBalancerFromLbName reconstructs the full loadbalancer name, given the
// lbName portion from NameComponents.
LoadBalancerFromLbName(lbName string) string
// ParseName parses the resource name of a resource generated by the namer.
ParseName(resourceName string) *NameComponents
// NameBelongsToCluster checks if a given resourceName is tagged with this
// cluster's UID.
NameBelongsToCluster(resourceName string) bool
// ForwardingRule returns the name of the gce forwarding rule for given lbName and protocol.
}
pkg/controller/controller.go
Outdated
@@ -417,7 +417,7 @@ func (lbc *LoadBalancerController) SyncLoadBalancer(state interface{}) error { | |||
|
|||
// GCLoadBalancers implements Controller. | |||
func (lbc *LoadBalancerController) GCLoadBalancers(toKeep []*v1beta1.Ingress) error { | |||
return lbc.l7Pool.GC(toLbNames(toKeep)) | |||
return lbc.l7Pool.GC(utils.ToIngressKeys(toKeep)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GC takes names specifically. This is another reason to use strong type for lbName.
ToIngressKeys
seems to lack of the Ingress-gce filtering capability of toLbNames
pkg/loadbalancers/l7.go
Outdated
@@ -50,7 +50,6 @@ const ( | |||
|
|||
// L7RuntimeInfo is info passed to this module from the controller runtime. | |||
type L7RuntimeInfo struct { | |||
// Name is the name of a loadbalancer. | |||
Name string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you forgot to remove Name?
pkg/loadbalancers/l7s.go
Outdated
type L7s struct { | ||
cloud *gce.Cloud | ||
namer *namer.Namer | ||
namer namer_util.LegacyFrontendNamer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the LegacyFrontendNamerHelper
pkg/loadbalancers/l7s.go
Outdated
"k8s.io/klog" | ||
"k8s.io/legacy-cloud-providers/gce" | ||
) | ||
|
||
// L7s implements LoadBalancerPool. | ||
// TODO(smatti): replace *namer_util.Namer with an interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove?
pkg/loadbalancers/l7s.go
Outdated
} | ||
|
||
// Namer returns the namer associated with the L7s. | ||
func (l *L7s) Namer() *namer.Namer { | ||
func (l *L7s) Namer() namer_util.LegacyFrontendNamer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think this function is used anywhere
pkg/utils/namer/fenamer_test.go
Outdated
// TestLegacyIngressFrontendNamer tests that the migrated legacy namer returns | ||
// expected values for various frontend resource names. This also tests that the | ||
// migrated legacy namer returns same values as old namer for frontend resource names. | ||
func TestLegacyIngressFrontendNamer(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend adding a few more cases:
- many chars above the truncation threshold
- 1 char above the truncation threshold
- 1 char below the truncation threshold
- chars just fits the 63 char limit
90ad989
to
f5f7735
Compare
ecc7d82
to
d57f5d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Just one nit.
/assign bowei@ for another pair of eyes.
} | ||
} | ||
|
||
// Link implements Link. | ||
func (l *instanceGroupLinker) Link(sp utils.ServicePort, groups []GroupKey) error { | ||
var igLinks []string | ||
for _, group := range groups { | ||
ig, err := l.instancePool.Get(l.namer.InstanceGroup(), group.Zone) | ||
ig, err := l.instancePool.Get(sp.IGName(), group.Zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about dropping the IGName function and just use BackendName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry. please skip it.
d57f5d8
to
f0fc341
Compare
/assign @bowei |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/assign bowei@ for approval
} | ||
} | ||
|
||
// Link implements Link. | ||
func (l *instanceGroupLinker) Link(sp utils.ServicePort, groups []GroupKey) error { | ||
var igLinks []string | ||
for _, group := range groups { | ||
ig, err := l.instancePool.Get(l.namer.InstanceGroup(), group.Zone) | ||
ig, err := l.instancePool.Get(sp.IGName(), group.Zone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry. please skip it.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: freehan, skmatti The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This is part 2 of V2 Namer Migration:#858 .
This does not change naming policy for backend resources. A light weight back-end namer interface is stubbed into each service port to retrieve back-end resource names. The current workflow passes in namer object to retrieve backend resources. This is not required anymore with new workflow.