-
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
Adding adapter to have volumes/links use DependsOn field #1830
Adding adapter to have volumes/links use DependsOn field #1830
Conversation
agent/api/task/task.go
Outdated
_, ok := task.ContainerByName(volume.SourceContainer) | ||
if !ok { | ||
return fmt.Errorf("could not find container with name %s", volume.SourceContainer) | ||
} else { |
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.
nit: you can one-line this:
if _, ok := task.Foo(); !ok {
}
@@ -250,6 +252,18 @@ func (task *Task) PostUnmarshalTask(cfg *config.Config, | |||
} | |||
} | |||
|
|||
err := task.initializeContainerOrderingForVolumes() |
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.
Have we already validated the links / volumes by 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.
No I think. The links/volumes are validated just before before creating the container, while adding the hostconfig.
5277886
to
c5879c6
Compare
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.
Are we deprecating the existing ContainerDependency
model and moving to DependsOn
?
agent/api/task/task.go
Outdated
@@ -250,6 +252,18 @@ func (task *Task) PostUnmarshalTask(cfg *config.Config, | |||
} | |||
} | |||
|
|||
err := task.initializeContainerOrderingForVolumes() | |||
if err != nil { | |||
seelog.Errorf("Task [%s]: could not initialize volumes for DependsOn field of container: %v", task.Arn, err) |
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.
Calling this - could not initialize volumes dependency for container
.. may be more readable.
agent/api/task/task_test.go
Outdated
Containers: []*apicontainer.Container{container, container1}, | ||
} | ||
|
||
task.initializeContainerOrderingForVolumes() |
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 you assert error returned from this method as well?
@@ -2816,3 +2816,129 @@ func TestAssociationByTypeAndName(t *testing.T) { | |||
association, ok = task.AssociationByTypeAndName("other-type", "dev1") | |||
assert.False(t, ok) | |||
} | |||
|
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.
You could think about using table driven tests for some of these
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 have reduced the number of tests by combining the cases in one...It brought down the number of tests to 1 and also checking all scenarios.
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.
consider making the container names mirror the use case of the test.
c5879c6
to
7da495c
Compare
I have not yet made that change. I have just implemented the initial adapter to populate the DependsOn field of containers with volumes and link containers. |
|
||
err := task.initializeContainerOrderingForVolumes() | ||
assert.Error(t, err) | ||
} |
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.
Please add negative test cases for links as well.
6f5be32
to
57de8d1
Compare
93bba69
to
fe31655
Compare
agent/api/task/task.go
Outdated
for _, volume := range container.VolumesFrom { | ||
if _, ok := task.ContainerByName(volume.SourceContainer); !ok { | ||
return fmt.Errorf("could not find container with name %s", volume.SourceContainer) | ||
} else { |
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.
nit: do we need the else here? if !ok
then the we return an error anyways.
agent/api/task/task.go
Outdated
linkName := linkParts[0] | ||
if _, ok := task.ContainerByName(linkName); !ok { | ||
return fmt.Errorf("could not find container with name %s", linkName) | ||
} else { |
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.
nit: same as above, doesn't seem like we need the else branch here.
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.
Thanks for pointing out. Removed the else.
also - are you expecting all tests to be passing right now? |
fe31655
to
246ab82
Compare
The tests should pass. As I have not touched any existing logic |
246ab82
to
08567bb
Compare
is this the same windows integ test that @sharanyad references here? #1833 (comment) |
I think so...TestVolumesFromRO this is the one which is timing out here. I have reinitialted the tests a few times. TestVolumesFromRO passed once and some other test timed out at that time. So I guess it should be unrelated to my change. |
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.
Summary
This implements how VolumesFrom and Links field in Container can start to use the DependsOn field in container
Implementation details
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=30s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes:
Description for the changelog
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.