-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle pull for "internal" containers #990
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import ( | |
"github.com/aws/amazon-ecs-agent/agent/engine/dependencygraph" | ||
"github.com/aws/amazon-ecs-agent/agent/engine/dockerclient" | ||
"github.com/aws/amazon-ecs-agent/agent/engine/dockerstate" | ||
"github.com/aws/amazon-ecs-agent/agent/engine/emptyvolume" | ||
"github.com/aws/amazon-ecs-agent/agent/eventstream" | ||
"github.com/aws/amazon-ecs-agent/agent/statechange" | ||
"github.com/aws/amazon-ecs-agent/agent/statemanager" | ||
|
@@ -508,6 +509,16 @@ func (engine *DockerTaskEngine) GetTaskByArn(arn string) (*api.Task, bool) { | |
} | ||
|
||
func (engine *DockerTaskEngine) pullContainer(task *api.Task, container *api.Container) DockerContainerMetadata { | ||
switch container.Type { | ||
case api.ContainerCNIPause: | ||
// ContainerCNIPause image are managed at startup | ||
return DockerContainerMetadata{} | ||
case api.ContainerEmptyHostVolume: | ||
// ContainerEmptyHostVolume image is either local (must be imported) or remote (must be pulled) | ||
if emptyvolume.LocalImage { | ||
return engine.client.ImportLocalEmptyVolumeImage() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
} | ||
if engine.enableConcurrentPull { | ||
seelog.Infof("Pulling container %v concurrently. Task: %v", container, task) | ||
return engine.concurrentPull(task, container) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// +build !windows,!integration | ||
|
||
// Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
package engine | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/amazon-ecs-agent/agent/api" | ||
"github.com/aws/amazon-ecs-agent/agent/config" | ||
"github.com/aws/amazon-ecs-agent/agent/engine/emptyvolume" | ||
"github.com/aws/amazon-ecs-agent/agent/statemanager/mocks" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPullEmptyVolumeImage(t *testing.T) { | ||
ctrl, client, _, privateTaskEngine, _, _ := mocks(t, &config.Config{}) | ||
defer ctrl.Finish() | ||
taskEngine, _ := privateTaskEngine.(*DockerTaskEngine) | ||
saver := mock_statemanager.NewMockStateManager(ctrl) | ||
taskEngine.SetSaver(saver) | ||
|
||
imageName := "image" | ||
container := &api.Container{ | ||
Type: api.ContainerEmptyHostVolume, | ||
Image: imageName, | ||
} | ||
task := &api.Task{ | ||
Containers: []*api.Container{container}, | ||
} | ||
|
||
assert.True(t, emptyvolume.LocalImage, "empty volume image is local") | ||
client.EXPECT().ImportLocalEmptyVolumeImage() | ||
|
||
metadata := taskEngine.pullContainer(task, container) | ||
assert.Equal(t, DockerContainerMetadata{}, metadata, "expected empty metadata") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// +build windows,!integration | ||
|
||
// Copyright 2014-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"). You may | ||
// not use this file except in compliance with the License. A copy of the | ||
// License is located at | ||
// | ||
// http://aws.amazon.com/apache2.0/ | ||
// | ||
// or in the "license" file accompanying this file. This file is distributed | ||
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
// express or implied. See the License for the specific language governing | ||
// permissions and limitations under the License. | ||
package engine | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/aws/amazon-ecs-agent/agent/api" | ||
"github.com/aws/amazon-ecs-agent/agent/config" | ||
"github.com/aws/amazon-ecs-agent/agent/engine/emptyvolume" | ||
"github.com/aws/amazon-ecs-agent/agent/statemanager/mocks" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPullEmptyVolumeImage(t *testing.T) { | ||
ctrl, client, _, privateTaskEngine, _, _ := mocks(t, &config.Config{}) | ||
defer ctrl.Finish() | ||
taskEngine, _ := privateTaskEngine.(*DockerTaskEngine) | ||
saver := mock_statemanager.NewMockStateManager(ctrl) | ||
taskEngine.SetSaver(saver) | ||
|
||
imageName := "image" | ||
container := &api.Container{ | ||
Type: api.ContainerEmptyHostVolume, | ||
Image: imageName, | ||
} | ||
task := &api.Task{ | ||
Containers: []*api.Container{container}, | ||
} | ||
|
||
assert.False(t, emptyvolume.LocalImage, "Windows empty volume image is not local") | ||
client.EXPECT().PullImage(imageName, nil) | ||
|
||
metadata := taskEngine.pullContainer(task, container) | ||
assert.Equal(t, DockerContainerMetadata{}, metadata, "expected empty metadata") | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the
transition
string be a const ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason why? I generally like constants if there's string reuse, string comparison, or if it aids clarity. I suppose reuse might apply here, but it's only used in two places right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was primarily concerned with reuse but it was more of a suggestion.