Skip to content

Reject new settings on deploy-as-is templates, not only UEFI - #14708

Open
yuminn-k wants to merge 1 commit into
apache:4.20from
yuminn-k:fix-template-validate-details-12458
Open

yuminn-k wants to merge 1 commit into
apache:4.20from
yuminn-k:fix-template-validate-details-12458

Conversation

@yuminn-k

Copy link
Copy Markdown

Description

TemplateManagerImpl.validateDetails() only checked whether a template is deploy-as-is when the UEFI key was present. For any other key it returned early, so settings such as rootDiskController could still be added to a deploy-as-is template ("Read Instance settings from OVA"), even though those settings are read directly from the OVA.

This moves the deploy-as-is check ahead of the early return. For a deploy-as-is template, any detail whose key is missing from the template's current details, or whose value differs, is rejected with InvalidParameterValueException ("Deploy-as-is Template ... can not have the setting. Settings are read directly from the Template"). Details that are identical to what the template already has are accepted, so clients that re-send the existing settings keep working.

Policy choice: the issue discussion asks that no new template settings be allowed for such templates, so all changed or new keys are rejected. The alternative is to reuse the VM-side allow list (vmware.allowed.additional.details.from.ova in UserVmManagerImpl), but that list is a zone-scoped setting and templates can be shared across zones, so I kept the template check strict. Happy to switch if reviewers prefer the allow list.

Targets 4.20 because this is a bug fix (milestone 4.20.4, see CONTRIBUTING).

Fixes: #12458

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)

How Has This Been Tested?

Unit tests in TemplateManagerImplTest (new): a deploy-as-is template rejects a new non-UEFI key (failed before the change, passes after), accepts an unchanged key, and a regular template still accepts non-UEFI keys.

mvn -pl server -am -Dtest=TemplateManagerImplTest test
Tests run: 40, Failures: 0, Errors: 0, Skipped: 0

Checkstyle reports 0 violations. I did not test against a real VMware deploy-as-is template.

This branch has not been deployed

No deployments
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.

1 participant