CLOUDSTACK-8808: Successfully registered VHD template is downloaded again due to missing virtualsize property in template.properties#901
Conversation
again due to missing virtualsize property in template.properties
We have multiple file processors to process different types of image
formats. The processor interface has two methods getVirtualSize() and
process().
1. getVirtualSize() as the name says, returns the virtual size of
the file and is used at get the size while copying files from NFS to s3
2. process() returns FormatInfo struct which has fileType, size,
virutalSize, filename. on successfully downloading a template, each
file is passed to all the processors.process() and whichever returns a
FormatInfo, that will be used to create template.properties file. If
process() throws an InternalErrorException, template installation fails.
But, if process() returns null, template registration is successful with
template.properties missing some attributes like virtualSize, file
format etc. which results in this bug on restart of ssvm/cloud
service/management server.
failing the template download if virutalsize or some other properties
cannot be determined.
The following changes are done:
getVirtualSize() to always return size(if it can calculate, get virtual
size else return file size). This would mean the following changes
1. QCOW2Processor.getVirtualSize() to return file size if virtual
size calculation fails
2. VHDProcessor.getVirtualSize() to return file size if virtual size
calculation fails
process() to throw InternalErrorException if virtual size calculation
fails or any other exceptions occur. This would mean the following
changes
1. OVAProcessor to throw InternalErrorException if untar fails
2. QCOW2Processor to throw InternalErrorException if virtual size
calculation fails
3. VHDProcessor to throw InternalErrorException if virtual size
calculation fails
There was a problem hiding this comment.
@karuturi Could you please use the QCOW2Utils.getVirtualSize() from the com.cloud.utils.storage package instead of using the function defined in the QCOW2Processor? :)
There was a problem hiding this comment.
The utils one should be a recent implementation. I wonder why the author hasnt done cleanup and left two implementation of the same. I will take a look at the code later and see if it can be reused here.
|
Thanks @karuturi for picking this up. Will have a look soon! |
|
@karuturi Thanks a lot, works great! LGTM I registered a template with invalid headers, as per CLOUDSTACK-8808. At first everything is normal: It then starts installing (and unzipping): And eventually disappears from the UI. The logs show Full logs: When someone else reviews this we can merge it and solve another blocker. |
|
@borisroman: Are the answers to your questions sufficient? Can you review again please? |
|
@remibergsma Anwser is sufficient. I'll cleanup after 4.6 is released. Regarding the PR: 👍 LGTM I ran the test_vm_lifecycle which succeeded and also manually ran the tests described in CLOUDSTACK-8808, same results as you showed. |
|
Thanks @borisroman, merged! |
CLOUDSTACK-8808: Successfully registered VHD template is downloaded again due to missing virtualsize property in template.propertiesWe have multiple file processors to process different types of image formats. The processor interface has two methods getVirtualSize() and process(). 1. getVirtualSize() as the name says, returns the virtual size of the file and is used at get the size while copying files from NFS to s3 2. process() returns FormatInfo struct which has fileType, size, virutalSize, filename. on successfully downloading a template, each file is passed to all the processors.process() and whichever returns a FormatInfo, that will be used to create template.properties file. If process() throws an InternalErrorException, template installation fails. But, if process() returns null, template registration is successful with template.properties missing some attributes like virtualSize, file format etc. which results in this bug on restart of ssvm/cloud service/management server. failing the template download if virutalsize or some other properties cannot be determined. The following changes are done: getVirtualSize() to always return size(if it can calculate, get virtual size else return file size). This would mean the following changes 1. QCOW2Processor.getVirtualSize() to return file size if virtual size calculation fails 2. VHDProcessor.getVirtualSize() to return file size if virtual size calculation fails process() to throw InternalErrorException if virtual size calculation fails or any other exceptions occur. This would mean the following changes 1. OVAProcessor to throw InternalErrorException if untar fails 2. QCOW2Processor to throw InternalErrorException if virtual size calculation fails 3. VHDProcessor to throw InternalErrorException if virtual size calculation fails Testing: added unittests for the changes in the file processors. manual test: setup: host xenserver 6.5, management server centos 6.7 template: disk created using the process specified by andy at https://issues.apache.org/jira/browse/CLOUDSTACK-8808?focusedCommentId=14933368 tried to register the template and it failed with an error. Template never moved to Ready state.  * pr/901: CLOUDSTACK-8808: Successfully registered VHD template is downloaded again due to missing virtualsize property in template.properties Signed-off-by: Remi Bergsma <github@remi.nl>
…901) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>


We have multiple file processors to process different types of image
formats. The processor interface has two methods getVirtualSize() and
process().
the file and is used at get the size while copying files from NFS to s3
virutalSize, filename. on successfully downloading a template, each
file is passed to all the processors.process() and whichever returns a
FormatInfo, that will be used to create template.properties file. If
process() throws an InternalErrorException, template installation fails.
But, if process() returns null, template registration is successful with
template.properties missing some attributes like virtualSize, file
format etc. which results in this bug on restart of ssvm/cloud
service/management server.
failing the template download if virutalsize or some other properties
cannot be determined.
The following changes are done:
getVirtualSize() to always return size(if it can calculate, get virtual
size else return file size). This would mean the following changes
size calculation fails
calculation fails
process() to throw InternalErrorException if virtual size calculation
fails or any other exceptions occur. This would mean the following
changes
calculation fails
calculation fails
Testing:

added unittests for the changes in the file processors.
manual test:
setup: host xenserver 6.5, management server centos 6.7
template: disk created using the process specified by andy at https://issues.apache.org/jira/browse/CLOUDSTACK-8808?focusedCommentId=14933368
tried to register the template and it failed with an error. Template never moved to Ready state.