You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2015/03/30 15:50:45 UTC

[GitHub] incubator-brooklyn pull request: web app deploy - use temporary fi...

GitHub user neykov opened a pull request:

    https://github.com/apache/incubator-brooklyn/pull/579

    web app deploy - use temporary file for upload

    **WARN:** The fix changes the semantics of the deploy method. Previously it always succeeded regardless of the result of the copy operation. Now it will fail if either the copy or the rename operations fail.
    
    Uploading the file directly to the webapps folder results in autodeploy triggering before the upload is complete. A problem arises when autodeploy triggers in the same second (before) the upload completes - it will fail due to incomplete file, but will not retry because the timestamp of the file won't change. Change deploy to upload to a temporary file and rename it to a .war only when done. This has a few benefits:
      * The application won't be undeployed at the start of the upload and be down for the duration of the upload
      * Once the server observers the updated file we can be sure that it read its full content
      * If the upload fails (timeout, connection reset, full disk...) the old app won't be undeployed.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/neykov/incubator-brooklyn fix/war-deploy

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-brooklyn/pull/579.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #579
    
----
commit 14ff153a066b5155349a7ed30718f0dd9b8889a9
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Date:   2015-03-30T13:48:29Z

    web app deploy - use temporary file for upload
    
    Uploading the file directly to the webapps folder results in autodeploy triggering before the upload is complete. A problem arises when autodeploy triggers in the same second (before) the upload completes - it will fail due to incomplete file, but will not retry because the timestamp of the file won't change. Change deploy to upload to a temporary file and rename it to a .war only when done. This has a few benefits:
      * The application won't be undeployed at the start of the upload and be down for the duration of the upload
      * Once the server observers the updated file we can be sure that it read its full content
      * If the upload fails (timeout, connection reset, full disk...) the old app won't be undeployed.
    
    The fix changes the semantics of the deploy method. Previously it always succeeded regardless of the result of the copy operation. Now it will fail if either the copy or the rename operations fail.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: web app deploy - use temporary fi...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on a diff in the pull request:

    https://github.com/apache/incubator-brooklyn/pull/579#discussion_r28435434
  
    --- Diff: software/webapp/src/main/java/brooklyn/entity/webapp/JavaWebAppSshDriver.java ---
    @@ -146,15 +149,39 @@ public void deploy(File f, String targetName) {
          * @see JavaWebAppSoftwareProcess#deploy(String, String) for details of how input filenames are handled
          */
         @Override
    -    public String deploy(String url, String targetName) {
    -        String canonicalTargetName = getFilenameContextMapper().convertDeploymentTargetNameToFilename(targetName);
    -        String dest = getDeployDir() + "/" + canonicalTargetName;
    -        log.info("{} deploying {} to {}:{}", new Object[]{entity, url, getHostname(), dest});
    -        // create a backup
    -        getMachine().execCommands("backing up old war", ImmutableList.of(String.format("mv -f %s %s.bak > /dev/null 2>&1", dest, dest))); //back up old file/directory
    -        int result = copyResource(url, dest);
    -        log.debug("{} deployed {} to {}:{}: result {}", new Object[]{entity, url, getHostname(), dest, result});
    -        if (result!=0) log.warn("Problem deploying {} to {}:{} for {}: result {}", new Object[]{url, getHostname(), dest, entity, result}); 
    +    public String deploy(final String url, final String targetName) {
    +        final String canonicalTargetName = getFilenameContextMapper().convertDeploymentTargetNameToFilename(targetName);
    +        final String dest = getDeployDir() + "/" + canonicalTargetName;
    +        //write to a .tmp so autodeploy is not triggered during upload
    +        final String tmpDest = dest + ".tmp";
    --- End diff --
    
    make this `dest+"."+Strings.makeRandomId(8)+".tmp"` ?
    
    that should prevent collisions if the same thing is deployed simultaneously


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: web app deploy - use temporary fi...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on the pull request:

    https://github.com/apache/incubator-brooklyn/pull/579#issuecomment-88630917
  
    Good catch! Changes look good; merging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] incubator-brooklyn pull request: web app deploy - use temporary fi...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/incubator-brooklyn/pull/579


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---