-
Notifications
You must be signed in to change notification settings - Fork 712
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
Add ECS views #2026
Conversation
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 |
@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:
@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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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. |
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
parent: hostsID, | ||
renderer: render.WeaveRenderer, | ||
Name: "weave net", | ||
HideIfEmpty: true, |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
c <- left.Merge(right) | ||
}(<-c, <-c) | ||
}() |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
||
group := sync.WaitGroup{} | ||
|
||
err := c.client.ListServicesPages( |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
||
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
// 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.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
|
||
for _, failure := range resp.Failures { | ||
// log the failures but still continue with what succeeded |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
return nil, err | ||
} | ||
|
||
results := make(map[string]string) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
if taskArnOk && clusterOk && familyOk { | ||
taskMap, ok := results[cluster] | ||
if !ok { | ||
taskMap = make(map[string]*taskInfo) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
|
||
// 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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
|
||
// Create all the services first | ||
unique := make(map[string]bool) |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
} | ||
|
||
} | ||
|
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -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.
This comment was marked as abuse.
Sorry, something went wrong.
Lots of nits, but nothing major. |
cca42be
to
c6728c6
Compare
(not working yet)
spellcheck and required comments and required comment formatting
Turns out that when iterating in go, &loop_var is the same address every time
b3ceefc
to
d0caee4
Compare
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. |
LGTM |
@pidster Also signed-off offline |
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:
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:
Unit tests(moved to Add ECS views #2026 )Document required permissions(No need, created Move ECS AMI documentation to Scope website #2039 , see Add ECS views #2026 (comment) for details)app/api_topology.go
)