Skip to content

Fix/13612 template cleanup on domain delete#13614

Open
Chinmay048 wants to merge 2 commits into
apache:mainfrom
Chinmay048:fix/13612-template-cleanup-on-domain-delete
Open

Fix/13612 template cleanup on domain delete#13614
Chinmay048 wants to merge 2 commits into
apache:mainfrom
Chinmay048:fix/13612-template-cleanup-on-domain-delete

Conversation

@Chinmay048

Copy link
Copy Markdown

Description

This PR fixes an issue where templates belonging to child accounts within a domain were not properly tracked during automated account and domain cleanup, causing domain deletion to fail due to orphaned storage resources.

Functional Changes:

  • Updated AccountManagerImpl.cleanupAccount to explicitly check the boolean return value of _tmpltMgr.delete(...).
  • Prevented the allTemplatesDeleted tracking flag from being overwritten on subsequent loop iterations if an earlier template deletion fails.
  • Ensured that any failed template deletion correctly sets accountCleanupNeeded = true, preventing premature domain teardowns when child resources remain active in secondary storage.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • My changes generate no new warnings or checkstyle errors.

Copilot AI review requested due to automatic review settings July 14, 2026 13:14
@boring-cyborg

boring-cyborg Bot commented Jul 14, 2026

Copy link
Copy Markdown

Congratulations on your first Pull Request and welcome to the Apache CloudStack community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/cloudstack/blob/main/CONTRIBUTING.md)
Here are some useful points:

Copilot AI left a comment

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.

Pull request overview

This PR addresses a cleanup edge case during account/domain teardown where template deletions that return false could be effectively “masked” by later successful deletions, leading to premature domain deletion attempts while template artifacts still remained in secondary storage.

Changes:

  • Update template cleanup loop in AccountManagerImpl.cleanupAccount to treat any false return from _tmpltMgr.delete(...) as a persistent failure signal (without being overwritten by later iterations).
  • Improve logging for the false return case and ensure exceptions also force allTemplatesDeleted = false.
  • Ensure accountCleanupNeeded is set when any template deletion fails, preventing premature teardown.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants