Skip to content

Commit cb11bbf

Browse files
author
awstools
committed
feat(client-synthetics): Add support to retry a canary automatically after schedule run failures. Users can enable this feature by configuring the RetryConfig field when calling the CreateCanary or UpdateCanary API. Also includes changes in GetCanary and GetCanaryRuns to support retrieving retry configurations.
1 parent bc861dd commit cb11bbf

File tree

9 files changed

+175
-5
lines changed

9 files changed

+175
-5
lines changed

clients/client-synthetics/src/commands/CreateCanaryCommand.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export interface CreateCanaryCommandOutput extends CreateCanaryResponse, __Metad
6262
* Schedule: { // CanaryScheduleInput
6363
* Expression: "STRING_VALUE", // required
6464
* DurationInSeconds: Number("long"),
65+
* RetryConfig: { // RetryConfigInput
66+
* MaxRetries: Number("int"), // required
67+
* },
6568
* },
6669
* RunConfig: { // CanaryRunConfigInput
6770
* TimeoutInSeconds: Number("int"),
@@ -111,6 +114,9 @@ export interface CreateCanaryCommandOutput extends CreateCanaryResponse, __Metad
111114
* // Schedule: { // CanaryScheduleOutput
112115
* // Expression: "STRING_VALUE",
113116
* // DurationInSeconds: Number("long"),
117+
* // RetryConfig: { // RetryConfigOutput
118+
* // MaxRetries: Number("int"),
119+
* // },
114120
* // },
115121
* // RunConfig: { // CanaryRunConfigOutput
116122
* // TimeoutInSeconds: Number("int"),

clients/client-synthetics/src/commands/DescribeCanariesCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ export interface DescribeCanariesCommandOutput extends DescribeCanariesResponse,
6666
* // Schedule: { // CanaryScheduleOutput
6767
* // Expression: "STRING_VALUE",
6868
* // DurationInSeconds: Number("long"),
69+
* // RetryConfig: { // RetryConfigOutput
70+
* // MaxRetries: Number("int"),
71+
* // },
6972
* // },
7073
* // RunConfig: { // CanaryRunConfigOutput
7174
* // TimeoutInSeconds: Number("int"),

clients/client-synthetics/src/commands/DescribeCanariesLastRunCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ export interface DescribeCanariesLastRunCommandOutput extends DescribeCanariesLa
5858
* // CanaryName: "STRING_VALUE",
5959
* // LastRun: { // CanaryRun
6060
* // Id: "STRING_VALUE",
61+
* // ScheduledRunId: "STRING_VALUE",
62+
* // RetryAttempt: Number("int"),
6163
* // Name: "STRING_VALUE",
6264
* // Status: { // CanaryRunStatus
6365
* // State: "RUNNING" || "PASSED" || "FAILED",
@@ -67,6 +69,7 @@ export interface DescribeCanariesLastRunCommandOutput extends DescribeCanariesLa
6769
* // Timeline: { // CanaryRunTimeline
6870
* // Started: new Date("TIMESTAMP"),
6971
* // Completed: new Date("TIMESTAMP"),
72+
* // MetricTimestampForRunAndRetries: new Date("TIMESTAMP"),
7073
* // },
7174
* // ArtifactS3Location: "STRING_VALUE",
7275
* // DryRunConfig: { // CanaryDryRunConfigOutput

clients/client-synthetics/src/commands/GetCanaryCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ export interface GetCanaryCommandOutput extends GetCanaryResponse, __MetadataBea
5555
* // Schedule: { // CanaryScheduleOutput
5656
* // Expression: "STRING_VALUE",
5757
* // DurationInSeconds: Number("long"),
58+
* // RetryConfig: { // RetryConfigOutput
59+
* // MaxRetries: Number("int"),
60+
* // },
5861
* // },
5962
* // RunConfig: { // CanaryRunConfigOutput
6063
* // TimeoutInSeconds: Number("int"),

clients/client-synthetics/src/commands/GetCanaryRunsCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export interface GetCanaryRunsCommandOutput extends GetCanaryRunsResponse, __Met
4848
* // CanaryRuns: [ // CanaryRuns
4949
* // { // CanaryRun
5050
* // Id: "STRING_VALUE",
51+
* // ScheduledRunId: "STRING_VALUE",
52+
* // RetryAttempt: Number("int"),
5153
* // Name: "STRING_VALUE",
5254
* // Status: { // CanaryRunStatus
5355
* // State: "RUNNING" || "PASSED" || "FAILED",
@@ -57,6 +59,7 @@ export interface GetCanaryRunsCommandOutput extends GetCanaryRunsResponse, __Met
5759
* // Timeline: { // CanaryRunTimeline
5860
* // Started: new Date("TIMESTAMP"),
5961
* // Completed: new Date("TIMESTAMP"),
62+
* // MetricTimestampForRunAndRetries: new Date("TIMESTAMP"),
6063
* // },
6164
* // ArtifactS3Location: "STRING_VALUE",
6265
* // DryRunConfig: { // CanaryDryRunConfigOutput

clients/client-synthetics/src/commands/UpdateCanaryCommand.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ export interface UpdateCanaryCommandOutput extends UpdateCanaryResponse, __Metad
5656
* Schedule: { // CanaryScheduleInput
5757
* Expression: "STRING_VALUE", // required
5858
* DurationInSeconds: Number("long"),
59+
* RetryConfig: { // RetryConfigInput
60+
* MaxRetries: Number("int"), // required
61+
* },
5962
* },
6063
* RunConfig: { // CanaryRunConfigInput
6164
* TimeoutInSeconds: Number("int"),

clients/client-synthetics/src/models/models_0.ts

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,18 @@ export interface CanaryRunConfigOutput {
355355
ActiveTracing?: boolean | undefined;
356356
}
357357

358+
/**
359+
* <p>This structure contains information about the canary's retry configuration.</p>
360+
* @public
361+
*/
362+
export interface RetryConfigOutput {
363+
/**
364+
* <p>The maximum number of retries. The value must be less than or equal to 2.</p>
365+
* @public
366+
*/
367+
MaxRetries?: number | undefined;
368+
}
369+
358370
/**
359371
* <p>How long, in seconds, for the canary to continue making regular runs according to the schedule in the
360372
* <code>Expression</code> value.</p>
@@ -387,6 +399,12 @@ export interface CanaryScheduleOutput {
387399
* @public
388400
*/
389401
DurationInSeconds?: number | undefined;
402+
403+
/**
404+
* <p>A structure that contains the retry configuration for a canary</p>
405+
* @public
406+
*/
407+
RetryConfig?: RetryConfigOutput | undefined;
390408
}
391409

392410
/**
@@ -446,13 +464,13 @@ export interface CanaryStatus {
446464
State?: CanaryState | undefined;
447465

448466
/**
449-
* <p>If the canary has insufficient permissions to run, this field provides more details.</p>
467+
* <p>If the canary creation or update failed, this field provides details on the failure.</p>
450468
* @public
451469
*/
452470
StateReason?: string | undefined;
453471

454472
/**
455-
* <p>If the canary cannot run or has failed, this field displays the reason.</p>
473+
* <p>If the canary creation or update failed, this field displays the reason code.</p>
456474
* @public
457475
*/
458476
StateReasonCode?: CanaryStateReasonCode | undefined;
@@ -769,6 +787,12 @@ export interface CanaryRunTimeline {
769787
* @public
770788
*/
771789
Completed?: Date | undefined;
790+
791+
/**
792+
* <p>The time at which the metrics will be generated for this run or retries.</p>
793+
* @public
794+
*/
795+
MetricTimestampForRunAndRetries?: Date | undefined;
772796
}
773797

774798
/**
@@ -782,6 +806,18 @@ export interface CanaryRun {
782806
*/
783807
Id?: string | undefined;
784808

809+
/**
810+
* <p>The ID of the scheduled canary run.</p>
811+
* @public
812+
*/
813+
ScheduledRunId?: string | undefined;
814+
815+
/**
816+
* <p>The count in number of the retry attempt.</p>
817+
* @public
818+
*/
819+
RetryAttempt?: number | undefined;
820+
785821
/**
786822
* <p>The name of the canary.</p>
787823
* @public
@@ -958,6 +994,25 @@ export interface CanaryRunConfigInput {
958994
EnvironmentVariables?: Record<string, string> | undefined;
959995
}
960996

997+
/**
998+
* <p>This structure contains information about the canary's retry configuration.</p>
999+
* <note>
1000+
* <p>The default account level concurrent execution limit from Lambda is 1000. When you have more than 1000 canaries, it's possible there are more than 1000 Lambda invocations due to retries and the console might hang. For more information on the Lambda execution limit,
1001+
* see <a href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html#:~:text=As%20your%20functions%20receive%20more,functions%20in%20an%20AWS%20Region">Understanding Lambda function scaling</a>.</p>
1002+
* </note>
1003+
* <note>
1004+
* <p>For canary with <code>MaxRetries = 2</code>, you need to set the <code>CanaryRunConfigInput.TimeoutInSeconds</code> to less than 600 seconds to avoid validation errors.</p>
1005+
* </note>
1006+
* @public
1007+
*/
1008+
export interface RetryConfigInput {
1009+
/**
1010+
* <p>The maximum number of retries. The value must be less than or equal to 2.</p>
1011+
* @public
1012+
*/
1013+
MaxRetries: number | undefined;
1014+
}
1015+
9611016
/**
9621017
* <p>This structure specifies how often a canary is to make runs and the date and time
9631018
* when it should stop making runs.</p>
@@ -990,6 +1045,12 @@ export interface CanaryScheduleInput {
9901045
* @public
9911046
*/
9921047
DurationInSeconds?: number | undefined;
1048+
1049+
/**
1050+
* <p>A structure that contains the retry configuration for a canary</p>
1051+
* @public
1052+
*/
1053+
RetryConfig?: RetryConfigInput | undefined;
9931054
}
9941055

