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

add finalizer to ensure integration children are cleaned up #480

Merged
merged 3 commits into from
Feb 22, 2019

Conversation

lburgazzoli
Copy link
Contributor

Fixes #477

pkg/cmd/run.go Outdated
@@ -84,6 +86,7 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) *cobra.Command {
cmd.Flags().BoolVar(&options.Compression, "compression", false, "Enable store source as a compressed binary blob")
cmd.Flags().StringSliceVar(&options.Resources, "resource", nil, "Add a resource")
cmd.Flags().StringSliceVar(&options.OpenAPIs, "open-api", nil, "Add an OpenAPI v2 spec")
cmd.Flags().BoolVar(&options.Owner, "owner", true, "Use resource ownership to cleanup child resources, if set to false finalizers are used")
Copy link
Member

Choose a reason for hiding this comment

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

We may want to name the option to something more explicit like deletion-policy with possible values owner / ownerReference or label / labelSelector to fit into k8s garbage collection scheme.

//
// Remove the finalizer to unlock resource
//
_, err = finalizer.Remove(target, finalizer.CamelIntegrationFinalizer)
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether we should check the foregroundDeletion finalizer and emulate a background cascading deletion when no present by removing our finaliser first and then delete the child resources.

@lburgazzoli
Copy link
Contributor Author

will do

@lburgazzoli
Copy link
Contributor Author

@astefanutti done

return err
}

if ok {
Copy link
Member

Choose a reason for hiding this comment

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

I think the logic should be reverse. In background cascading deletion, Kubernetes deletes the owner object immediately and the garbage collector then deletes the dependents in the background.

resource := resource

// Pods are automatically deleted by the removal of Deployment
if resource.GetKind() == "Pod" {
Copy link
Member

Choose a reason for hiding this comment

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

I wonder whether we should deactivate cascading in the delete operation so that we fully rely on the label deletion policy and avoid mixing label and owner strategies and get rid of these special cases.


l.Infof("Deleting child resource: %s/%s", resource.GetKind(), resource.GetName())

err := action.client.Delete(ctx, &resource)
Copy link
Member

Choose a reason for hiding this comment

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

We could set the PropagationPolicy to orphan here.

@lburgazzoli
Copy link
Contributor Author

@astefanutti should be better now

@astefanutti
Copy link
Member

👍

@lburgazzoli lburgazzoli merged commit 9e8ee20 into apache:master Feb 22, 2019
@lburgazzoli lburgazzoli deleted the github-477-finalizers branch February 24, 2019 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants