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

Attribute checker feature #444

Merged
merged 4 commits into from
Mar 5, 2019
Merged

Attribute checker feature #444

merged 4 commits into from
Mar 5, 2019

Conversation

nithu0115
Copy link
Contributor

@nithu0115 nithu0115 commented Mar 13, 2018

Currently, our console or AWS CLI will throw a random error when RunTask API is called if a Container Instance has a missing Attribute and will not give enough reason on what is missing - "Reason":"Attribute"

This feature will check an compare if a Container Instance(s) has all required attributes to Run a Task and returns missing Attribute.

$ ./ecs-cli attribute-checker --task-def awsvpc-nginx:14 --container-instances "c998e09d-164e-447f-9d29-642ed6cc66a4,6f10952d-7133-4031-aa6b-8035eb449c09" --cluster Prod --region us-east-1
Done, parsing Container Instance "arn:aws:ecs:us-east-1:364336798170:container-instance/c998e09d-164e-447f-9d29-642ed6cc66a4" Attributes
Missing "ecs.capability.execution-role-awslogs" attribute on Container Instance "arn:aws:ecs:us-east-1:364336798170:container-instance/6f10952d-7133-4031-aa6b-8035eb449c09"
Done, parsing Container Instance "arn:aws:ecs:us-east-1:364336798170:container-instance/6f10952d-7133-4031-aa6b-8035eb449c09" Attributes

Error if all required parameters are passed:
$ ./ecs-cli attribute-checker --container-instances "c998e09d-164e-447f-9d29-642ed6cc66a4,6f10952d-7133-4031-aa6b-8035eb449c09" --cluster Prod --region us-east-1
FATA[0000] Error executing 'Attribute Checker': TaskDefinition must be specified with the --task-def flag
$./ecs-cli attribute-checker --task-def awsvpc-nginx:14 --cluster Prod --region us-east-1
FATA[0000] Error executing 'Attribute Checker': ContainerInstance(s) must be specified with the --container-instances flag

@nithu0115 nithu0115 changed the title Attribute checker Attribute checker feature Mar 13, 2018
@nithu0115
Copy link
Contributor Author

Adding @PettitWesley @allisaurus @SoManyHs

@PettitWesley
Copy link
Contributor

@nithu0115 Can you change the command and output to look like this:

$ ecs-cli check-attributes --task-def awsvpc-nginx:14 \
--container-instances c998e09d-164e-447f-9d29-642ed6cc66a4,6f10952d-7133-4031-aa6b-8035eb449c09 \
--cluster Prod --region us-east-1
Container Instance			Missing Attributes
c998e09d-164e-447f-9d29-642ed6cc66a4	ecs.capability.execution-role-awslogs, com.amazonaws.ecs.capability.logging-driver.fluentd
6f10952d-7133-4031-aa6b-8035eb449c09	None

The ecs-cli ps command formats its output as a table, you can look at how the code for it works:

https://github.com/aws/amazon-ecs-cli/blob/master/ecs-cli/modules/cli/compose/container/container.go#L123
https://github.com/aws/amazon-ecs-cli/blob/master/ecs-cli/modules/cli/compose/compose_app.go#L88

@nithu0115
Copy link
Contributor Author

nithu0115 commented Jan 6, 2019

Output as a table:

$ ./ecs-cli check-attributes --cluster Prod \
> --region us-east-1 \
> --task-def Nginx5:12 \
> --container-instances 606893e0-8d1e-4e6c-b8ea-8dd9647f954a,6f10952d-7133-4031-aa6b-8035eb449c09,4b6bf9c3-56af-4f10-a20f-cf45fc4b98ba,4b6bf9c3-56af-4f10-a20f-cf45fc4b98ba
Container Instance                    Missing Attributes
6f10952d-7133-4031-aa6b-8035eb449c09  None
4b6bf9c3-56af-4f10-a20f-cf45fc4b98ba  com.amazonaws.ecs.capability.task-iam-role
606893e0-8d1e-4e6c-b8ea-8dd9647f954a  com.amazonaws.ecs.capability.task-iam-role, com.amazonaws.ecs.capability.logging-driver.awslogs

@nithu0115
Copy link
Contributor Author

@PettitWesley, please take a look at the latest commit.

@nithu0115
Copy link
Contributor Author

"By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license."

@nithu0115 nithu0115 force-pushed the stage branch 2 times, most recently from 930944a to 1a8f128 Compare February 13, 2019 02:16
Copy link
Contributor

@PettitWesley PettitWesley left a comment

Choose a reason for hiding this comment

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

Did some final testing (all results are what I expect):

$ ecs-cli check-attributes --container-instances 28c5abd2-360e-41a0-81d8-0afca2d08d9b,45510138-f24f-47c6-a418-71c46dd51f88,ae66e18e-1d46-47ff-81c5-647f0f1426ce,dffe7f91-8faa-4e00-983b-c58fd279cf6d --cluster practice-cluster --region us-east-2 --task-def fluentd-kinesis
Container Instance                    Missing Attributes
dffe7f91-8faa-4e00-983b-c58fd279cf6d  None
28c5abd2-360e-41a0-81d8-0afca2d08d9b  com.amazonaws.ecs.capability.logging-driver.fluentd
45510138-f24f-47c6-a418-71c46dd51f88  None
ae66e18e-1d46-47ff-81c5-647f0f1426ce  com.amazonaws.ecs.capability.logging-driver.fluentd
$ ecs-cli check-attributes --container-instances 28c5abd2-360e-41a0-81d8-0afca2d08d9b,45510138-f24f-47c6-a418-71c46dd51f88,ae66e18e-1d46-47ff-81c5-647f0f1426ce,dffe7f91-8faa-4e00-983b-c58fd279cf6d --cluster practice-cluster --region us-east-2 --task-def fluentdrouter:3
FATA[0000] Error executing 'Attribute Checker': Failed to Describe TaskDefinition, please check the region/taskDefinition values: ClientException: Unable to describe task definition.
	status code: 400, request id: 3f57aa92-2ffa-11e9-9e15-01d8bc5164b8
$ ecs-cli check-attributes --container-instances 92254393-63a1-4a22-9603-3c9e12167aa1 --cluster mu-environment-acceptance --region us-west-2 --task-def fluentdrouter:3
Container Instance                    Missing Attributes
92254393-63a1-4a22-9603-3c9e12167aa1  com.amazonaws.ecs.capability.logging-driver.aws-fluentd-router
$ ecs-cli check-attributes --container-instances f9084017-b207-4a0f-a14e-4ccc737266d5 --cluster blogpost --region us-west-2 --task-def fluentdrouter:3
Container Instance                    Missing Attributes
f9084017-b207-4a0f-a14e-4ccc737266d5  None
$ ecs-cli check-attributes --container-instances f9084017-b207-4a0f-a14e-4ccc737266d5  --region us-west-2 --task-def fluentdrouter:3
FATA[0000] Error executing 'Attribute Checker': Failed to Describe Container Instances, please check region/containerInstance/cluster values: Failures [{
  Arn: "arn:aws:ecs:us-west-2:144718711470:container-instance/f9084017-b207-4a0f-a14e-4ccc737266d5",
  Reason: "MISSING"
}]

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.

3 participants