9951056
/**
@@ -1622,6 +1683,9 @@ export interface GetCanaryRunsRequest {
16221683
* <p>A token that indicates that there is more data
16231684
* available. You can use this token in a subsequent <code>GetCanaryRuns</code> operation to retrieve the next
16241685
* set of results.</p>
1686+
* <note>
1687+
* <p>When auto retry is enabled for the canary, the first subsequent retry is suffixed with *1 indicating its the first retry and the next subsequent try is suffixed with *2.</p>
1688+
* </note>
16251689
* @public
16261690
*/
16271691
NextToken?: string | undefined;

clients/client-synthetics/src/protocols/Aws_restJson1.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ import {
8282
RequestEntityTooLargeException,
8383
ResourceNotFoundException,
8484
ResourceToTag,
85+
RetryConfigInput,
8586
RuntimeVersion,
8687
S3EncryptionConfig,
8788
ServiceQuotaExceededException,
@@ -1320,6 +1321,8 @@ const se_CanaryCodeInput = (input: CanaryCodeInput, context: __SerdeContext): an
13201321

13211322
// se_ResourceList omitted.
13221323

1324+
// se_RetryConfigInput omitted.
1325+
13231326
// se_S3EncryptionConfig omitted.
13241327

13251328
// se_SecurityGroupIds omitted.
@@ -1414,6 +1417,8 @@ const de_CanaryRun = (output: any, context: __SerdeContext): CanaryRun => {
14141417
DryRunConfig: _json,
14151418
Id: __expectString,
14161419
Name: __expectString,
1420+
RetryAttempt: __expectInt32,
1421+
ScheduledRunId: __expectString,
14171422
Status: _json,
14181423
Timeline: (_: any) => de_CanaryRunTimeline(_, context),
14191424
}) as any;
@@ -1441,6 +1446,7 @@ const de_CanaryRuns = (output: any, context: __SerdeContext): CanaryRun[] => {
14411446
const de_CanaryRunTimeline = (output: any, context: __SerdeContext): CanaryRunTimeline => {
14421447
return take(output, {
14431448
Completed: (_: any) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
1449+
MetricTimestampForRunAndRetries: (_: any) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
14441450
Started: (_: any) => __expectNonNull(__parseEpochTimestamp(__expectNumber(_))),
14451451
}) as any;
14461452
};
@@ -1481,6 +1487,8 @@ const de_Group = (output: any, context: __SerdeContext): Group => {
14811487

14821488
// de_GroupSummaryList omitted.
14831489

1490+
// de_RetryConfigOutput omitted.
1491+
14841492
/**
14851493
* deserializeAws_restJson1RuntimeVersion
14861494
*/

codegen/sdk-codegen/aws-models/synthetics.json

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,18 @@
448448
"smithy.api#documentation": "<p>A unique ID that identifies this canary run.</p>"
449449
}
450450
},
451+
"ScheduledRunId": {
452+
"target": "com.amazonaws.synthetics#UUID",
453+
"traits": {
454+
"smithy.api#documentation": "<p>The ID of the scheduled canary run.</p>"
455+
}
456+
},
457+
"RetryAttempt": {
458+
"target": "com.amazonaws.synthetics#RetryAttempt",
459+
"traits": {
460+
"smithy.api#documentation": "<p>The count in number of the retry attempt.</p>"
461+
}
462+
},
451463
"Name": {
452464
"target": "com.amazonaws.synthetics#CanaryName",
453465
"traits": {
@@ -621,6 +633,12 @@
621633
"traits": {
622634
"smithy.api#documentation": "<p>The end time of the run.</p>"
623635
}
636+
},
637+
"MetricTimestampForRunAndRetries": {
638+
"target": "com.amazonaws.synthetics#Timestamp",
639+
"traits": {
640+
"smithy.api#documentation": "<p>The time at which the metrics will be generated for this run or retries.</p>"
641+
}
624642
}
625643
},
626644
"traits": {
@@ -648,6 +666,12 @@
648666
"traits": {
649667
"smithy.api#documentation": "<p>How long, in seconds, for the canary to continue making regular runs according to\n the schedule in the <code>Expression</code> value. If you specify 0, the canary continues\n making runs until you stop it. If you omit this field, the default of 0 is used.</p>"
650668
}
669+
},
670+
"RetryConfig": {
671+
"target": "com.amazonaws.synthetics#RetryConfigInput",
672+
"traits": {
673+
"smithy.api#documentation": "<p>A structure that contains the retry configuration for a canary</p>"
674+
}
651675
}
652676
},
653677
"traits": {
@@ -668,6 +692,12 @@
668692
"traits": {
669693
"smithy.api#documentation": "<p>How long, in seconds, for the canary to continue making regular runs after it \n was created. The runs are performed according to the schedule in the \n <code>Expression</code> value.</p>"
670694
}
695+
},
696+
"RetryConfig": {
697+
"target": "com.amazonaws.synthetics#RetryConfigOutput",
698+
"traits": {
699+
"smithy.api#documentation": "<p>A structure that contains the retry configuration for a canary</p>"
700+
}
671701
}
672702
},
673703
"traits": {
@@ -822,13 +852,13 @@
822852
"StateReason": {
823853
"target": "com.amazonaws.synthetics#String",
824854
"traits": {
825-
"smithy.api#documentation": "<p>If the canary has insufficient permissions to run, this field provides more details.</p>"
855+
"smithy.api#documentation": "<p>If the canary creation or update failed, this field provides details on the failure.</p>"
826856
}
827857
},
828858
"StateReasonCode": {
829859
"target": "com.amazonaws.synthetics#CanaryStateReasonCode",
830860
"traits": {
831-
"smithy.api#documentation": "<p>If the canary cannot run or has failed, this field displays the reason.</p>"
861+
"smithy.api#documentation": "<p>If the canary creation or update failed, this field displays the reason code.</p>"
832862
}
833863
}
834864
},
@@ -1697,7 +1727,7 @@
16971727
"NextToken": {
16981728
"target": "com.amazonaws.synthetics#Token",
16991729
"traits": {
1700-
"smithy.api#documentation": "<p>A token that indicates that there is more data\n available. You can use this token in a subsequent <code>GetCanaryRuns</code> operation to retrieve the next \n set of results.</p>"
1730+
"smithy.api#documentation": "<p>A token that indicates that there is more data\n available. You can use this token in a subsequent <code>GetCanaryRuns</code> operation to retrieve the next \n set of results.</p>\n <note>\n <p>When auto retry is enabled for the canary, the first subsequent retry is suffixed with *1 indicating its the first retry and the next subsequent try is suffixed with *2.</p>\n </note>"
17011731
}
17021732
},
17031733
"MaxResults": {
@@ -2279,6 +2309,15 @@
22792309
}
22802310
}
22812311
},
2312+
"com.amazonaws.synthetics#MaxRetries": {
2313+
"type": "integer",
2314+
"traits": {
2315+
"smithy.api#range": {
2316+
"min": 0,
2317+
"max": 2
2318+
}
2319+
}
2320+
},
22822321
"com.amazonaws.synthetics#MaxSize100": {
22832322
"type": "integer",
22842323
"traits": {
@@ -2408,6 +2447,44 @@
24082447
}
24092448
}
24102449
},
2450+
"com.amazonaws.synthetics#RetryAttempt": {
2451+
"type": "integer",
2452+
"traits": {
2453+
"smithy.api#range": {
2454+
"min": 1,
2455+
"max": 2
2456+
}
2457+
}
2458+
},
2459+
"com.amazonaws.synthetics#RetryConfigInput": {
2460+
"type": "structure",
2461+
"members": {
2462+
"MaxRetries": {
2463+
"target": "com.amazonaws.synthetics#MaxRetries",
2464+
"traits": {
2465+
"smithy.api#documentation": "<p>The maximum number of retries. The value must be less than or equal to 2.</p>",
2466+
"smithy.api#required": {}
2467+
}
2468+
}
2469+
},
2470+
"traits": {
2471+
"smithy.api#documentation": "<p>This structure contains information about the canary's retry configuration.</p>\n <note>\n <p>The default account level concurrent execution limit from Lambda is 1000. When you have more than 1000 canaries, it's possible there are more than 1000 Lambda invocations due to retries and the console might hang. For more information on the Lambda execution limit, \n see <a href=\"https://docs.aws.amazon.com/lambda/latest/dg/lambda-concurrency.html#:~:text=As%20your%20functions%20receive%20more,functions%20in%20an%20AWS%20Region\">Understanding Lambda function scaling</a>.</p>\n </note>\n <note>\n <p>For canary with <code>MaxRetries = 2</code>, you need to set the <code>CanaryRunConfigInput.TimeoutInSeconds</code> to less than 600 seconds to avoid validation errors.</p>\n </note>"
2472+
}
2473+
},
2474+
"com.amazonaws.synthetics#RetryConfigOutput": {
2475+
"type": "structure",
2476+
"members": {
2477+
"MaxRetries": {
2478+
"target": "com.amazonaws.synthetics#MaxRetries",
2479+
"traits": {
2480+
"smithy.api#documentation": "<p>The maximum number of retries. The value must be less than or equal to 2.</p>"
2481+
}
2482+
}
2483+
},
2484+
"traits": {
2485+
"smithy.api#documentation": "<p>This structure contains information about the canary's retry configuration.</p>"
2486+
}
2487+
},
24112488
"com.amazonaws.synthetics#RoleArn": {
24122489
"type": "string",
24132490
"traits": {

0 commit comments

Comments
 (0)