-
Notifications
You must be signed in to change notification settings - Fork 22
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
chore(tenants): tenant cleanup #775
chore(tenants): tenant cleanup #775
Conversation
Pull Request Test Coverage Report for Build 83a215a0aeb5ccb5c8de527747f9eeb256e6f32a-PR-775Details
💛 - Coveralls |
OTAOperation | ||
|> Ash.Query.filter(tenant_id == ^tenant.tenant_id) | ||
|> Ash.Query.filter(manual?) | ||
|> Ash.read!(tenant: tenant) |
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.
Keep in mind that inside the Ash.Changeset.after_action
logic the multitenant resources are already deleted, thanks to the cascade deletes and the tenant being deleted.
We could either:
- verify that Ash automagically calls the destroy actions on resources instead of relying on the cascade deletes, and we add Changes to the destroy actions that try to cleanup the resources from external systems.
- read the resources before the
after_action
callback, and then call directly the modules (e.g.@ephemeral_image_module.delete
) to cleanup the external systems.
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.
For the first point, because of the way we set up the deletion (using ash_postgres
references) ash
does not automatically call the destroy actions of associated resources (see ash_postgres
documentation). I think the second route is our best option, as it allows to handle the deletion directly in the resources (with a before_action
) that triggers the external sotrages behavior only after the transaction if successful.
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 updated the commit with this approach, the resources get deleted even on external storage (see tenants_test)
0f0e644
to
08747b1
Compare
Closes edgehog-device-manager#504. Manages resource cleanup on tenant deletion, deleting base images, ephemeral images and system models images on remote storage. Signed-off-by: Luca Zaninotto <[email protected]>
08747b1
to
83a215a
Compare
Closes #504.
Manages resource cleanup on tenant deletion, deleting base images, ephemeral images and system models images on remote storage.