Skip to content

HMS-10467: Making deletions tasks more resilient#1509

Open
Starle21 wants to merge 1 commit into
content-services:mainfrom
Starle21:resilient-deletion
Open

HMS-10467: Making deletions tasks more resilient#1509
Starle21 wants to merge 1 commit into
content-services:mainfrom
Starle21:resilient-deletion

Conversation

@Starle21
Copy link
Copy Markdown
Contributor

@Starle21 Starle21 commented Jun 1, 2026

Summary

Previously, if any of the 3 deletion tasks:
delete_snapshots
delete_templates
delete_repository_snapshots
failed to delete a resource, it was not exactly clear where and why it happened.

To make it more resilient, this was changed:

  • detailed failure messages were added to identify easily which op caused a failure
  • logging warnings if a resource was not found or nil
  • loops now return errors at the end, so all the resources in a loop get a chance to be deleted

Testing steps

Test manually by creating templates, repositories with snapshots and without snapshots and then deleting them.
Everything works as before, but you get much better idea what is happening.
Automated tests pass.

@xbhouse
Copy link
Copy Markdown
Contributor

xbhouse commented Jun 1, 2026

@Starle21 Starle21 force-pushed the resilient-deletion branch 3 times, most recently from ea4311f to f9ed2f8 Compare June 3, 2026 16:12
@Starle21 Starle21 marked this pull request as ready for review June 3, 2026 16:13
@Starle21 Starle21 requested a review from a team as a code owner June 3, 2026 16:13
@rverdile rverdile self-assigned this Jun 3, 2026
Comment on lines +124 to +140
var snapErrs []error
for _, snap := range snaps {
_, err = d.deleteRpmDistribution(snap.DistributionHref)
if err != nil {
return err
snapErrs = append(snapErrs, err)
continue
}
err = d.deleteTemplateSnapshot(snap.UUID)
if err != nil {
return err
if err = d.deleteTemplateSnapshot(snap.UUID); err != nil {
snapErrs = append(snapErrs, err)
}
err = d.deleteSnapshot(snap.UUID)
if err != nil {
return err
if err = d.deleteSnapshot(snap.UUID); err != nil {
snapErrs = append(snapErrs, err)
}
}
if err = errors.Join(snapErrs...); err != nil {
return err
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If deleteTemplateSnapshot errors, let's also continue. I think if you try to delete the snapshot before deleting the template snapshot, I think that would cause an error or at least leave things in an odd state.

Previously, if any of the 3 deletion tasks (delete-repository-snapshost, delete-snapshots, delete-templates)
failed to delete a resource, it was not exactly clear where and why it happened.
To make it more resilient, this was changed:
- detailed failure messages were added to identify easily which op caused the failure
- logging warnings if a resource was not found or nil
- loops now return errors at the end, so all the resources in a loop get a chance to be deleted
@Starle21 Starle21 force-pushed the resilient-deletion branch from f9ed2f8 to 4e19406 Compare June 5, 2026 14:59
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.

3 participants