in aws-globalaccelerator-listener/src/main/kotlin/software/amazon/globalaccelerator/listener/HandlerCommons.kt [26:61]
fun waitForSynchronizedStep(context: CallbackContext,
model: ResourceModel,
proxy: AmazonWebServicesClientProxy,
agaClient: AWSGlobalAccelerator,
logger: Logger,
isDelete: Boolean = false): ProgressEvent<ResourceModel, CallbackContext?> {
logger.debug("Waiting for accelerator with arn: [${model.acceleratorArn}] to be deployed. " +
"Stabilization retries remaining ${context.stabilizationRetriesRemaining}")
val newCallbackContext = context.copy(stabilizationRetriesRemaining = context.stabilizationRetriesRemaining - 1)
if (newCallbackContext.stabilizationRetriesRemaining < 0) {
throw RuntimeException(TIMED_OUT_MESSAGE)
}
val accelerator = getAccelerator(model.acceleratorArn, proxy, agaClient, logger)
// Addresses race condition: accelerator associated with listener is deleted out-of-band.
// Sequence diagram :: Delete Listener -> (accelerator deleted) -> waiting for accelerator to go-in-sync
// Ignore AcceleratorNotFoundException exception.
if (accelerator == null && isDelete) {
return ProgressEvent.defaultSuccessHandler(null)
}
return if (accelerator!!.status == AcceleratorStatus.DEPLOYED.toString()) {
logger.debug("Accelerator with arn: [${accelerator.acceleratorArn}] is deployed.")
// Delete contract expects no model to be returned upon delete success
var resourceModel: ResourceModel? = model
if (isDelete) {
resourceModel = null
}
ProgressEvent.defaultSuccessHandler(resourceModel)
} else {
ProgressEvent.defaultInProgressHandler(newCallbackContext, CALLBACK_DELAY_IN_SECONDS, model)
}
}