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

Switch to using Finalizers for ClusterIngress deletion. #3035

Merged
merged 1 commit into from
Jan 30, 2019

Conversation

mattmoor
Copy link
Member

This removes the OwnerReferences from ClusterIngress, which are buggy and unsupported anyways.

Instead, we will add a finalizer prior to creating ClusterIngress, which will enable us to hook into Route deletion to clean up the ClusterIngress resources manually.

When we see a Route with a DeletionTimestamp, we elide most processing. When we are the first finalizer on the list, it is our turn and we delete the cluster ingresses matching our label selector and remove the finalizer to allow deletion to proceed.

Fixes: #2570

@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mattmoor

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 Jan 30, 2019
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 30, 2019
@mattmoor
Copy link
Member Author

/retest

if err := c.ensureFinalizer(r); err != nil {
return err
}

logger.Info("Creating ClusterIngress.")
clusterIngress, err := c.reconcileClusterIngress(ctx, r, resources.MakeClusterIngress(r, traffic))
Copy link
Member

Choose a reason for hiding this comment

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

we should drop owner references for existing cluster ingresses

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think that they are particularly harmful as-is. Do you have some reason to think they are?

I actually (after a whole bunch of debugging!) just found a fun and subtle bug (which is why all these e2e tests are exploding), which ironically is caused by my dropping OwnerReferences (our filter on the Owner's Kind).

cc @tcnghia I think this is the reason for the bizarrely long resync earlier, we filtered out all of the ClusterIngress events! Oops. I'll push a fix for this shortly.

Copy link
Member

Choose a reason for hiding this comment

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

Do you have some reason to think they are?

Currently OwnerReferences being used to across scopes (namespace,cluster) was undefined causing the K8s GC unable to delete the ClusterIngress. Breaking foreground cascade deletion and causing deleted objects to be reconciled continuously.

If the undefined behaviour were to change would it have a material impact on us? Looking at the PR further I don't think so (at this time).

pkg/reconciler/testing/table.go Show resolved Hide resolved
pkg/reconciler/testing/table.go Outdated Show resolved Hide resolved
pkg/reconciler/testing/table.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/route/reconcile_resources.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/route/route.go Show resolved Hide resolved
@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/route/reconcile_resources.go 89.2% 89.5% 0.3
pkg/reconciler/v1alpha1/route/route.go 93.3% 92.1% -1.2

@mattmoor
Copy link
Member Author

/test pull-knative-serving-unit-tests

@mattmoor
Copy link
Member Author

/retest

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
/hold

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jan 30, 2019
@mattmoor
Copy link
Member Author

@tcnghia PTAL in the morning and /hold cancel please :D

pkg/reconciler/v1alpha1/route/route.go Show resolved Hide resolved
pkg/reconciler/v1alpha1/route/route.go Show resolved Hide resolved
pkg/reconciler/v1alpha1/route/route.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/route/reconcile_resources.go Outdated Show resolved Hide resolved
This removes the OwnerReferences from ClusterIngress, which are buggy and unsupported anyways.

Instead, we will add a finalizer prior to creating ClusterIngress, which will enable us to hook into Route deletion to clean up the ClusterIngress resources manually.

When we see a Route with a DeletionTimestamp, we elide most processing.  When we are the first finalizer on the list, it is our turn and we delete the cluster ingresses matching our label selector and remove the finalizer to allow deletion to proceed.

Fixes: knative#2570
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2019
@mattmoor
Copy link
Member Author

/hold cancel

Since the LGTM is removed.

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 30, 2019
@tcnghia
Copy link
Contributor

tcnghia commented Jan 30, 2019

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2019
@knative-prow-robot knative-prow-robot merged commit 5b24091 into knative:master Jan 30, 2019
@mattmoor mattmoor deleted the route-finalizer branch January 30, 2019 19:56
@dprotaso
Copy link
Member

I realize we can’t drop owner references in 0.4 since that breaks things when downgrading to 0.3. A ClusterIngress created with 0.4 without an owner will leak during a deletion when running an 0.3 controller.

Unless we cherry pick parts of this change to a 0.3 point release and require that version prior to upgrading?

ZhiminXiang pushed a commit to ZhiminXiang/serving-1 that referenced this pull request Feb 7, 2019
This removes the OwnerReferences from ClusterIngress, which are buggy and unsupported anyways.

Instead, we will add a finalizer prior to creating ClusterIngress, which will enable us to hook into Route deletion to clean up the ClusterIngress resources manually.

When we see a Route with a DeletionTimestamp, we elide most processing.  When we are the first finalizer on the list, it is our turn and we delete the cluster ingresses matching our label selector and remove the finalizer to allow deletion to proceed.

Fixes: knative#2570
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. 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.

7 participants