-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from ExpediaDotCom/fix_rate_limit_issue6
Fix "Rate exceeded" issues for large clusters
- Loading branch information
Showing
43 changed files
with
4,741 additions
and
971 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
## UI | ||
* Menubar with: | ||
* Selectable Region | ||
* Selectable AWS account – requires ability for mutliple config files server side | ||
* Show clusters as tabbed view with one cluster per tab | ||
* Add toggle button to switch between memory vs CPU resourceType | ||
* Show an exploded view of task with more details when hovering over tasks: | ||
* Show containers within tasks | ||
* Show memory breakdown across containers | ||
* Sliding timebar to see historical data for comparison (like google street view) | ||
* Show container actual memory utilisation vs reserved memory utilisation | ||
* Provide access to more troubleshooting information (such as docker logs, ECS logs) | ||
* Add footer with fetched/expiry timestamp, #instances/services/tasks, Average CPU/Memory Reservation | ||
|
||
## Server | ||
* Write a plugin system that lets adopters plugin their own statistics from favourite monitoring tool | ||
* Pluggable backend system that could support other public or private cloud providers | ||
* Provide access to more troubleshooting information (such as docker logs, ECS logs) | ||
* Cache responses server-side to reduce AWS API calls | ||
* Make the data transfer between client and server more efficient - Separate requests for task and instance data and populate graph asynchronously | ||
* Return instances with FETCHED_INSTANCES FetchStatus to allow client to draw instances outline until tasks retrieved asynchronously | ||
* Arrow functions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions | ||
* Testing | ||
|
||
|
||
|
||
## Testing | ||
* Capture ECS JSON responses for testing and replay with mock AWS ECS server | ||
* https://fbflex.wordpress.com/2013/11/18/mocking-out-amazon-aws-sdk-with-the-betamax-recording-proxy-for-testing/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const lodash = require('lodash'); | ||
const TARGET_ENV = process.env.TARGET_ENV || 'dev'; | ||
|
||
function _loadDefaultConfig() { | ||
return require('./defaults.js'); | ||
} | ||
|
||
function _loadOverrideConfig(targetEnvironment) { | ||
try { | ||
// Extend configuration with environment-specific configuration | ||
console.debug(`Overriding default configuration with '${targetEnvironment}' environment configuration from ${_overrideConfigFilename(targetEnvironment)} (TARGET_ENV=${process.env.TARGET_ENV}, NODE_ENV=${process.env.NODE_ENV})`); | ||
return require(_overrideConfigFilename(targetEnvironment)); | ||
} catch (err) { | ||
console.error(`ERROR: Could not load configuration file for target environment '${targetEnvironment}'. Skipping. (${err})`); | ||
return {} | ||
} | ||
} | ||
|
||
function _overrideConfigFilename(targetEnvironment) { | ||
return `./env/${targetEnvironment}.js`; | ||
} | ||
|
||
module.exports = lodash.merge(_loadDefaultConfig(), _loadOverrideConfig(TARGET_ENV)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
environmentName: undefined, | ||
port: process.env.PORT || 3000, | ||
clusterStateCacheTtl: 30 * 60 * 1000, // Invalidate clusters in cache after 30 minutes | ||
aws: { | ||
configFile: './aws_config.json', | ||
apiDelay: 100, // milliseconds to pause between AWS API calls to prevent API rate limiting | ||
listInstancesPageSize: 100, // max 100 | ||
describeInstancesPageSize: 100, // max 100 | ||
listTasksPageSize: 100, // max 100 | ||
describeTasksPageSize: 100, // max 100 | ||
maxSimultaneousDescribeTasksCalls: 2, | ||
maxSimultaneousDescribeTaskDefinitionCalls: 1, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
// Add dev environment config overrides here and enable at startup with TARGET_ENV=dev environment variable | ||
environmentName: "Development" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
// Add prod environment config overrides here and enable at startup with TARGET_ENV=prod environment variable | ||
environmentName: "Production" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
// Add test environment config overrides here and enable at startup with TARGET_ENV=test environment variable | ||
environmentName: "Test" | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Configuring AWS SDK | ||
|
||
The c3vis server uses the AWS JavaScript SDK to connect to AWS APIs. | ||
|
||
As per [Configuring the SDK for JavaScript](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/configuring-the-jssdk.html), the AWS JavaScript SDK will get its configuration from the server's environment. | ||
|
||
## Provide Explicit AWS SDK Configuration with `aws_config.json` Configuration File | ||
|
||
AWS SDK configuration can be overridden by providing an `aws_config.json` file (this file location is overridable with `aws.configFile` option, see [CONFIGURATION.md](CONFIGURATION.md)). | ||
|
||
E.g. to set the region used by c3vis server to `us-east-1`, create an `aws_config.json` file in the root directory with the following: | ||
|
||
``` | ||
{ | ||
"region": "us-east-1" | ||
} | ||
``` | ||
|
||
The contents of this file override all other sources of AWS SDK configuration. | ||
The settings are applied to the AWS Global Configuration Object using `AWS.config.update()` as per [Using the Global Configuration Object](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/global-config-object.html) | ||
|
||
## AWS Region | ||
|
||
As per above section, AWS Region can be provided in local `aws_config.json` file. | ||
|
||
Otherwise the Region will be configured as per [Setting the AWS Region](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html). | ||
|
||
## AWS Credentials | ||
|
||
If using `aws_config.json` file as per above section, you can add AWS credentials properties `accessKeyId` and `secretAccessKey` to the `aws_config.json` | ||
See [https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-json-file.html](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-json-file.html). | ||
|
||
*NOTE: Storing credentials in plaintext file is not recommended, especially if there is a risk this file could be committed to version control.* | ||
|
||
Otherwise, the credentials will be loaded as per priority listed [here](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html). | ||
|
||
## IAM Role Permissions | ||
|
||
### EC2 IAM Role Permissions | ||
|
||
When running c3vis on EC2 instances using an IAM role, ensure the role has the | ||
following permissions: | ||
|
||
* `ecs:listContainerInstances` | ||
* `ecs:describeContainerInstances` | ||
* `ecs:listTasks` | ||
* `ecs:describeTasks` | ||
* `ecs:describeTaskDefinition` | ||
* `ecs:listClusters` | ||
* `ec2:describeInstance` | ||
|
||
Sample IAM Inline Policy: | ||
``` | ||
{ | ||
"Version": "2012-10-17", | ||
"Statement": [ | ||
{ | ||
"Effect": "Allow", | ||
"Action": [ | ||
"ecs:listContainerInstances", | ||
"ecs:describeContainerInstances", | ||
"ecs:listTasks", | ||
"ecs:describeTasks", | ||
"ecs:describeTaskDefinition", | ||
"ecs:listClusters", | ||
"ec2:describeInstances" | ||
], | ||
"Resource": [ | ||
"*" | ||
] | ||
} | ||
] | ||
} | ||
``` | ||
|
||
### ECS IAM Task Role | ||
|
||
When running c3vis on an ECS cluster, you can use an ECS Task IAM Role, which | ||
can be created using the process documented [here](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html#create_task_iam_policy_and_role). | ||
Ensure the IAM Policy has the permissions listed above. | ||
|
||
## Security Warning | ||
|
||
**WARNING:** c3vis makes ECS data from the above API calls (including environment variables in task definitions) available to clients/browsers. | ||
Ensure the c3vis server is available only to users that should have access to this information. |
Oops, something went wrong.