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

fix(toolkit): increase retry count for operations #2053

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/aws-cdk/lib/api/bootstrap-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function bootstrapEnvironment(environment: Environment, aws: SDK, t
environment,
metadata: {},
template: {
Description: "The CDK Toolkit Stack. It cas created by `cdk bootstrap` and manages resources necessary for managing your Cloud Applications with AWS CDK.",
Description: "The CDK Toolkit Stack. It was created by `cdk bootstrap` and manages resources necessary for managing your Cloud Applications with AWS CDK.",
Resources: {
StagingBucket: {
Type: "AWS::S3::Bucket",
Expand Down
18 changes: 18 additions & 0 deletions packages/aws-cdk/lib/api/util/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ export class SDK {
private readonly credentialsCache: CredentialsCache;
private readonly profile?: string;

/**
* Default retry options for SDK clients
*
* Biggest bottleneck is CloudFormation, with a 1tps call rate. We want to be
* a little more tenacious than the defaults, and with a little more breathing
* room between calls (defaults are {retries=3, base=100}).
*
* I've left this running in a tight loop for an hour and the throttle errors
* haven't escaped the retry mechanism.
*/
private readonly retryOptions = { maxRetries: 6, retryDelayOptions: { base: 300 }};

constructor(options: SDKOptions = {}) {
this.profile = options.profile;

Expand Down Expand Up @@ -78,41 +90,47 @@ export class SDK {

public async cloudFormation(environment: Environment, mode: Mode): Promise<AWS.CloudFormation> {
return new AWS.CloudFormation({
...this.retryOptions,
region: environment.region,
credentials: await this.credentialsCache.get(environment.account, mode)
});
}

public async ec2(awsAccountId: string | undefined, region: string | undefined, mode: Mode): Promise<AWS.EC2> {
return new AWS.EC2({
...this.retryOptions,
region,
credentials: await this.credentialsCache.get(awsAccountId, mode)
});
}

public async ssm(awsAccountId: string | undefined, region: string | undefined, mode: Mode): Promise<AWS.SSM> {
return new AWS.SSM({
...this.retryOptions,
region,
credentials: await this.credentialsCache.get(awsAccountId, mode)
});
}

public async s3(environment: Environment, mode: Mode): Promise<AWS.S3> {
return new AWS.S3({
...this.retryOptions,
region: environment.region,
credentials: await this.credentialsCache.get(environment.account, mode)
});
}

public async route53(awsAccountId: string | undefined, region: string | undefined, mode: Mode): Promise<AWS.Route53> {
return new AWS.Route53({
...this.retryOptions,
region,
credentials: await this.credentialsCache.get(awsAccountId, mode),
});
}

public async ecr(environment: Environment, mode: Mode): Promise<AWS.ECR> {
return new AWS.ECR({
...this.retryOptions,
region: environment.region,
credentials: await this.credentialsCache.get(environment.account, mode)
});
Expand Down