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

Cannot remove anything which was used in a deleted task template #725

Closed
MrChausson opened this issue Sep 7, 2021 · 4 comments
Closed
Labels
Milestone

Comments

@MrChausson
Copy link

MrChausson commented Sep 7, 2021

In version v2.7.14 using official mysql docker image

When I want to remove an inventory, I get this message:
image

But I was able to figure out what that errors means. In the database, we cannot remove any row that is linked in another row.
The problem is actually that no template is removed from the database. As you can see here:

My template page:

image

My project__template table

image

So we cannot remove any row which was previously linked to those templates...

Steps to reproduice:

  • Create a template
  • Remove the template
  • (try to) Remove the inventory which was used by the template
@fiftin fiftin added the bug label Sep 7, 2021
@fiftin
Copy link
Collaborator

fiftin commented Sep 9, 2021

Agree, it is a bug. Task template can't be deleted from database because it is linked with task logs. I sure we should preserve task logs for audit purpose.

But I not sure the best solution. We can set null inventory_id, repository_id, etc of deleted templates.

Or we can use removed flag for environment and inventories.

Or we can set null template_id for tasks.

@MrChausson
Copy link
Author

I feel like it's best to not keep too much unused things in the database, as it can end up taking a lot of storage. I'd not keep those logs for audit purposes, as I don't really see why someone would need it after having deleted the template.

But if we absolutely must keep those logs, I'd suggest doing this:
Moving those logs in another table let's say backup__logs and then remove the task template, so we won't have anything linked anymore.

@fiftin
Copy link
Collaborator

fiftin commented Sep 10, 2021

It is very interesting how this implemented in AWX.

@fiftin fiftin added this to the 2.8 milestone Oct 12, 2021
@fiftin
Copy link
Collaborator

fiftin commented Jan 31, 2022

Fixed, please try release https://github.com/ansible-semaphore/semaphore/releases/tag/v2.8.39

@fiftin fiftin closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants