Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Commit 7a147e5

Browse files
authored
Adding propagation delay to take into account eventual consistency. (#48)
1 parent b56f2be commit 7a147e5

File tree

1 file changed

+9
-0
lines changed
  • aws-codeartifact-repository/src/main/java/software/amazon/codeartifact/repository

1 file changed

+9
-0
lines changed

aws-codeartifact-repository/src/main/java/software/amazon/codeartifact/repository/CreateHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package software.amazon.codeartifact.repository;
22

33
import java.util.Set;
4+
import java.util.concurrent.TimeUnit;
45
import software.amazon.awssdk.awscore.AwsResponse;
56
import software.amazon.awssdk.awscore.exception.AwsServiceException;
67
import software.amazon.awssdk.services.codeartifact.CodeartifactClient;
78
import software.amazon.awssdk.services.codeartifact.model.ResourceNotFoundException;
9+
import software.amazon.cloudformation.exceptions.CfnGeneralServiceException;
810
import software.amazon.cloudformation.exceptions.CfnInvalidRequestException;
911
import software.amazon.cloudformation.proxy.AmazonWebServicesClientProxy;
1012
import software.amazon.cloudformation.proxy.Logger;
@@ -14,6 +16,8 @@
1416

1517

1618
public class CreateHandler extends BaseHandlerStd {
19+
private static final int PROPAGATION_DELAY_S = 10;
20+
private static final long PROPAGATION_DELAY_MS = TimeUnit.SECONDS.toMillis(PROPAGATION_DELAY_S);
1721
private Logger logger;
1822

1923
protected ProgressEvent<ResourceModel, CallbackContext> handleRequest(
@@ -67,6 +71,10 @@ private ProgressEvent<ResourceModel, CallbackContext> createRepository(
6771
AwsResponse awsResponse = null;
6872
try {
6973
awsResponse = client.injectCredentialsAndInvokeV2(awsRequest, client.client()::createRepository);
74+
logger.log(String.format("waiting %s milliseconds for repository to become available", PROPAGATION_DELAY_MS));
75+
Thread.sleep(PROPAGATION_DELAY_MS);
76+
} catch (InterruptedException e) {
77+
throw new CfnGeneralServiceException(e);
7078
} catch (final AwsServiceException e) {
7179
String repositoryName = progress.getResourceModel().getRepositoryName();
7280
Translator.throwCfnException(e, Constants.CREATE_REPOSITORY, repositoryName);
@@ -89,6 +97,7 @@ private boolean isStabilized(
8997
try {
9098
proxyClient.injectCredentialsAndInvokeV2(
9199
Translator.translateToReadRequest(model), proxyClient.client()::describeRepository);
100+
logger.log(String.format("%s successfully stabilized.", ResourceModel.TYPE_NAME));
92101
return true;
93102
} catch (ResourceNotFoundException e) {
94103
return false;

0 commit comments

Comments
 (0)