DaanHoogland opened a new issue #3588: attach iso succeeds from different zone
URL: https://github.com/apache/cloudstack/issues/3588
 
 
   <!--
   Verify first that your issue/request is not already reported on GitHub.
   Also test if the latest release and master branch are affected too.
   Always add information AFTER of these HTML comments, but no need to delete 
the comments.
   -->
   When attaching an iso from zone A to a stopped VM from zone B, a customer 
reported that the API succeeds. The VM can not be started as the ISO is not 
available in the required zone.
   I have not reproduced the error for lack of being able to create a suitable 
environment, but code analysis shows that this is plausible.
   
   the following fragment should ensure the attachement fails with a proper 
error result:
   ```
   $ git diff
   diff --git 
a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java 
b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
   index b81faeb0bd..9058b4922f 100755
   --- a/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
   +++ b/server/src/main/java/com/cloud/template/TemplateManagerImpl.java
   @@ -1182,6 +1182,12 @@ public class TemplateManagerImpl extends ManagerBase 
implements TemplateManager,
                throw new InvalidParameterValueException("Unable to find a 
virtual machine with id " + vmId);
            }
   
   +        long dcId = vm.getDataCenterId();
   +        VMTemplateZoneVO exists = _tmpltZoneDao.findByZoneTemplate(dcId, 
isoId);
   +        if (null == exists) {
   +            throw new InvalidParameterValueException("iso is not available 
in the zone the VM is in.");
   +        }
   +
            VMTemplateVO iso = _tmpltDao.findById(isoId);
            if (iso == null || iso.getRemoved() != null) {
                throw new InvalidParameterValueException("Unable to find an ISO 
with id " + isoId);
   ```
   
   ##### ISSUE TYPE
   <!-- Pick one below and delete the rest -->
   ( * Bug Report)
    * Improvement Request
   
   ##### COMPONENT NAME
   <!--
   Categorize the issue, e.g. API, VR, VPN, UI, etc.
   -->
   ~~~
   API
   ~~~
   
   ##### CLOUDSTACK VERSION
   <!--
   New line separated list of affected versions, commit ID for issues on master 
branch.
   -->
   
   ~~~
   All
   ~~~
   
   ##### CONFIGURATION
   <!--
   Information about the configuration if relevant, e.g. basic network, 
advanced networking, etc.  N/A otherwise
   -->
   
   
   ##### OS / ENVIRONMENT
   <!--
   Information about the environment if relevant, N/A otherwise
   -->
   
   
   ##### SUMMARY
   <!-- Explain the problem/feature briefly -->
   attaching an ISO from another zone succeeds when it should fail
   
   ##### STEPS TO REPRODUCE
   <!--
   For bugs, show exactly how to reproduce the problem, using a minimal 
test-case. Use Screenshots if accurate.
   
   For new features, show how the feature would be used.
   -->
   
   <!-- Paste example playbooks or commands between quotes below -->
   ~~~
   create two zones
   create a VM in zone 1
   make sure the VM is stopped
   register an ISO in the other zone
   attach the ISO to the VM
   ~~~
   
   <!-- You can also paste gist.github.com links for larger files -->
   
   ##### EXPECTED RESULTS
   <!-- What did you expect to happen when running the steps above? -->
   
   ~~~
   ISO will not be attached
   ~~~
   
   ##### ACTUAL RESULTS
   <!-- What actually happened? -->
   
   <!-- Paste verbatim command output between quotes below -->
   ~~~
   ISO is attached to the VM
   ~~~
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to