Skip to content

Commit

Permalink
#3626 Only save usable AWS instance types
Browse files Browse the repository at this point in the history
Summary:
When initializing AWS provider, all instance type information is saved. This can consume a lot of
time later and cause problems if certain AWS regions change.

Test Plan: Create AWS provider

Reviewers: arnav, ram

Reviewed By: ram

Subscribers: jenkins-bot, yugaware

Differential Revision: https://phabricator.dev.yugabyte.com/D8016
  • Loading branch information
WesleyW committed Mar 3, 2020
1 parent 6a26a60 commit cb0cbd8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
17 changes: 15 additions & 2 deletions managed/src/main/java/com/yugabyte/yw/cloud/AWSInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,12 @@ private void storeInstancePriceComponents(JsonNode productDetailsListJson,
matches(productAttrs, "storage", FilterOp.Contains, "EBS"));
// Make sure it is current generation.
include &= matches(productAttrs, "currentGeneration", FilterOp.Equals, "Yes");
// Make sure tenancy is shared
// Make sure tenancy is shared.
include &= matches(productAttrs, "tenancy", FilterOp.Equals, "Shared");
// Make sure it is the base instance type.
include &= matches(productAttrs, "preInstalledSw", FilterOp.Equals, "NA");
// Make sure instance type is supported.
include &= isInstanceTypeSupported(productAttrs);

if (include) {
JsonNode attributesJson = productDetailsJson.get("attributes");
Expand Down Expand Up @@ -411,8 +415,12 @@ private void parseProductDetailsList(JsonNode productDetailsListJson) {
matches(productAttrs, "storage", FilterOp.Contains, "EBS"));
// Make sure it is current generation.
include &= matches(productAttrs, "currentGeneration", FilterOp.Equals, "Yes");
// Make sure tenancy is shared
// Make sure tenancy is shared.
include &= matches(productAttrs, "tenancy", FilterOp.Equals, "Shared");
// Make sure it is the base instance type.
include &= matches(productAttrs, "preInstalledSw", FilterOp.Equals, "NA");
// Make sure instance type is supported.
include &= isInstanceTypeSupported(productAttrs);

if (!include) {
if (enableVerboseLogging) {
Expand Down Expand Up @@ -605,4 +613,9 @@ private boolean matches(Map<String, String> objAttrs, String name, FilterOp op,
return false;
}
}

private boolean isInstanceTypeSupported(Map<String, String> productAttributes) {
return InstanceType.AWS_INSTANCE_PREFIXES_SUPPORTED.stream().anyMatch(
productAttributes.getOrDefault("instanceType", "")::startsWith);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
public class InstanceType extends Model {
public static final Logger LOG = LoggerFactory.getLogger(InstanceType.class);

static List<String> AWS_INSTANCE_PREFIXES_SUPPORTED = ImmutableList.of("m3.", "c5.", "c4.", "c3.", "i3.");
public static List<String> AWS_INSTANCE_PREFIXES_SUPPORTED = ImmutableList.of(
"m3.", "c5.", "c4.", "c3.", "i3.");

public enum VolumeType {
@EnumValue("EBS")
Expand Down

0 comments on commit cb0cbd8

Please sign in to comment.