You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by he...@apache.org on 2019/11/15 19:05:00 UTC

[geode-benchmarks] branch develop updated: retry creating the security group (#116)

This is an automated email from the ASF dual-hosted git repository.

heybales pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git


The following commit(s) were added to refs/heads/develop by this push:
     new e10430b  retry creating the security group (#116)
e10430b is described below

commit e10430bb7fa895c4948be331a3d4f133e7b8fac7
Author: Helena Bales <hb...@pivotal.io>
AuthorDate: Fri Nov 15 11:04:50 2019 -0800

    retry creating the security group (#116)
    
    retry creating the security group
---
 .../geode/infrastructure/aws/LaunchCluster.java    | 60 ++++++++++++----------
 1 file changed, 33 insertions(+), 27 deletions(-)

diff --git a/infrastructure/src/main/java/org/apache/geode/infrastructure/aws/LaunchCluster.java b/infrastructure/src/main/java/org/apache/geode/infrastructure/aws/LaunchCluster.java
index 879178d..d6c7fbf 100644
--- a/infrastructure/src/main/java/org/apache/geode/infrastructure/aws/LaunchCluster.java
+++ b/infrastructure/src/main/java/org/apache/geode/infrastructure/aws/LaunchCluster.java
@@ -72,7 +72,8 @@ import org.apache.geode.infrastructure.BenchmarkMetadata;
 
 public class LaunchCluster {
   private static final long MAX_WAIT_INTERVAL = 2000;
-  private static final int MAX_RETRIES = 5;
+  private static final int MAX_DESCRIBE_RETRIES = 5;
+  private static final int MAX_CREATE_RETRIES = 2;
   static Ec2Client ec2 = Ec2Client.create();
 
   public static void main(String[] args) throws IOException, InterruptedException {
@@ -264,38 +265,43 @@ public class LaunchCluster {
    */
   private static void createSecurityGroup(String benchmarkTag, List<Tag> tags)
       throws InterruptedException {
-    CreateSecurityGroupResponse csgr = ec2.createSecurityGroup(CreateSecurityGroupRequest.builder()
-        .groupName(AwsBenchmarkMetadata.securityGroup(benchmarkTag))
-        .description(AwsBenchmarkMetadata.securityGroup(benchmarkTag))
-        .build());
-
-    String groupId = csgr.groupId();
-    int retries = 0;
-    DescribeSecurityGroupsRequest describeSecurityGroupsRequest =
-        DescribeSecurityGroupsRequest.builder().groupIds(groupId).build();
-    DescribeSecurityGroupsResponse describeSecurityGroupsResponse;
-
-    while (true) {
-      try {
-        describeSecurityGroupsResponse = ec2.describeSecurityGroups(describeSecurityGroupsRequest);
-
-        if (!describeSecurityGroupsResponse.securityGroups().isEmpty()) {
-          System.out.println("SecurityGroup with id '" + groupId
-              + "' is created and visible to subsequent commands.");
-          break;
+    String groupId;
+
+    for (int create_retries = 0;; create_retries++) {
+      CreateSecurityGroupResponse csgr =
+          ec2.createSecurityGroup(CreateSecurityGroupRequest.builder()
+              .groupName(AwsBenchmarkMetadata.securityGroup(benchmarkTag))
+              .description(AwsBenchmarkMetadata.securityGroup(benchmarkTag))
+              .build());
+
+      groupId = csgr.groupId();
+      DescribeSecurityGroupsRequest describeSecurityGroupsRequest =
+          DescribeSecurityGroupsRequest.builder().groupIds(groupId).build();
+      DescribeSecurityGroupsResponse describeSecurityGroupsResponse;
+
+      for (int describe_retries = 0; describe_retries < MAX_DESCRIBE_RETRIES; describe_retries++) {
+        try {
+          describeSecurityGroupsResponse =
+              ec2.describeSecurityGroups(describeSecurityGroupsRequest);
+
+          if (!describeSecurityGroupsResponse.securityGroups().isEmpty()) {
+            System.out.println("TEST SecurityGroup with id '" + groupId
+                + "' is created and visible to subsequent commands.");
+            ec2.createTags(CreateTagsRequest.builder().resources(groupId).tags(tags).build());
+            System.out.println("Security Group for cluster '" + benchmarkTag + "' created.");
+            return;
+          }
+        } catch (Ec2Exception e) {
+          System.out.println(e.getMessage());
+          // will retry or return from the method
         }
-      } catch (Ec2Exception e) {
-        System.out.println(e.getMessage());
-        // will retry or return from the method
+        Thread.sleep(Math.min(getWaitTimeExp(describe_retries), MAX_WAIT_INTERVAL));
       }
-      if (++retries >= MAX_RETRIES) {
+      if (create_retries == (MAX_CREATE_RETRIES - 1)) {
         throw new RuntimeException("Security Group with id '" + groupId
             + "' was not created or is invisible to subsequent commands.");
       }
-      Thread.sleep(Math.min(getWaitTimeExp(retries), MAX_WAIT_INTERVAL));
     }
-    ec2.createTags(CreateTagsRequest.builder().resources(groupId).tags(tags).build());
-    System.out.println("Security Group for cluster '" + benchmarkTag + "' created.");
   }
 
   /*