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

Add blackhole imds route for awsvpc network mode #968

Merged
merged 5 commits into from
Sep 7, 2017

Conversation

aaithal
Copy link
Contributor

@aaithal aaithal commented Sep 6, 2017

Summary

Add AWSVPCBlockInstanceMetdata config (ECS_AWSVPC_BLOCK_IMDS) for blocking access to instance metdata for awsvpc tasks

Implementation details

  • 5e8001c agent/app: register task-eni-block-instance-metadata capability when AWSVPCBlockInstanceMetdata config is enabled
  • 63734d3 agent/ecscni,agent/engine: wire in AWSVPCBlockInstanceMetdata config to CNI config
  • 5f0e4ed agent/config: add AWSVPCBlockInstanceMetdata config for blocking access to instance metdata for awsvpc tasks

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=25s ./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: Yes

Description for the changelog

None

Licensing

This contribution is under the terms of the Apache 2.0 License: Yes

@aaithal aaithal force-pushed the addBlackholeIMDSRoute branch from d6a614f to 820d1bd Compare September 7, 2017 15:26
Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

I think there should be a commit to CHANGELOG.md as well.

@aaithal
Copy link
Contributor Author

aaithal commented Sep 7, 2017

@nmeyerhans I decided not to do a changelog entry as I think this should be covered under 0e782a5. Do you think this warrants an entry by itself?

@@ -124,6 +126,14 @@ func (agent *ecsAgent) capabilities() []*ecs.Attribute {
capabilities = append(capabilities, taskENIVersionAttribute)
}

if agent.cfg.AWSVPCBlockInstanceMetdata {

Choose a reason for hiding this comment

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

You may want to move this above inside the check for TaskENIEnabled since this relies on the awsvpc network mode and cni plugins.

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 thought about and ended up not doing it as it's essentially a nop to do this if Task ENI is not enabled. I'll change it if you insist.

Choose a reason for hiding this comment

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

Move this above makes the logic more clear to me, let's do it, thanks.

README.md Outdated
@@ -177,6 +177,7 @@ configure them as something other than the defaults.
| `ECS_INSTANCE_ATTRIBUTES` | `{"stack": "prod"}` | These attributes take effect only during initial registration. After the agent has joined an ECS cluster, use the PutAttributes API action to add additional attributes. For more information, see [Amazon ECS Container Agent Configuration](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html) in the Amazon ECS Developer Guide.| `{}` | `{}` |
| `ECS_ENABLE_TASK_ENI` | `false` | Whether to enable task networking for task to be launched with its own network interface | `false` | `false` |
| `ECS_CNI_PLUGINS_PATH` | `/ecs/cni` | The path where the cni binary file is located | `/amazon-ecs-cni-plugins` | `/amazon-ecs-cni-plugins` |
| `ECS_AWSVPC_BLOCK_IMDS` | `true` | Whether to block access to Instance Metdata for Tasks started with `awsvpc` network mode | `false` | `false`|

Choose a reason for hiding this comment

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

Do you we need to add a link to the instance metadata here, I'm not sure if all the customers know Instance Metadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can do that.

@@ -380,3 +380,11 @@ func TestImageCleanupMinimumNumImagesToDeletePerCycle(t *testing.T) {
t.Errorf("Wrong value for NumImagesToDeletePerCycle: %v", cfg.NumImagesToDeletePerCycle)
}
}

func TestAWSVPCBlockInstanceMetadata(t *testing.T) {

Choose a reason for hiding this comment

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

Please add a simple comment 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.

Isn't the name itself descriptive?

Choose a reason for hiding this comment

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

Only if I know that this test was in the config package, it will have different meaning in engine package, where the test may be testing the process to block the metadata. Ignore my comments if we are supposed to have the context when reading the code.

Copy link
Contributor

@nmeyerhans nmeyerhans left a comment

Choose a reason for hiding this comment

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

LGTM. Though it'd make me really happy to see more detailed commit messages. https://chris.beams.io/posts/git-commit/ has some examples of good commit messages and explains why they matter.

@aaithal
Copy link
Contributor Author

aaithal commented Sep 7, 2017

@nmeyerhans that'd make me happy as well. I thought the changes here were small enough and didn't need additional context. Let me know if you had any particular commit(s) in mind and I can add some context.

@nmeyerhans
Copy link
Contributor

One thing that'd help the commit messages here is to ensure that the "subject" (first line of the message) is no longer than about 50 characters. When displaying a commit log, Github truncates at 70 characters, so there's a little room to be flexible here, but most of the commits in this PR don't even fit within the 70 character limit. Any context or details that don't fit within ~50 characters should be expanded upon in the "body" of the commit message.

Note for others who might be reading: Do as I say, not as I do. I've certainly pushed some poor commit messages in the past. More recently, though, we've had internal conversations about improving our commit logs, and I'm trying to drive that effort forward...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants