Skip to content
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

Conversation

ubhattacharjya
Copy link
Contributor

Summary

This implements how VolumesFrom and Links field in Container can start to use the DependsOn field in container

Implementation details

Testing

  • Builds on Linux (make release)
  • Builds on Windows (go build -out amazon-ecs-agent.exe ./agent)
  • Unit tests on Linux (make test) pass
  • Unit tests on Windows (go test -timeout=30s ./agent/...) pass
  • Integration tests on Linux (make run-integ-tests) pass
  • Integration tests on Windows (.\scripts\run-integ-tests.ps1) pass
  • Functional tests on Linux (make run-functional-tests) pass
  • Functional tests on Windows (.\scripts\run-functional-tests.ps1) pass

New 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.

_, ok := task.ContainerByName(volume.SourceContainer)
if !ok {
return fmt.Errorf("could not find container with name %s", volume.SourceContainer)
} else {
Copy link
Contributor

@petderek petderek Jan 31, 2019

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@petderek petderek requested a review from sharanyad January 31, 2019 22:34
@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch from 5277886 to c5879c6 Compare February 1, 2019 19:07
Copy link
Contributor

@sharanyad sharanyad left a 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 ?

@@ -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)
Copy link
Contributor

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.

Containers: []*apicontainer.Container{container, container1},
}

task.initializeContainerOrderingForVolumes()
Copy link
Contributor

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)
}

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@ubhattacharjya ubhattacharjya requested review from sharanyad and a team February 1, 2019 19:09
@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch from c5879c6 to 7da495c Compare February 1, 2019 20:07
@ubhattacharjya
Copy link
Contributor Author

ubhattacharjya commented Feb 1, 2019

Are we deprecating the existing ContainerDependency model and moving to DependsOn ?

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)
}
Copy link
Contributor

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.

@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch 4 times, most recently from 6f5be32 to 57de8d1 Compare February 4, 2019 21:35
@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch 2 times, most recently from 93bba69 to fe31655 Compare February 4, 2019 21:51
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 {
Copy link
Contributor

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.

linkName := linkParts[0]
if _, ok := task.ContainerByName(linkName); !ok {
return fmt.Errorf("could not find container with name %s", linkName)
} else {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@adnxn
Copy link
Contributor

adnxn commented Feb 4, 2019

also - are you expecting all tests to be passing right now?

@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch from fe31655 to 246ab82 Compare February 4, 2019 22:33
@ubhattacharjya
Copy link
Contributor Author

also - are you expecting all tests to be passing right now?

The tests should pass. As I have not touched any existing logic

@ubhattacharjya ubhattacharjya force-pushed the ContainerOrderingVolumesLinksAgain branch from 246ab82 to 08567bb Compare February 5, 2019 01:04
@adnxn
Copy link
Contributor

adnxn commented Feb 6, 2019

is this the same windows integ test that @sharanyad references here? #1833 (comment)

@ubhattacharjya
Copy link
Contributor Author

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.

Copy link
Contributor

@adnxn adnxn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ubhattacharjya ubhattacharjya merged commit 5fbfab0 into aws:container-ordering-feature Feb 7, 2019
@ubhattacharjya ubhattacharjya deleted the ContainerOrderingVolumesLinksAgain branch April 8, 2019 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants