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

Clean up Istio Servers of a ClusterIngress when deleting the ClusterIngress #3479

Merged

Conversation

ZhiminXiang
Copy link

Fixes #

Proposed Changes

  • Introduce Finalizer into ClusterIngress
  • Clean up Istio Servers of a ClusterIngress when deleting the ClusterIngress

@knative-prow-robot knative-prow-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. area/API API objects and controllers area/networking size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 21, 2019
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

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

@ZhiminXiang: 0 warnings.

In response to this:

Fixes #

Proposed Changes

  • Introduce Finalizer into ClusterIngress
  • Clean up Istio Servers of a ClusterIngress when deleting the ClusterIngress

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.

@ZhiminXiang ZhiminXiang changed the title [WIP] Clean up Istio Servers of a ClusterIngress when deleting the ClusterIngress Clean up Istio Servers of a ClusterIngress when deleting the ClusterIngress Mar 21, 2019
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 21, 2019
// finalizers:
// - clusteringresses.networking.internal.knative.dev
var (
//
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
//

Copy link
Author

Choose a reason for hiding this comment

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

Done

@mattmoor
Copy link
Member

This LGTM, but I'm concerned that the Gateway will become a bottleneck / SPOF with this API.

IIUC every ClusterIngress is going to be adding Server entries to a single resource. This is going to fail at some scale, we should press Istio for a better API (maybe I'm wrong?).

@mattmoor
Copy link
Member

Note: I'm obviously not suggestion you fix istio in this PR, leaving open for the other comment 😅

@ZhiminXiang
Copy link
Author

ZhiminXiang commented Mar 21, 2019

This LGTM, but I'm concerned that the Gateway will become a bottleneck / SPOF with this API.

IIUC every ClusterIngress is going to be adding Server entries to a single resource. This is going to fail at some scale, we should press Istio for a better API (maybe I'm wrong?).

Yes, the Gateway is the single resource here. I will follow up with Istio team about this API.


mergePatch := map[string]interface{}{
"metadata": map[string]interface{}{
"finalizers": finalizers.List(),
Copy link
Contributor

Choose a reason for hiding this comment

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

does the order of the finalizers matter?

Copy link
Author

Choose a reason for hiding this comment

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

No, the order does not matter.
An object is deleted when all of the finalizers are removed. The deletion order of finalizers does not matter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then if it doesn't matter why do we check that our finalizer is the "first one" below?

}

gatewayNames := gatewayNamesFromContext(ctx, ci)
logger.Info("Cleaning up Gateway Servers")
Copy link
Contributor

Choose a reason for hiding this comment

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

log the key?

Copy link
Author

Choose a reason for hiding this comment

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

Done

@@ -410,6 +438,14 @@ func gateway(name, namespace string, servers []v1alpha3.Server) *v1alpha3.Gatewa
}
}

func patchAddFinalizerAction(ingressName, finalizer string) clientgotesting.PatchActionImpl {
action := clientgotesting.PatchActionImpl{}
Copy link
Contributor

Choose a reason for hiding this comment

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

initialize during creation.

Copy link
Author

Choose a reason for hiding this comment

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

Done

@vagababov
Copy link
Contributor

/lgtm
I'll let Matt approve is his concern is alleviated.
/assign @mattmoor

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 24, 2019
// If our Finalizer is first, delete the `Servers` from Gateway for this ClusterIngress,
// and remove the finalizer.
if len(ci.Finalizers) == 0 || ci.Finalizers[0] != clusterIngressFinalizer {
if !finalizers.Has(clusterIngressFinalizer) {
Copy link
Member

Choose a reason for hiding this comment

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

This is now incorrect. We should ONLY process our finalizer when we are "next" (first).

Copy link
Contributor

Choose a reason for hiding this comment

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

So if the order matters, we can't do Sets(x).List() above either.

Copy link
Author

Choose a reason for hiding this comment

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

I see. Thanks!
Now I use append instead of doing Sets(x).List() in order to keep the order of finalizers.

We also need to do the similar thing for the finalizers of Route.

@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2019
@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-serving-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/reconciler/v1alpha1/clusteringress/clusteringress.go 78.6% 80.8% 2.2
pkg/reconciler/v1alpha1/clusteringress/resources/gateway.go Do not exist 96.9%

Copy link
Contributor

@vagababov vagababov left a comment

Choose a reason for hiding this comment

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

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 25, 2019
@ZhiminXiang
Copy link
Author

/test pull-knative-serving-upgrade-tests

@mattmoor
Copy link
Member

/lgtm
/approve

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor, ZhiminXiang

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 26, 2019
@knative-prow-robot knative-prow-robot merged commit b00c960 into knative:master Mar 26, 2019
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. area/API API objects and controllers area/networking lgtm Indicates that a PR is ready to be merged. 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.

5 participants