Skip to content

Commit 1688a7a

Browse files
authored
Merge branch 'main' into firehose-developer-preview
2 parents 8b5c154 + a235a9f commit 1688a7a

2 files changed

Lines changed: 35 additions & 1 deletion

File tree

packages/aws-cdk/lib/api/garbage-collection/garbage-collector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ export class GarbageCollector {
635635

636636
// No images in the repository
637637
if (!response.imageIds || response.imageIds.length === 0) {
638-
continue;
638+
break;
639639
}
640640

641641
// map unique image digest to (possibly multiple) tags

packages/aws-cdk/test/api/garbage-collection.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,40 @@ describe('ECR Garbage Collection', () => {
633633
});
634634
});
635635

636+
test('succeeds when no images are present', async () => {
637+
mockTheToolkitInfo({
638+
Outputs: [
639+
{
640+
OutputKey: 'BootstrapVersion',
641+
OutputValue: '999',
642+
},
643+
],
644+
});
645+
646+
const mockListImagesNone = jest.fn().mockImplementation(() => {
647+
return Promise.resolve({
648+
images: [],
649+
});
650+
});
651+
652+
sdk.stubEcr({
653+
batchGetImage: mockBatchGetImage,
654+
describeImages: mockDescribeImages,
655+
batchDeleteImage: mockBatchDeleteImage,
656+
putImage: mockPutImage,
657+
listImages: mockListImagesNone,
658+
});
659+
660+
garbageCollector = garbageCollector = gc({
661+
type: 'ecr',
662+
rollbackBufferDays: 0,
663+
action: 'full',
664+
});
665+
666+
// succeeds without hanging
667+
await garbageCollector.garbageCollect();
668+
});
669+
636670
test('tags are unique', async () => {
637671
mockTheToolkitInfo({
638672
Outputs: [

0 commit comments

Comments
 (0)