-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CDK needs garbage collection for assets in the cdk.out directory #2869
Comments
Duplicated by #3749 |
Seems to be related to #1332 |
Hi @nathanpeck, thanks for submitting a feature request! This seems like a reasonable and helpful ask. We will look into this and someone will update this issue when there is movement. |
I think that if users do P.S. it should be something like |
@eladb I do worry that would reduce the visibility of the folder. Particularly in cases where I have multiple projects and for some reason my stacks aren't generating as expected I would hate to have to figure out which of the outputs inside my tmp folder is the right one. I think while it is tempting to piggyback on the existing |
If you do I am not sure I understand why you think putting intermediate (temporary) build artifacts is not a good use case for |
@eladb I don't think of the build artifacts as temporary. For example if I GCC compile I would expect my C++ files to turn into object files in a local path, not in the Or if I TypeScript compile I expect the resulting JavaScript to end up in the local directory, not in From that perspective I see CDK to CloudFormation / assets as just another type of transformation, where I expect the resulting product to be local, not remotely cached I'm not strictly opinionated on this, but it just feels somewhat strange to me if the cdk.out is located in a different folder outside of my project |
I found this issue from a different direction - I have some tests for my CDK code, and each time I run them it is building a new asset directory and putting it in I think I would expect that - by default - assets for test runs were deleted after the test run had completed, regardless of where they are stored. |
In the interim.. is it ok to just manually clear out anything in this folder (or even the whole folder)? I've left it building up for now as I wasn't sure if they were required somewhere down the line/for |
I have another use case for more control over the asset directories. I'm using CDK with SAM CLI and I'm trying to use The workaround I'm about to implement is to get the existing asset directory name, delete it, then rename the new asset directory to the old one after |
Please don't move cdk.out to /tmp as people who never reboot will have that thing blowing up as well. Also it is not safe when deploying multiple projects since the erase solution above would remove anything inside /tmp I had literally over 100 Why isn't all that being just deleted right after deploy (or before deploy so we keep last one)? |
I think cdk synth should clean the folder and create it again |
How about automatic cleanup based on the creation date? For example, configure cdk.json like: {
"app": "bin/synth",
"autoCleanOutdatedAssetsBefore": "3days" // The assets created before 3 days are automatically deleted(on running `cdk synth` or etc.)
} |
This is problematic with CDK tests as every test run creates a new directory in /tmp and when writing tests it fills up the hard disk space quite quickly |
I've run out of space (aka memory on Linux) in Never had a problem around |
+1 to finding a solution for this. I just had to clean up ~70GB of files from my cdk.out directory in my project. |
Why not just delete the |
Because all Assets would have to be re-staged on every |
I'm surprised by this. Is there no OS level garbage collection for |
/tmp is a ramdisk (at least on my linux systems), so is gone after a restart/logout. But if you restart only once in a blue moon, running out of space will happen... |
Thanks for clarifying this. 👍🏻 |
I'm using C# and the DockerImageFunction construct and I just stumbled across 45GB of assets in cdk.out My Program.cs now has the following
|
Should be warned that if you delete your |
I'm not sure of the issues hierarchy here, but everyone should probably be aware of a parallel discussion going on in aws/aws-cdk-rfcs#64 (opened in 2018). I feel like clearing out cdk.out better be an okay thing to do, because I build from multiple development locations, so they aren't going to be in sync depending on if I'm working from home or my office.. Deleting things out of the staging bucket is a little scarier to me. Issues related to scaling and rollback have been raised, but I am not enough of an expert to know whether or not those are legitimate concerns. I think it should be okay to clear out the staging bucket after you successfully deploy, but I'm not confident enough to try it on a production project. The biggest item in the staging bucket looks like it might be part of the cdk itself (maybe put there by I think all this means two things:
|
I work on my project in a Dropbox folder, and regularly use The ability to move the artefacts to a directory outside the current working directory/tree (and outside of dropbox) is ideal, and I can always create a soft link for convenience from the cwd which isn’t synced. Perpetual growth of the cdk.out directory is, IMHO, just lazy design. I appreciate that there are intermediate assets that might add extra cost to repeated synth/deploy cycles and these should be documented. |
I'll add one more suggestion to the pile... I'd like the CDK Toolkit to provide a With a Of course, the templates provided for use with the |
My CDK project is an npm package, and I utilize npm pre scripts to remove the
|
@lprhodes I figured out a solution for this sample code:
And then in my When you run that script, esbuild is actually running watch and recompiles your changes and put it out to the Hope that helps! I was able to code my lambdas in typescript and re-run the lambda without costing so much time for the cdk re-runs. Resources: |
I've been working on a CDK project over the last couple of days and suddenly my IDE stopped working. I had a poke around today and found this:
For now I'm going to obliterate the |
In order to see the total size all files within
Then from the relevant path, you can delete the assets and synth files within those
|
Each time I run a CDK deploy I get a new asset in the asset's directory, and they seem to accumulate forever. Each asset folder is around 100 MB for me, so this quickly adds up to many GB of data. Here is a screenshot of it accumulating assets again after the last time I cleaned it out manually.
Ideally I would like a CDK configuration that would cause CDK to automatically garbage collect older asset files it no longer needs so I don't have to do it manually.
The text was updated successfully, but these errors were encountered: