1
votes

I found that CodeDeploy is filling up disk space on my EC2 instance with logs/deploy info at "/opt/codedeploy-agent/deployment-root/#####yourNumberWillBeDifferent#####".

Every time there is a deployment is creates another directory in that location that is named with the Deployment ID and it is approximately 650M. The directory contains logs, bundle.tar and a deployment-archive folder which has all the files needed for that deployment. After a few deployments I noticed that my disk space was being used up because of this. FYI - I am performing in place deployments on EC2 in place instances.

I next discovered that when a deployment is run it looks in the EC2 instance for the deploy directory of the previous deploy run and requires its AppSpec file for some reason. I discovered this due to the fact that if I delete all the deploy folders in this directory I get the error -

''' The revision was unpacked to directory "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive", and the AppSpec file was expected but not found at path "/opt/codedeploy-agent/deployment-root/59a04892-4afd-4e82-9335-52e8b6047d4b/d-WZDFGDBHU/deployment-archive/appspec.yml" '''

d-WZDFGDBHU is the Deployment ID of the last deployment that was performed prior to the one that was just run.

If I delete all the directories except for the most recent one (in this case keeping just "d-WZDFGDBHU") then the deploy runs fine.

What I wound up doing is have a script run every hour that deletes all the directories in this location except the latest one.

I don't know why CodeDeploy needs to refer to this directory of the last deployment but indeed it does!!

Is there a better way to handle this or did I set up CodeDeploy incorrectly?

1

1 Answers

1
votes

For anyone else experiencing this -

CodeDeploy keeps a number of the last deployments to allow you to rollback to previous versions. By default it keeps the last 5 but this is configurable using the codedeploy agent config: https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-agent-configuration.html

The setting that controls this is :max_revisions: