Skip to content

Commit 4cd4804

Browse files
committed
config: exclude known cached images
1 parent ad95b99 commit 4cd4804

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

agent/config/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ const (
126126

127127
// DefaultTaskMetadataBurstRate is set to handle 60 burst requests at once
128128
DefaultTaskMetadataBurstRate = 60
129+
130+
//Known cached image names
131+
CachedImageNamePauseContainer = "amazon/amazon-ecs-pause:0.1.0"
132+
CachedImageNameAgentContainer = "amazon/amazon-ecs-agent:latest"
129133
)
130134

131135
const (

agent/config/config_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ func TestValidForImagesCleanupExclusion(t *testing.T) {
376376
defer setTestRegion()()
377377
defer setTestEnv("ECS_EXCLUDE_UNTRACKED_IMAGE", "amazonlinux:2,amazonlinux:3")()
378378
imagesNotDelete := parseImageCleanupExclusionList("ECS_EXCLUDE_UNTRACKED_IMAGE")
379-
assert.Equal(t, []string{"amazonlinux:2", "amazonlinux:3"}, imagesNotDelete, "unexpected imageCleanupExclusionList")
379+
expectedImages := []string{"amazonlinux:2", "amazonlinux:3", CachedImageNameAgentContainer, CachedImageNamePauseContainer}
380+
assert.Equal(t, expectedImages, imagesNotDelete, "unexpected imageCleanupExclusionList")
380381
}
381382

382383
func TestValidFormatParseEnvVariableDuration(t *testing.T) {

agent/config/parse.go

+4
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ func parseImageCleanupExclusionList(envVar string) []string {
298298
} else {
299299
imageCleanupExclusionList = strings.Split(imageEnv, ",")
300300
}
301+
302+
// append known cached internal images to imageCleanupExclusionLis
303+
imageCleanupExclusionList = append(imageCleanupExclusionList, CachedImageNameAgentContainer, CachedImageNamePauseContainer)
304+
301305
for _, image := range imageCleanupExclusionList {
302306
seelog.Infof("Image excluded from cleanup: %s", image)
303307
}

0 commit comments

Comments
 (0)