aws-codedeploy-agent: Two deployments in the same directory: the second one fails

We are using Ubuntu 18.04, and are cloning the github repository’s master branch.

We currently have two deployments in two separate directories:

  • /var/www/api
  • /var/www/angular

We can’t seem to be able to deploy both in /var/www with the new version of the agent, while it works fine with the previous one.

The deployment will fail during the install stage after less than a second if /var/www is not completely empty.

The error code it returns is: Unknown error, Directory not empty @ dir_s_rmdir - /var/www

We were previously using Ubuntu 16.04 with the CodeDeploy agent located here: s3://aws-codedeploy-us-east-1/latest/install – and it works fine with two deployment in /var/www.

Version v1.0-1518 on github seems to work properly on Ubutun 18.04, and we can deploy both applications in /var/www. We only really have this problem with the master branch.

Our environment is pretty standard (Vanilla Ubuntu 18.04, with a few standard packages installed, such as nginx, php7.2-fpm, etc.)

Steps to reproduce:

  • Deploy api: success
  • Deploy angular: error
  • Deploy angular: error
  • Delete /var/www
  • Deploy angular: success
  • Deploy api: error
  • Deploy api: error

Our appspec.yml goes as follow (it’s the same for the angular project, but with /var/www/angular instead):

# http://docs.aws.amazon.com/codedeploy/latest/userguide/app-spec-ref.html

version: 0.0

os: linux

files:
   - source: /
     destination: /var/www/api

permissions:
  - object: /var/www/api
    pattern: "**"
    owner: root
    group: www-data
    mode: 775
    type:
      - directory
  - object: /var/www/api
    pattern: "**"
    owner: root
    group: www-data
    mode: 664
    type:
      - file

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 8
  • Comments: 39 (4 by maintainers)

Commits related to this issue

Most upvoted comments

If anyone else hits this and gets stuck (all new deployments failing), removing the *-cleanup files in /opt/codedeploy-agent/deployment-root/deployment-instructions/ allows deployments to run again.

When installing ruby in ubuntu 18.04, ruby version 2.5.x is installed by default.

Before ruby 2.5(i.e., 2.4.3), FileUtils.rmdir silently fails when the target directory is not empty, so the non-empty directories in cleanup file are not removed.

But the implementation of FileUtils.rmdir is changed in ruby 2.5 so that it doesn’t rescue Errno::ENOTEMPTY any more, which generates failures in deployment.

You may refer to #201 to solve the problem by yourself. (I’m wondering what time this would be accepted and merged…)

I’m getting this error with a single deployment and one directory. Seems like this fix should really be prioritized.

For anyone who’s still facing the issue Directory not empty @ dir_s_rmdir - /var/www" on Ubuntu 18.04 For the first time - Step 1 - Delete the cleanup files as commented by @hdm earlier. Step 2 - When creating a deployment, under the Additional deployment behavior settings tab, check the ‘Retain the content’ checkbox.

For the case when you wanna redeploy again - Ignore Step 1 and follow Step 2.

Hope it helps!

The one thing I did that appeared to work was to completely uninstall the CodeDeploy agent and then I had to wipe the /opt/codedeploy directory as well. If you leave that directory around, future deploys will fail after a reinstallation.

😦 Also having this issue on Ubuntu 18.04. Please provide guidance

I encountered this error right after upgrading to ubuntu 18 as well - although I am not trying to run 2 applications.

Directory not empty @ dir_s_rmdir - /home/ubuntu/web

As far as I can tell, Code Deploy no longer wants to delete vendor and node_modules whereas it wasn’t a problem before on Ubuntu 14.

I’ve built a quick hack fix for this until the official release push is done:

https://gist.github.com/WhiteyDude/fd8744440a021b3bb2d1b6cb40ff93ac

@tlacroix @Samuell1 You may use my previous PR in this thread(#201) instead. Folks said it’s working well in their servers.

It is quicker to delete the deployment-instruction folder. You do not need to uninstall the agent.

rm -fr /opt/codedeploy-agent/deployment-root/deployment-instruction

This worked for me.

Hi, We are still looking into it. Thank you

@jackdpeterson we support concurrent deployment , the only thing we ask is that the instance should be in 2 diff deployment groups