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 ECS views #2026

Merged
merged 19 commits into from
Nov 29, 2016
Merged

Add ECS views #2026

merged 19 commits into from
Nov 29, 2016

Conversation

ekimekim
Copy link
Contributor

@ekimekim ekimekim commented Nov 23, 2016

This PR adds two new ECS-specific topologes, ECSTasks and ECSServices,
and adds a probe which collects info to populate it.

The probe uses the instance's IAM role to look up task and service info. It requires the following permissions:
ListServices
DescribeTasks
DescribeServices

@2opremio: For rendering: I've associated a container with 0 or 1 ECSTasks and ECSServices, under the Node.Parents Sets.
ie. if a container X is associated with task Y and service Z, then rpt.Container.Nodes[X].Parents contains:

{
	"ecstask": [
		"Y;ecstask"
	],
	"ecsservice": [
		"Z;ecsservice"
	]
}

and so any endpoints associated with the container should be assoicated with the given task and service,
so that communication between containers is visible on the tasks view, etc.

TODO:

@2opremio 2opremio removed their assignment Nov 23, 2016
@ekimekim
Copy link
Contributor Author

more testing is needed since my test environment turned out to be flawed (not enough cpu to run app and probe), but apart from the rendering stuff that @2opremio is working on, this should be ready to go

@2opremio
Copy link
Contributor

2opremio commented Nov 24, 2016

@abuehrle We are going to need documentation for this. Showing ECS views on Scope requires adding permissions to the AWS machines in which it runs. See above:

The probe uses the instance's IAM role to look up task and service info. It requires the following permissions:
ListServices
DescribeTasks
DescribeServices

@ekimekim knows the details and can draft/write the requirements but it would be great if you can review it (for Re:Invent which is when we plan to release this)

}(<-c, <-c)
}
return <-c
return *<-c

This comment was marked as abuse.

This comment was marked as abuse.

@ekimekim
Copy link
Contributor Author

Tested with sock shop. No obvious performance regressions after looking at CPU load on master (0.70) vs branch with ECS stuff disabled (0.81) vs branch with ECS stuff enabled (0.79). It's a really, really poor test, but we can discount crazy order-of-magnitude changes.

@2opremio 2opremio mentioned this pull request Nov 28, 2016
@2opremio
Copy link
Contributor

We should probably add a filter for Clusters, pretty much like we do for K8s namespaces.

It is probably not urgent (since a Container Instance can only belong to a cluster) and you can create different organizations for different clusters in Weave Cloud.

@ekimekim Please add the cluster to the metadata (probably to the host instead of the task/service) in order to make this possible.

@@ -90,81 +96,98 @@ func AddInitialTopologiesToRegistry(registry *Registry) {
// be the verb to get to that state
registry.Add(
APITopologyDesc{
id: processesTopologyDescID,
id: processesID,

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

parent: hostsID,
renderer: render.WeaveRenderer,
Name: "weave net",
HideIfEmpty: true,

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

c <- left.Merge(right)
}(<-c, <-c)
}()

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.


group := sync.WaitGroup{}

err := c.client.ListServicesPages(

This comment was marked as abuse.

This comment was marked as abuse.

lock.Lock()
for _, service := range resp.Services {
for _, deployment := range service.Deployments {
results[*deployment.Id] = *service.ServiceName

This comment was marked as abuse.

This comment was marked as abuse.


resp, err := c.client.DescribeServices(&ecs.DescribeServicesInput{
Cluster: &c.cluster,
Services: page.ServiceArns,

This comment was marked as abuse.

This comment was marked as abuse.

// returns a map from deployment ids to service names
// cannot fail as it will attempt to deliver partial results, though that may end up being no results
func (c ecsClient) getDeploymentMap() map[string]string {
results := make(map[string]string)

This comment was marked as abuse.

}

for _, failure := range resp.Failures {
// log the failures but still continue with what succeeded

This comment was marked as abuse.

@2opremio
Copy link
Contributor

2opremio commented Nov 28, 2016

Fixes #721

log.Warnf("Failed to describe ECS task %s, ECS service report may be incomplete: %s", failure.Arn, failure.Reason)
}

results := make(map[string]string)

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

return nil, err
}

results := make(map[string]string)

This comment was marked as abuse.

if taskArnOk && clusterOk && familyOk {
taskMap, ok := results[cluster]
if !ok {
taskMap = make(map[string]*taskInfo)

This comment was marked as abuse.

cluster, clusterOk := node.Latest.Lookup(docker.LabelPrefix + "com.amazonaws.ecs.cluster")
family, familyOk := node.Latest.Lookup(docker.LabelPrefix + "com.amazonaws.ecs.task-definition-family")

if taskArnOk && clusterOk && familyOk {

This comment was marked as abuse.

}

// Tag needed for Tagger
func (r Reporter) Tag(rpt report.Report) (report.Report, error) {

This comment was marked as abuse.

This comment was marked as abuse.

taskArns := make([]string, 0, len(taskMap))
for taskArn := range taskMap {
taskArns = append(taskArns, taskArn)
}

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

}

// Create all the services first
unique := make(map[string]bool)

This comment was marked as abuse.

log.Warnf("Got task info for non-existent container %v, this shouldn't be able to happen", containerID)
}
}

This comment was marked as abuse.

}

}

This comment was marked as abuse.

@@ -282,6 +284,9 @@ func main() {
flag.StringVar(&flags.probe.kubernetesConfig.User, "probe.kubernetes.user", "", "The name of the kubeconfig user to use")
flag.StringVar(&flags.probe.kubernetesConfig.Username, "probe.kubernetes.username", "", "Username for basic authentication to the API server")

// AWS ECS
flag.BoolVar(&flags.probe.ecsEnabled, "probe.ecs", false, "collect ecs-related attributes for containers on this node")

This comment was marked as abuse.

@tomwilkie
Copy link
Contributor

Lots of nits, but nothing major.

@errordeveloper
Copy link
Contributor

So you won't see tasks that don't have at least one container running on a probe-monitored instance.

Ah, sure, makes sense with respect to probe's view... Personally, I'd love to see tasks with no scheduled containers, but that'd be a big feature request, and I think I've already filed that as an issue sometime ago in the Kubernetes context or mentioned it elsewhere. Thanks for clarifying, glad we don't have a last minute bug.

@2opremio 2opremio changed the title [WIP] Add ECS topologies Add ECS views Nov 29, 2016
@2opremio
Copy link
Contributor

LGTM

@2opremio
Copy link
Contributor

@pidster Also signed-off offline

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.

5 participants