fun waitForSynchronizedStep()

in aws-globalaccelerator-endpointgroup/src/main/kotlin/software/amazon/globalaccelerator/endpointgroup/HandlerCommons.kt [30:65]


    fun waitForSynchronizedStep(context: CallbackContext,
                                model: ResourceModel,
                                proxy: AmazonWebServicesClientProxy,
                                agaClient: AWSGlobalAccelerator,
                                logger: Logger,
                                isDelete: Boolean = false): ProgressEvent<ResourceModel, CallbackContext?> {

        val acceleratorArn = ListenerArn(model.listenerArn).acceleratorArn
        logger.debug("Waiting for accelerator with arn: [$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(acceleratorArn, proxy, agaClient, logger)

        // Addresses race condition: accelerator associated with endpointgroup is deleted out-of-band.
        // Sequence diagram :: Delete EndpointGroup -> (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()) {
            // 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)
        }
    }