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

Bugfix: don't GC instance groups while multi-cluster ingresses exist #838

Merged
merged 1 commit into from
Sep 7, 2019

Conversation

skmatti
Copy link
Contributor

@skmatti skmatti commented Aug 29, 2019

Fixes #836

Existing GC workflow deletes instance groups as soon all GCE ingresses are deleted. But, instance groups should be retained as they are shared by multi-cluster ingresses as well.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 29, 2019
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 29, 2019
@skmatti
Copy link
Contributor Author

skmatti commented Aug 29, 2019

/assign mrhohn

@skmatti skmatti changed the title Improve GC to not cleanup instance groups while multi-clusters ingress exists Improve GC to not cleanup instance groups while multi-cluster ingresses exist Aug 29, 2019
@skmatti
Copy link
Contributor Author

skmatti commented Aug 29, 2019

/assign bowei

@MrHohn
Copy link
Member

MrHohn commented Aug 29, 2019

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 29, 2019
Copy link
Member

@MrHohn MrHohn left a comment

Choose a reason for hiding this comment

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

LGTM overall, some minor comments

pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/sync/sync.go Outdated Show resolved Hide resolved
pkg/common/operator/ingress.go Outdated Show resolved Hide resolved
pkg/sync/interfaces.go Outdated Show resolved Hide resolved
pkg/sync/interfaces.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
@MrHohn
Copy link
Member

MrHohn commented Aug 29, 2019

BTW should we fix the GC logic for L7ILB here as well? It may be as simple as tweaking these:

// IsGCEMultiClusterIngress returns true if the given Ingress has
// ingress.class annotation set to "gce-multi-cluster".
func IsGCEMultiClusterIngress(ing *v1beta1.Ingress) bool {
class := annotations.FromIngress(ing).IngressClass()
return class == annotations.GceMultiIngressClass
}
// IsGCEL7ILBIngress returns true if the given Ingress has
// ingress.class annotation set to "gce-l7-ilb"
func IsGCEL7ILBIngress(ing *v1beta1.Ingress) bool {
class := annotations.FromIngress(ing).IngressClass()
return class == annotations.GceL7ILBIngressClass
}
// IsGLBCIngress returns true if the given Ingress should be processed by GLBC
func IsGLBCIngress(ing *v1beta1.Ingress) bool {
return IsGCEIngress(ing) || IsGCEMultiClusterIngress(ing)
}

cc @spencerhance

@MrHohn
Copy link
Member

MrHohn commented Aug 29, 2019

BTW should we fix the GC logic for L7ILB here as well?

Discussed offline, seems like that works properly as is and doesn't need any fix :)

@MrHohn
Copy link
Member

MrHohn commented Aug 29, 2019

Will let @bowei also take a look.
/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 29, 2019
pkg/common/operator/ingress.go Outdated Show resolved Hide resolved
pkg/common/operator/ingress.go Outdated Show resolved Hide resolved
pkg/common/operator/ingress.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
@@ -631,35 +612,24 @@ func updateAnnotations(client kubernetes.Interface, name, namespace string, anno
func (lbc *LoadBalancerController) ToSvcPorts(ings []*v1beta1.Ingress) []utils.ServicePort {
var knownPorts []utils.ServicePort
for _, ing := range ings {
// Only resources associated with GCE Ingress are managed by this controller.
if !utils.IsGCEIngress(ing) {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to do the filter inside or outside this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We either needed to have toKeepGceIngresses and toKeepIngresses both or handle this filter in the downstream. I think second one is straightforward. I improved the doc of both helper methods to specify that it returns a list of svc ports owned by this controller.

// toLbNames translates a list of ingresses into their corresponding load balancer names.
func toLbNames(ings []*v1beta1.Ingress) []string {
lbNames := make([]string, 0, len(ings))
for _, ing := range ings {
// Only resources associated with GCE Ingress are managed by this controller.
if !utils.IsGCEIngress(ing) {
Copy link
Member

Choose a reason for hiding this comment

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

see comment above

// GCBackends garbage collects backends for all Ingresses given some existing state.
GCBackends(state interface{}) error
// GCBackends garbage collects backends for all ingresses given a list of ingresses to exclude from GC.
GCBackends(toKeep []*v1beta1.Ingress) error
Copy link
Member

Choose a reason for hiding this comment

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

you might want to sync up with rohit about why this was interface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed offline with Rohit and interface is not required anymore.

@skmatti
Copy link
Contributor Author

skmatti commented Sep 3, 2019

/assign @rramkumar1

@bowei bowei changed the title Improve GC to not cleanup instance groups while multi-cluster ingresses exist Bugfix: don't GC instance groups while multi-cluster ingresses exist Sep 4, 2019
@bowei
Copy link
Member

bowei commented Sep 7, 2019

/lgtm
/approve

It seems strange that toCleanup is not related at all with the GC action (e.g. it is only after GC deletes the resources for a given Ingress that the finalizer is removed). It seems worthwhile to have a follow on change that makes it more explicit connection, as this will lead to bugs.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 7, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bowei, MrHohn, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7719985 into kubernetes:master Sep 7, 2019
@skmatti skmatti deleted the improve-gc branch September 7, 2019 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix or verify the GC logic for multi-cluster ingress
5 participants