Skip to content

Changes to the error message displayed during the removal of public templates that are used#12373

Open
erikbocks wants to merge 1 commit intoapache:4.20from
scclouds:fix-error-message-during-public-template-removal
Open

Changes to the error message displayed during the removal of public templates that are used#12373
erikbocks wants to merge 1 commit intoapache:4.20from
scclouds:fix-error-message-during-public-template-removal

Conversation

@erikbocks
Copy link
Collaborator

Description

During the removal of public templates, if it is being used by VMs, an error message is displayed informing that the removal could not proceed because it is being used by VMs, and the list of VMs using it is returned. However, sometimes the user that is trying to remove the template does not have access to these resources. Thus, the error message was changed, in order to return the list of VMs only to users with RootAdmin accounts and for the others users, the message only states that the template is being used by VMs.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

Exception message for User type accounts image
Exception message for Root Admin type accounts image

How Has This Been Tested?

First, two User type accounts were created: templateAcc and instanceAcc. The templateAcc account was accessed and a public template was registered. After that, the instanceAcc was accessed and a VM was deployed using the template registered by templateAcc.

Logged in as templateAcc again, I tried to remove the registered template, and it was possible to validate that the error message was displayed without the VMs list. By logging in with a Root Admin account, it was possible to validate that the error message contained the VMs lists. Through the Management Server's logs it was also possible to validate that the log message displayed the VMs list:

Updated log message
2025-12-17 12:58:08,815 [management] WARN  [c.c.t.TemplateManagerImpl:1360] (API-Job-Executor-1:[ctx-106b8b79, job-448, ctx-e8ca5865]) (logid:c41a7e6a) Unable to delete template with ID 210, because there are VM instances using it. Instances list: [VM instance {"id":33,"instanceName":"i-13-33-VM","type":"User","uuid":"a15065e6-5422-4eca-ae8a-e4f0d8887a99"}].

@codecov
Copy link

codecov bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (ce42ce5) to head (f9e815e).
⚠️ Report is 1 commits behind head on 4.20.

Files with missing lines Patch % Lines
...n/java/com/cloud/template/TemplateManagerImpl.java 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.20   #12373   +/-   ##
=========================================
  Coverage     16.26%   16.26%           
- Complexity    13428    13431    +3     
=========================================
  Files          5660     5660           
  Lines        499959   499962    +3     
  Branches      60707    60708    +1     
=========================================
+ Hits          81326    81339   +13     
+ Misses       409560   409548   -12     
- Partials       9073     9075    +2     
Flag Coverage Δ
uitests 4.16% <ø> (ø)
unittests 17.12% <60.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@winterhazel
Copy link
Member

@erikbocks could you target 4.20 as this is a simple enhancement?

@erikbocks erikbocks changed the base branch from main to 4.20 February 3, 2026 11:44
@erik-bock-silva erik-bock-silva force-pushed the fix-error-message-during-public-template-removal branch from b50eca4 to 73a254a Compare February 3, 2026 11:55
@github-actions
Copy link

github-actions bot commented Feb 3, 2026

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@erik-bock-silva erik-bock-silva force-pushed the fix-error-message-during-public-template-removal branch from 73a254a to f9e815e Compare February 3, 2026 12:06
Copy link
Contributor

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@DaanHoogland DaanHoogland added this to the 4.20.3 milestone Feb 3, 2026
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.

4 participants