Skip to content

Commit 98770dd

Browse files
committed
fix: allow disabling smart retries [gh-943]
1 parent ec3a946 commit 98770dd

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

Diff for: packages/cli/src/constructs/check-group.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export interface CheckGroupProps {
110110
/**
111111
* Sets a retry policy for the group. Use RetryStrategyBuilder to create a retry policy.
112112
*/
113-
retryStrategy?: RetryStrategy
113+
retryStrategy?: RetryStrategy | null
114114
/**
115115
* Determines whether the checks in the group should run on all selected locations in parallel or round-robin.
116116
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
@@ -143,7 +143,7 @@ export class CheckGroup extends Construct {
143143
apiCheckDefaults: ApiCheckDefaultConfig
144144
browserChecks?: BrowserCheckConfig
145145
multiStepChecks?: MultiStepCheckConfig
146-
retryStrategy?: RetryStrategy
146+
retryStrategy?: RetryStrategy | null
147147
runParallel?: boolean
148148
alertSettings?: AlertEscalation
149149
useGlobalAlertSettings?: boolean
@@ -163,7 +163,6 @@ export class CheckGroup extends Construct {
163163
this.name = props.name
164164
this.activated = props.activated
165165
this.muted = props.muted
166-
this.doubleCheck = props.doubleCheck
167166
this.tags = props.tags
168167
this.runtimeId = props.runtimeId
169168
this.locations = props.locations
@@ -185,6 +184,11 @@ export class CheckGroup extends Construct {
185184
this.alertChannels = props.alertChannels ?? []
186185
this.localSetupScript = props.localSetupScript
187186
this.localTearDownScript = props.localTearDownScript
187+
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
188+
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
189+
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
190+
? false
191+
: props.doubleCheck
188192
this.retryStrategy = props.retryStrategy
189193
this.runParallel = props.runParallel
190194
// `browserChecks` is not a CheckGroup resource property. Not present in synthesize()

Diff for: packages/cli/src/constructs/check.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export interface CheckProps {
9292
/**
9393
* Sets a retry policy for the check. Use RetryStrategyBuilder to create a retry policy.
9494
*/
95-
retryStrategy?: RetryStrategy
95+
retryStrategy?: RetryStrategy | null
9696
/**
9797
* Determines whether the check should run on all selected locations in parallel or round-robin.
9898
* See https://www.checklyhq.com/docs/monitoring/global-locations/ to learn more about scheduling strategies.
@@ -117,7 +117,7 @@ export abstract class Check extends Construct {
117117
groupId?: Ref
118118
alertChannels?: Array<AlertChannel>
119119
testOnly?: boolean
120-
retryStrategy?: RetryStrategy
120+
retryStrategy?: RetryStrategy | null
121121
alertSettings?: AlertEscalation
122122
useGlobalAlertSettings?: boolean
123123
runParallel?: boolean
@@ -135,7 +135,6 @@ export abstract class Check extends Construct {
135135
this.name = props.name
136136
this.activated = props.activated
137137
this.muted = props.muted
138-
this.doubleCheck = props.doubleCheck
139138
this.shouldFail = props.shouldFail
140139
this.locations = props.locations
141140
this.privateLocations = props.privateLocations
@@ -156,6 +155,11 @@ export abstract class Check extends Construct {
156155
// alertSettings, useGlobalAlertSettings, groupId, groupOrder
157156

158157
this.testOnly = props.testOnly ?? false
158+
// When `retryStrategy: null` and `doubleCheck: undefined`, we want to let the user disable all retries.
159+
// The backend has a Joi default of `doubleCheck: true`, though, so we need special handling for this case.
160+
this.doubleCheck = props.doubleCheck === undefined && props.retryStrategy === null
161+
? false
162+
: props.doubleCheck
159163
this.retryStrategy = props.retryStrategy
160164
this.alertSettings = props.alertEscalationPolicy
161165
this.useGlobalAlertSettings = !this.alertSettings

Diff for: packages/cli/src/constructs/retry-strategy.ts

+4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export class RetryStrategyBuilder {
5555
return RetryStrategyBuilder.retryStrategy('EXPONENTIAL', options)
5656
}
5757

58+
static noRetries (): null {
59+
return null
60+
}
61+
5862
private static retryStrategy (type: RetryStrategyType, options?: RetryStrategyOptions): RetryStrategy {
5963
return {
6064
type,

0 commit comments

Comments
 (0)