-
Notifications
You must be signed in to change notification settings - Fork 301
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 finalizer workflow and improve Ingress GC #825
Conversation
Welcome @skmatti! |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
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. I understand the commands that are listed here. |
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. |
/ok-to-test |
/assign @MrHohn |
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.
Thanks, just a few nits.
/hold If the Ingress has a finalizer, that means we have potentially allocated resources associated with the previous state of the Ingress. Which means we need to keep the finalizer... |
@bowei If you look at line 496 of controller.go, you can see that if the class was changed from glbc to non-glbc, then we add the Ingress for garbage collection to ensure we clean stuff up. This was to fix some bug not related to finalizer support. I think we should add all non-glbc Ingresses for garbage collection always (rather than just when the class is changed) as a sanity check that stuff is getting cleaned up. |
/hold cancel |
Discussed offline -- looks like the finalizer handling is currently incorrect and needs to be fixed. |
/hold |
/assign |
c88c5b7
to
45a423c
Compare
939f0c6
to
3f786ec
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.
discussed making the filtering and set of ingresses that the code is operating on more obvious
fce6b2f
to
348537c
Compare
/lgtm |
[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 |
/hold cancel |
klog.Errorf("Invalid object type: %T", obj) | ||
return | ||
} | ||
if delIng.ObjectMeta.DeletionTimestamp != nil { |
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.
Can we have some comments here to explain the reason behind? BTW have we verified that this for sure isn't the case when an Ingress is deleted without finalizer? (I'm still reading through https://github.com/kubernetes/apiserver/blob/master/pkg/registry/generic/registry/store.go...)
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.
Yeah, I tested this behavior. Deletion timestamp is being added only with finalizer enabled. I think I added a comment, but later changed to a log comment below this line.
} | ||
} | ||
// MaybeRemoveFinalizers cleans up Finalizers if needed. | ||
func (lbc *LoadBalancerController) MaybeRemoveFinalizers(state interface{}) error { |
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.
Why Maybe
?
lbNames []string | ||
svcPorts []utils.ServicePort | ||
// ingressesToCleanup is the list of ingressesToCleanup that needs to be cleaned up during GC. | ||
ingressesToCleanup []*v1beta1.Ingress |
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 vaguely remember we uses this as a signal for whether we can remove the instance group (if there is no ingresses exist). Has that logic been changed?
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.
Ahh, seems like we look at lbNames
instead.
ingress-gce/pkg/controller/controller.go
Lines 385 to 392 in fddd91d
// TODO(ingress#120): Move this to the backend pool so it mirrors creation | |
if len(gcState.lbNames) == 0 { | |
igName := lbc.ctx.ClusterNamer.InstanceGroup() | |
klog.Infof("Deleting instance group %v", igName) | |
if err := lbc.instancePool.DeleteInstanceGroup(igName); err != err { | |
return err | |
} | |
} |
So we need to keep multi-cluster ingress in this case then? :/
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.
We are using lbnames to see if we can delete instance groups.
func toLbNames(ings []*v1beta1.Ingress) []string { | ||
lbNames := make([]string, 0, len(ings)) | ||
for _, ing := range ings { | ||
lbNames = append(lbNames, utils.IngressKeyFunc(ing)) |
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.
IngressKeyFunc used here is incorrect. It should be replaced with KeyFunc defined here.
This fixes a bug on Ingress resource deletion when Ingress class changes from a GLBC resource to a non-GLBC one. Finalizer of a non-GLBC Ingress resource is removed when GC is invoked on it.