Commit 66e0b2d
authored
fix(cli): gc does not delete isolated assets when rollback-buffer-days is set (#502)
The `Date` class allows the following for values: `new Date(value:
number | string | Date)`, but sometimes does not work as expected.
That's essentially what we are doing because we are storing the string
value of the date in the tags and the conversion back to a date doesn't
work correctly.
A deep dive into the issue with Dates:
```ts
console.log(Date.now()) // 1747346265800
console.log(Date(1747346265800)) // Thu May 15 2025 18:06:11 GMT-0400 (Eastern Daylight Time)
console.log(Date('1747346265800')) // Thu May 15 2025 18:05:57 GMT-0400 (Eastern Daylight Time)
console.log(new Date(1747346265800)) // 2025-05-15T21:57:45.800Z
console.log(new Date('1747346265800')) // Invalid Date
```
I seem to have been unlucky with how I tried to create the date from a
string. Also, the resulting dates with a number of milliseconds versus a
string of milliseconds is _slightly_ different, 18:06:11 versus
18:05:57...
This _was_ attempted to be unit tested but in the unit test I mistakenly
mocked the tag to be an ISO String which _is_ a string so it had no
problem getting converted into a Date. This test has been updated.
Because we pessimistically handle errors; we just treated this as a
nondeletable asset. I have added an integ test that tests this scenario
and confirmed on my own local set up that this fixes the issue.
---
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license1 parent 7e23e64 commit 66e0b2d
File tree
3 files changed
+74
-3
lines changed- packages
- @aws-cdk-testing/cli-integ/tests/cli-integ-tests
- @aws-cdk/toolkit-lib
- lib/api/garbage-collection
- test/api/garbage-collection
3 files changed
+74
-3
lines changedLines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
| 120 | + | |
119 | 121 | | |
120 | 122 | | |
121 | 123 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | | - | |
| 919 | + | |
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
| |||
0 commit comments