Search in sources :

Example 1 with OperationInProgressException

use of com.amazonaws.services.cloudformation.model.OperationInProgressException in project pipeline-aws-plugin by jenkinsci.

the class CloudFormationStackSet method doUpdate.

private UpdateStackSetResult doUpdate(UpdateStackSetRequest req, int attempt) throws InterruptedException {
    try {
        this.listener.getLogger().format("Attempting to update CloudFormation stack set %s %n", this.stackSet);
        UpdateStackSetResult result = this.client.updateStackSet(req);
        this.listener.getLogger().format("Updated CloudFormation stack set %s %n", this.stackSet);
        return result;
    } catch (OperationInProgressException | StaleRequestException e) {
        if (attempt == MAX_STACK_SET_RETRY_ATTEMPT_COUNT) {
            this.listener.getLogger().format("Retries exhausted and cloudformation stack set %s is still busy%n", this.stackSet);
            throw e;
        } else {
            long sleepDuration = this.sleepStrategy.calculateSleepDuration(attempt);
            this.listener.getLogger().format("StackSet %s busy. Waiting %d ms %n", this.stackSet, sleepDuration);
            Thread.sleep(sleepDuration);
            return doUpdate(req, attempt + 1);
        }
    } catch (LimitExceededException lee) {
        if (lee.getMessage().startsWith("StackSet operations cannot involve more than")) {
            if (attempt == MAX_STACK_SET_RETRY_ATTEMPT_COUNT) {
                this.listener.getLogger().format("Retries exhausted and cloudformation stack set operations %s is still busy%n", this.stackSet);
                throw lee;
            } else {
                long sleepDuration = this.sleepStrategy.calculateSleepDuration(attempt);
                this.listener.getLogger().format("Too many concurrent operations in progress (%s). Waiting for %s update. Waiting %d ms %n", lee.getMessage(), this.stackSet, sleepDuration);
                Thread.sleep(sleepDuration);
                return doUpdate(req, attempt + 1);
            }
        } else {
            throw lee;
        }
    }
}
Also used : UpdateStackSetResult(com.amazonaws.services.cloudformation.model.UpdateStackSetResult) StaleRequestException(com.amazonaws.services.cloudformation.model.StaleRequestException) LimitExceededException(com.amazonaws.services.cloudformation.model.LimitExceededException) OperationInProgressException(com.amazonaws.services.cloudformation.model.OperationInProgressException)

Aggregations

LimitExceededException (com.amazonaws.services.cloudformation.model.LimitExceededException)1 OperationInProgressException (com.amazonaws.services.cloudformation.model.OperationInProgressException)1 StaleRequestException (com.amazonaws.services.cloudformation.model.StaleRequestException)1 UpdateStackSetResult (com.amazonaws.services.cloudformation.model.UpdateStackSetResult)1