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

HMS-5062: fix del-templ task fail if repo is deleted first #927

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dominikvagner
Copy link
Contributor

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. The delete-template task just needed to be changed to ignore not found repository configs.

Testing steps

  1. Create a custom repository and add it to a new template.
  2. Note down the template-repository distribution href (look it up by uuids in SELECT * FROM templates_repository_configurations;) and verify it exists (http -a admin:password :8080/${DISTRIBUTION_HREF}).
  3. Change retry_wait_upper_bound in config.yaml to 3m.
  4. Edit the Run() method of delete_templates.go to force a failure by returning an error (add return errors.new("test error") at the beginning).
  5. Delete the template.
  6. Delete the repository configuration.
  7. Once the delete-repository-snapshot task finishes, stop the server.
  8. Fix the Run() from step 3, so it runs correctly, then restart the server.
  9. The delete-templates tasks will retry and it should be completed successfully.
  10. Verify the template-repository distribution was deleted (http -a admin:password :8080/${DISTRIBUTION_HREF} -> 404).

@jlsherrill
Copy link
Member

@swadeley
Copy link
Member

swadeley commented Jan 8, 2025

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants