HMS-5062: fix del-templ task fail if repo is deleted first #927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a bug that happens when a repository exists within a template, and both are deleted, but the repository config is deleted before the template is deleted, then the
delete-templates
task gives a "repository not found" error and if this happens the template-repository distribution doesn't get deleted and remains an orphan.The ticket assumed that the
delete-repository-snapshots
task didn't try deleting the template-repository distribution, but it actually already was trying to do so, but that step just needed to be moved earlier in the task and also do that for soft deleted templates. Thedelete-template
task just needed to be changed to ignore not found repository configs.Testing steps
SELECT * FROM templates_repository_configurations;
) and verify it exists (http -a admin:password :8080/${DISTRIBUTION_HREF}
).retry_wait_upper_bound
inconfig.yaml
to 3m.Run()
method ofdelete_templates.go
to force a failure by returning an error (addreturn errors.new("test error")
at the beginning).delete-repository-snapshot
task finishes, stop the server.Run()
from step 3, so it runs correctly, then restart the server.delete-templates
tasks will retry and it should be completed successfully.http -a admin:password :8080/${DISTRIBUTION_HREF}
->404
).