Skip to content

Commit 3beaf91

Browse files
committed
Merge pull request Netflix#205 from ebukoski/master
Fix warnings, add SimpleDB max retry
2 parents d5bddfd + 70abc6c commit 3beaf91

6 files changed

Lines changed: 29 additions & 22 deletions

File tree

build.gradle

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'nebula.netflixoss' version '2.2.9'
33
id 'net.saliman.cobertura' version '2.2.7'
4+
id 'com.github.hierynomus.license' version '0.11.0'
45
}
56

67
// Establish version and status
@@ -62,8 +63,9 @@ tasks.withType(JavaCompile) {
6263
artifacts {
6364
archives tasks.jar
6465
}
65-
import nl.javadude.gradle.plugins.license.License
66-
tasks.withType(License).each { licenseTask ->
67-
licenseTask.exclude '**/*.json'
68-
licenseTask.exclude '**/*.properties'
66+
67+
license {
68+
exclude '**/*.properties'
69+
exclude '**/*.json'
70+
exclude '**/*.sh'
6971
}

src/main/java/com/netflix/simianarmy/aws/janitor/crawler/edda/EddaEBSVolumeJanitorCrawler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private List<Resource> getVolumeResources(String... volumeIds) {
166166
* Gets all volumes that are not attached to any instance. Janitor Monkey only considers unattached volumes
167167
* as cleanup candidates, so there is no need to get volumes that are in-use.
168168
* @param region
169-
* @return
169+
* @return list of resources that are not attached to any instance
170170
*/
171171
private List<Resource> getUnattachedVolumeResourcesInRegion(String region, String... volumeIds) {
172172
String url = eddaClient.getBaseUrl(region) + "/aws/volumes;";

src/main/java/com/netflix/simianarmy/basic/BasicSimianArmyContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public AWSCredentialsProvider getAwsCredentialsProvider() {
397397
* (Duplicates a method in MonkeyServer; refactor to util?).
398398
*
399399
* @param key
400-
* @return
400+
* @return the loaded class or null if the class is not found
401401
*/
402402
@SuppressWarnings("rawtypes")
403403
private Class loadClientClass(String key) {

src/main/java/com/netflix/simianarmy/client/aws/AWSClient.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,16 @@ public class AWSClient implements CloudClient {
119119
/** The plain name for AWS account */
120120
private final String accountName;
121121

122+
/** Maximum retry count for Simple DB */
123+
private static final int SIMPLE_DB_MAX_RETRY = 11;
124+
122125
private final AWSCredentialsProvider awsCredentialsProvider;
123126

124127
private final ClientConfiguration awsClientConfig;
125128

126129
private ComputeService jcloudsComputeService;
130+
131+
127132

128133
/**
129134
* This constructor will let the AWS SDK obtain the credentials, which will
@@ -220,7 +225,7 @@ public String region() {
220225
/**
221226
* The accountName.
222227
*
223-
* @accountName the plain name for the aws account easier to identify which account
228+
* @return the plain name for the aws account easier to identify which account
224229
* monkey is running in
225230
*/
226231
public String accountName() {
@@ -306,19 +311,19 @@ protected AmazonElasticLoadBalancingClient elbClient() {
306311
*/
307312
public AmazonSimpleDB sdbClient() {
308313
AmazonSimpleDB client;
309-
if (awsClientConfig == null) {
310-
if (awsCredentialsProvider == null) {
311-
client = new AmazonSimpleDBClient();
312-
} else {
313-
client = new AmazonSimpleDBClient(awsCredentialsProvider);
314-
}
314+
ClientConfiguration cc = awsClientConfig;
315+
316+
if (cc == null) {
317+
cc = new ClientConfiguration();
318+
cc.setMaxErrorRetry(SIMPLE_DB_MAX_RETRY);
319+
}
320+
321+
if (awsCredentialsProvider == null) {
322+
client = new AmazonSimpleDBClient(cc);
315323
} else {
316-
if (awsCredentialsProvider == null) {
317-
client = new AmazonSimpleDBClient(awsClientConfig);
318-
} else {
319-
client = new AmazonSimpleDBClient(awsCredentialsProvider, awsClientConfig);
320-
}
324+
client = new AmazonSimpleDBClient(awsCredentialsProvider, cc);
321325
}
326+
322327
// us-east-1 has special naming
323328
// http://docs.amazonwebservices.com/general/latest/gr/rande.html#sdb_region
324329
if (region == null || region.equals("us-east-1")) {
@@ -328,7 +333,7 @@ public AmazonSimpleDB sdbClient() {
328333
}
329334
return client;
330335
}
331-
336+
332337
/**
333338
* Describe auto scaling groups.
334339
*

src/main/java/com/netflix/simianarmy/janitor/AbstractJanitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ public void cleanupResources() {
295295
markedResource.setState(Resource.CleanupState.JANITOR_TERMINATED);
296296
resourceTracker.addOrUpdate(markedResource);
297297
} catch (Exception e) {
298-
LOGGER.error(String.format("Failed to clean up the resource %s.",
299-
markedResource.getId()), e);
298+
LOGGER.error(String.format("Failed to clean up the resource %s of type %s.",
299+
markedResource.getId(), markedResource.getResourceType().name()), e);
300300
failedToCleanResources.add(markedResource);
301301
continue;
302302
}

src/test/java/com/netflix/simianarmy/janitor/TestAbstractJanitor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ public ImmediateCleanupRule(DateTime now) {
570570
@Override
571571
public boolean isValid(Resource resource) {
572572
resource.setExpectedTerminationTime(new Date(now.minusMinutes(10).getMillis()));
573-
resource.setNotificationTime(new Date(now.getMillis()));
573+
resource.setNotificationTime(new Date(now.getMillis()-5000));
574574
return false;
575575
}
576576
}

0 commit comments

Comments
 (0)