Skip to content

Commit

Permalink
agent: naming changes for exclude non ecs images
Browse files Browse the repository at this point in the history
  • Loading branch information
adnxn committed Dec 26, 2018
1 parent e9c4be7 commit e9f23ab
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion agent/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func environmentConfig() (Config, error) {
NumImagesToDeletePerCycle: parseNumImagesToDeletePerCycle(),
NumNonECSContainersToDeletePerCycle: parseNumNonECSContainersToDeletePerCycle(),
ImagePullBehavior: parseImagePullBehavior(),
ImageCleanupExclusionList: parseImageCleanupExclusionList("ECS_NONECS_IMAGE_CLEANUP_EXCLUDE"),
ImageCleanupExclusionList: parseImageCleanupExclusionList("ECS_EXCLUDE_UNTRACKED_IMAGE"),
InstanceAttributes: instanceAttributes,
CNIPluginsPath: os.Getenv("ECS_CNI_PLUGINS_PATH"),
AWSVPCBlockInstanceMetdata: utils.ParseBool(os.Getenv("ECS_AWSVPC_BLOCK_IMDS"), false),
Expand Down
4 changes: 2 additions & 2 deletions agent/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ func TestInvalidFormatParseEnvVariableDuration(t *testing.T) {

func TestValidForImagesCleanupExclusion(t *testing.T) {
defer setTestRegion()()
defer setTestEnv("ECS_NONECS_IMAGE_CLEANUP_EXCLUDE", "amazonlinux:2,amazonlinux:3")()
imagesNotDelete := parseImageCleanupExclusionList("ECS_NONECS_IMAGE_CLEANUP_EXCLUDE")
defer setTestEnv("ECS_EXCLUDE_UNTRACKED_IMAGE", "amazonlinux:2,amazonlinux:3")()
imagesNotDelete := parseImageCleanupExclusionList("ECS_EXCLUDE_UNTRACKED_IMAGE")
assert.Equal(t, []string{"amazonlinux:2", "amazonlinux:3"}, imagesNotDelete, "unexpected imageCleanupExclusionList")
}

Expand Down
4 changes: 1 addition & 3 deletions agent/dockerclient/dockerapi/docker_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1026,9 +1026,7 @@ func (dg *dockerGoClient) listImages(ctx context.Context) ListImagesResponse {
if err != nil {
return ListImagesResponse{Error: err}
}
images, err := client.ImageList(ctx, types.ImageListOptions{
All: false,
})
images, err := client.ImageList(ctx, types.ImageListOptions{})
if err != nil {
return ListImagesResponse{Error: err}
}
Expand Down
8 changes: 4 additions & 4 deletions agent/engine/docker_image_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ func (imageManager *dockerImageManager) removeUnusedImages(ctx context.Context)
}

func (imageManager *dockerImageManager) removeNonECSContainers(ctx context.Context) {
nonECSContainersIDs, err := imageManager.nonECSContainersIDs(ctx)
nonECSContainersIDs, err := imageManager.getNonECSContainerIDs(ctx)
if err != nil {
seelog.Errorf("Error getting non-ECS container IDs: %v", err)
}
Expand Down Expand Up @@ -360,7 +360,7 @@ func (imageManager *dockerImageManager) removeNonECSContainers(ctx context.Conte
}
}

func (imageManager *dockerImageManager) nonECSContainersIDs(ctx context.Context) ([]string, error) {
func (imageManager *dockerImageManager) getNonECSContainerIDs(ctx context.Context) ([]string, error) {
var allContainersIDs []string
listContainersResponse := imageManager.client.ListContainers(ctx, true, dockerclient.ListContainersTimeout)
if listContainersResponse.Error != nil {
Expand All @@ -383,7 +383,7 @@ func (imageManager *dockerImageManager) removeNonECSImages(ctx context.Context,
if nonECSImagesNumToDelete == 0 {
return
}
var nonECSImageNames = imageManager.nonECSImagesNames(ctx)
var nonECSImageNames = imageManager.getNonECSImageNames(ctx)
var nonECSImageNamesRemoveEligible []string
for _, nonECSImage := range nonECSImageNames {
if !isInExclusionList(nonECSImage, imageManager.imageCleanupExclusionList) {
Expand Down Expand Up @@ -419,7 +419,7 @@ func (imageManager *dockerImageManager) removeNonECSImages(ctx context.Context,
}
}

func (imageManager *dockerImageManager) nonECSImagesNames(ctx context.Context) []string {
func (imageManager *dockerImageManager) getNonECSImageNames(ctx context.Context) []string {
response := imageManager.client.ListImages(ctx, dockerclient.ListImagesTimeout)
var allImagesNames []string
for _, name := range response.RepoTags {
Expand Down

0 comments on commit e9f23ab

Please sign in to comment.