Skip to content

Guard OS type update for iso/template with existing vms #11215

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

Merged
merged 5 commits into from
Jul 22, 2025

Conversation

abh1sar
Copy link
Collaborator

@abh1sar abh1sar commented Jul 16, 2025

Description

This PR fixes #10588

The behaviour is as follows:
If no VMs are present which were deployed using the ISO/Template - OS type change is allowed

If VMs are present which were deployed using the ISO/Template - OS type change is disallowed but can still be done using the forceupdateostype parameter. In the UI, this field is displayed only if the OS type is changed.

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

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

Force option not visible by default
Screenshot 2025-07-16 at 1 07 24 PM

Only visible if the OS type is changed
Screenshot 2025-07-16 at 1 07 44 PM

The error:
Screenshot 2025-07-16 at 1 42 08 PM

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copy link

codecov bot commented Jul 16, 2025

Codecov Report

Attention: Patch coverage is 0% with 7 lines in your changes missing coverage. Please review.

Project coverage is 16.57%. Comparing base (6059724) to head (356c03c).
Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
...n/java/com/cloud/template/TemplateManagerImpl.java 0.00% 4 Missing ⚠️
...che/cloudstack/api/BaseUpdateTemplateOrIsoCmd.java 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11215      +/-   ##
============================================
- Coverage     16.58%   16.57%   -0.01%     
- Complexity    13991    14057      +66     
============================================
  Files          5745     5772      +27     
  Lines        510757   512956    +2199     
  Branches      62144    62308     +164     
============================================
+ Hits          84690    85023     +333     
- Misses       416598   418451    +1853     
- Partials       9469     9482      +13     
Flag Coverage Δ
uitests 3.89% <ø> (-0.02%) ⬇️
unittests 17.47% <0.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.

@abh1sar
Copy link
Collaborator Author

abh1sar commented Jul 16, 2025

@blueorangutan package

@blueorangutan
Copy link

@abh1sar a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14209

@@ -2238,6 +2238,12 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
sc.addAnd("state", SearchCriteria.Op.NEQ, State.Expunging);
List<VMInstanceVO> vms = _vmInstanceDao.search(sc, null);
if (vms != null && !vms.isEmpty()) {
if (!Boolean.TRUE.equals(cmd.getForceUpdateOsType())) {
Copy link
Member

Choose a reason for hiding this comment

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

for backwards compatibility, I suggest to force update vm os types by default.

on UI, we can uncheck the checkbox by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@weizhouapache I can make this change, but the issue will still be there for the api calls.
Do you foresee this impacting any workflows? My initial thought was it would be relatively uncommon for users to change the OS type of a template or ISO after deploying VMs from them, so the risk of breaking existing setups seems low. Happy to proceed as you recommend. let me know your thoughts.

Copy link
Member

Choose a reason for hiding this comment

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

@abh1sar
I am good with both.

@DaanHoogland @sureshanaparti
Your advise ?

Copy link
Contributor

Choose a reason for hiding this comment

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

@abh1sar I would say, keep existing functionality as default in the API as @weizhouapache says. We can change the default at any time if users massively protest.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@sureshanaparti
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@sureshanaparti a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 14282

@sureshanaparti
Copy link
Contributor

@blueorangutan test

@blueorangutan
Copy link

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-13835)
Environment: kvm-ol8 (x2), Advanced Networking with Mgmt server ol8
Total time taken: 56756 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11215-t13835-kvm-ol8.zip
Smoke tests completed. 142 look OK, 0 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File

@rosi-shapeblue rosi-shapeblue self-assigned this Jul 22, 2025
Copy link
Collaborator

@rosi-shapeblue rosi-shapeblue left a comment

Choose a reason for hiding this comment

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

LGTM.

Force update is disabled by default in the UI. Changing the OS type with force update disabled, results in an error (if Instances created from that ISO - exist).

image

Changing the OS Type with "Force update OS type" enabled - is possible.

Via the API - changing OS type is possible without having to use the 'forceupdateostype' flag. If it is set to 'false' the OS type is not updated.

Same behavior is valid for Templates.

image Screenshot from 2025-07-22 15-49-40 Screenshot from 2025-07-22 15-50-28 Screenshot from 2025-07-22 15-51-06 Screenshot from 2025-07-22 15-51-12

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

@abh1sar check the cmk error msg cc @rosi-shapeblue

@sureshanaparti
Copy link
Contributor

@abh1sar check the cmk error msg cc @rosi-shapeblue

msg looks ok, with the updated results.

@sureshanaparti sureshanaparti merged commit e717216 into apache:main Jul 22, 2025
23 of 26 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache CloudStack 4.21.0 Jul 22, 2025
@sureshanaparti sureshanaparti changed the title Guard OS type update for iso/template with existing vms Guest OS type update for iso/template with existing vms Jul 22, 2025
@sureshanaparti sureshanaparti changed the title Guest OS type update for iso/template with existing vms Guard OS type update for iso/template with existing vms Jul 22, 2025
@abh1sar abh1sar deleted the ostype-iso branch July 22, 2025 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

ISO Image OS Type is tied to the Instance, even after the ISO is disconnected, changes affect all Instances
6 participants