HMS-10467: Making deletions tasks more resilient#1509
Open
Starle21 wants to merge 1 commit into
Open
Conversation
Contributor
ea4311f to
f9ed2f8
Compare
rverdile
reviewed
Jun 4, 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 | ||
| } |
Contributor
There was a problem hiding this comment.
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
f9ed2f8 to
4e19406
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Previously, if any of the 3 deletion tasks:
delete_snapshotsdelete_templatesdelete_repository_snapshotsfailed to delete a resource, it was not exactly clear where and why it happened.
To make it more resilient, this was changed:
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.