Skip to content

Commit e1cd1d4

Browse files
authored
chore(cli): add image to gc docs and document race condition (#31925)
This might be contentious given that we don't do photos in most places but afaik we do not replicate the CLI docs on the CDK docs site so it may be safe (as it renders correctly on github). Documents garbage collection algorithm via diagram and details potentail race condition with `REVIEW_IN_PROGRESS` stacks. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent ccab485 commit e1cd1d4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

packages/aws-cdk/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,26 @@ cdk gc --unstable=gc --action=delete-tagged --rollback-buffer-days=30
971971

972972
This will delete assets that have been unused for >30 days, but will not tag additional assets.
973973

974+
Here is a diagram that shows the algorithm of garbage collection:
975+
976+
![Diagram of Garbage Collection algorithm](images/garbage-collection.png)
977+
978+
#### Theoretical Race Condition with `REVIEW_IN_PROGRESS` stacks
979+
980+
When gathering stack templates, we are currently ignoring `REVIEW_IN_PROGRESS` stacks as no template
981+
is available during the time the stack is in that state. However, stacks in `REVIEW_IN_PROGRESS` have already
982+
passed through the asset uploading step, where it either uploads new assets or ensures that the asset exists.
983+
Therefore it is possible the assets it references are marked as isolated and garbage collected before the stack
984+
template is available.
985+
986+
Our recommendation is to not deploy stacks and run garbage collection at the same time. If that is unavoidable,
987+
setting `--created-buffer-days` will help as garbage collection will avoid deleting assets that are recently
988+
created. Finally, if you do result in a failed deployment, the mitigation is to redeploy, as the asset upload step
989+
will be able to reupload the missing asset.
990+
991+
In practice, this race condition is only for a specific edge case and unlikely to happen but please open an
992+
issue if you think that this has happened to your stack.
993+
974994
### `cdk doctor`
975995

976996
Inspect the current command-line environment and configurations, and collect information that can be useful for
319 KB
Loading

0 commit comments

Comments
 (0)