[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-6938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14036468#comment-14036468
 ] 

Logan B commented on CLOUDSTACK-6938:
-------------------------------------

This is the relevant bit of code:

In NfsSecondaryStorageResource.java:

if (!downloadDirectory.mkdirs()) {
                final String errMsg = "Unable to create directory " + 
downloadPath + " to copy from S3 to cache.";
                s_logger.error(errMsg);
                return new CopyCmdAnswer(errMsg);
            } else {
                s_logger.debug("Directory " + downloadPath + " already exists");
            }

I believe mkdirs() returns false if the directory already exists.  So this 
failure logic is prone to breaking.

Better logic might be:

if (downloadDirectory.exists()) {
              s_logger.debug("Directory " + downloadPath + " already exists");
            } else {
                 if (!downloadDirectory.mkdirs()) {
                       final String errMsg = "Unable to create directory " + 
downloadPath + " to copy from S3 to cache.";
                        s_logger.error(errMsg);
                        return new CopyCmdAnswer(errMsg);
             }

I'm not a programmer, but it seems that checking for the existing path before 
blindly failing would be better here.  If this code checks out I'll try to 
figure out how to offer a commit for cherry picking.

> Cannot create template from snapshot when using S3 storage
> ----------------------------------------------------------
>
>                 Key: CLOUDSTACK-6938
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-6938
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Snapshot
>    Affects Versions: 4.4.0
>         Environment: KVM + S3 Secondary Storage
>            Reporter: Logan B
>            Priority: Blocker
>             Fix For: 4.4.0
>
>
> When trying to create a template from a snapshot with S3 secondary storage, 
> the command immediately fails with a NullPointerException.
> This appears to only happen when there is a pre-existing snapshot folder in 
> the NFS staging store.  This indicates that there is something wrong with the 
> copy command (e.g., it's using 'mkdir' instead of 'mkdir -p').
> The issue can be worked around by deleting the existing snapshot folder on 
> the staging store every time you want to create a new template.  This is 
> obviously not viable for end users.
> This issue should be fixed before 4.4 ships because it should be a stupid 
> simple thing to correct, but completely breaks restoring snapshots for end 
> users.  Waiting for 4.5 would be far too long for an issue like this.
> 2014-06-18 21:13:54,789 DEBUG [cloud.agent.Agent] 
> (agentRequest-Handler-2:null) Processing command: 
> org.apache.cloudstack.storage.command.CopyCommand
> 2014-06-18 21:13:54,789 INFO  [storage.resource.NfsSecondaryStorageResource] 
> (agentRequest-Handler-2:null) Determined host 172.16.48.99 corresponds to IP 
> 172.16.48.99
> 2014-06-18 21:13:54,797 ERROR [storage.resource.NfsSecondaryStorageResource] 
> (agentRequest-Handler-2:null) Unable to create directory 
> /mnt/SecStorage/6b9bdec9-fdc9-3fdd-a5f8-0481df177ae8/snapshots/2/25 to copy 
> from S3 to cache.
> I'm guessing it's an issue with the mkdirs() function in the code, but I've 
> been unable to find it.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to