From 1f6df700a0ba4d632aea18a346677ab9dc859fb8 Mon Sep 17 00:00:00 2001 From: Joshua Guan Date: Fri, 16 Oct 2020 09:00:47 -0500 Subject: [PATCH 1/4] Added logs to debug vmtype availability and validation --- .../cloudbreak/cloud/model/VmType.java | 5 ++- .../cloud/aws/AwsPlatformResources.java | 2 + .../template/TemplateValidator.java | 39 ++++++++++++++----- .../service/StackCommonService.java | 1 + core/src/main/resources/logback.xml | 5 +++ 5 files changed, 42 insertions(+), 10 deletions(-) diff --git a/cloud-api/src/main/java/com/sequenceiq/cloudbreak/cloud/model/VmType.java b/cloud-api/src/main/java/com/sequenceiq/cloudbreak/cloud/model/VmType.java index c464d615510..7d0be29b2f9 100644 --- a/cloud-api/src/main/java/com/sequenceiq/cloudbreak/cloud/model/VmType.java +++ b/cloud-api/src/main/java/com/sequenceiq/cloudbreak/cloud/model/VmType.java @@ -3,6 +3,7 @@ import com.sequenceiq.cloudbreak.cloud.model.generic.StringType; public class VmType extends StringType { + private String vmType; private VmTypeMeta metaData; @@ -16,6 +17,7 @@ private VmType(String vmType, VmTypeMeta meta, Boolean extended) { super(vmType); metaData = meta; this.extended = extended; + this.vmType = vmType; } public static VmType vmType(String vmType) { @@ -53,7 +55,8 @@ public boolean isMetaSet() { @Override public String toString() { return "VmType{" - + "metaData=" + metaData + + "vmType=" + vmType + + ", metaData=" + metaData + ", extended=" + extended + '}'; } diff --git a/cloud-aws/src/main/java/com/sequenceiq/cloudbreak/cloud/aws/AwsPlatformResources.java b/cloud-aws/src/main/java/com/sequenceiq/cloudbreak/cloud/aws/AwsPlatformResources.java index 0e6ed0033a0..98442df1c08 100644 --- a/cloud-aws/src/main/java/com/sequenceiq/cloudbreak/cloud/aws/AwsPlatformResources.java +++ b/cloud-aws/src/main/java/com/sequenceiq/cloudbreak/cloud/aws/AwsPlatformResources.java @@ -350,7 +350,9 @@ public CloudRegions regions(CloudCredential cloudCredential, Region region, Map< @Override @Cacheable(cacheNames = "cloudResourceVmTypeCache", key = "#cloudCredential?.id + #region.getRegionName()") public CloudVmTypes virtualMachines(CloudCredential cloudCredential, Region region, Map filters) { + LOGGER.info("CloudCredential(id=%s, name=%s)".format(cloudCredential.getId().toString(), cloudCredential.getName())); CloudRegions regions = regions(cloudCredential, region, filters); + LOGGER.info("CloudRegions regions: %s".format(regions.toString())); Map> cloudVmResponses = new HashMap<>(); Map defaultCloudVmResponses = new HashMap<>(); diff --git a/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java b/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java index 6fbbfe619ef..e778843c6b3 100644 --- a/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java +++ b/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java @@ -1,7 +1,9 @@ package com.sequenceiq.cloudbreak.controller.validation.template; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Supplier; @@ -10,6 +12,8 @@ import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.google.common.base.Suppliers; @@ -30,6 +34,7 @@ @Component public class TemplateValidator { + private static final Logger LOGGER = LoggerFactory.getLogger(TemplateValidator.class); @Inject private CloudParameterService cloudParameterService; @@ -43,42 +48,58 @@ public class TemplateValidator { private final Supplier> platformParameters = Suppliers.memoize(() -> cloudParameterService.getPlatformParameters()); - public void validateTemplateRequest(Credential credential, Template value, String region, String availabilityZone, String variant) { + private List getVmTypes(Set availableVmTypes) { + List vmTypes = new ArrayList(); + for (VmType type : availableVmTypes) { + vmTypes.add(type.value()); + } + return vmTypes; + } + public void validateTemplateRequest(Credential credential, Template template, String region, String availabilityZone, String variant) { + LOGGER.info("Josh and Toby's logging attempt 4. validateTemplateRequest is invoked"); CloudVmTypes cloudVmTypes = cloudParameterService.getVmTypesV2(credential, region, variant, new HashMap<>()); - if (StringUtils.isEmpty(value.getInstanceType())) { - validateCustomInstanceType(value); + if (StringUtils.isEmpty(template.getInstanceType())) { + validateCustomInstanceType(template); } else { VmType vmType = null; VolumeParameterType volumeParameterType = null; - Platform platform = Platform.platform(value.cloudPlatform()); + Platform platform = Platform.platform(template.cloudPlatform()); Map> machines = cloudVmTypes.getCloudVmResponses(); + LOGGER.info("Checkpoint1 Validating %s for region %s and az %s".format(template.getInstanceType(), region, availabilityZone)); String locationString = locationService.location(region, availabilityZone); + LOGGER.info(locationString); if (machines.containsKey(locationString) && !machines.get(locationString).isEmpty()) { + LOGGER.info("Checkpoint2 showing available types..."); + LOGGER.info(String.join(" ", getVmTypes(machines.get(locationString)))); for (VmType type : machines.get(locationString)) { - if (type.value().equals(value.getInstanceType())) { + LOGGER.info("Checkpoint3"); + if (type.value().equals(template.getInstanceType())) { + LOGGER.info("Checkpoint3 match"); vmType = type; break; } } + LOGGER.info("Checkpoint4"); if (vmType == null) { throw new BadRequestException( - String.format("The '%s' instance type isn't supported by '%s' platform", value.getInstanceType(), platform.value())); + String.format("The '%s' instance type isn't supported by '%s' platform", + template.getInstanceType(), platform.value())); } } Map> disks = diskMappings.get(); if (disks.containsKey(platform) && !disks.get(platform).isEmpty()) { Map map = disks.get(platform); - volumeParameterType = map.get(value.getVolumeType()); + volumeParameterType = map.get(template.getVolumeType()); if (volumeParameterType == null) { throw new BadRequestException( - String.format("The '%s' volume type isn't supported by '%s' platform", value.getVolumeType(), platform.value())); + String.format("The '%s' volume type isn't supported by '%s' platform", template.getVolumeType(), platform.value())); } } - validateVolume(value, vmType, platform, volumeParameterType); + validateVolume(template, vmType, platform, volumeParameterType); } } diff --git a/core/src/main/java/com/sequenceiq/cloudbreak/service/StackCommonService.java b/core/src/main/java/com/sequenceiq/cloudbreak/service/StackCommonService.java index c2737895049..2e74485cfc9 100644 --- a/core/src/main/java/com/sequenceiq/cloudbreak/service/StackCommonService.java +++ b/core/src/main/java/com/sequenceiq/cloudbreak/service/StackCommonService.java @@ -171,6 +171,7 @@ public StackResponse getStackForAmbari(AmbariAddressJson json) { @Override public Set getAllForAutoscale() { + LOGGER.info("Josh and Toby's version is live and used on cloudbreak"); LOGGER.info("Get all stack, autoscale authorized only."); return stackService.getAllForAutoscale(); } diff --git a/core/src/main/resources/logback.xml b/core/src/main/resources/logback.xml index 1a824044cc3..bf6b4fa71c1 100644 --- a/core/src/main/resources/logback.xml +++ b/core/src/main/resources/logback.xml @@ -51,4 +51,9 @@ + + + + + \ No newline at end of file From 49fe6bb345b0f62555eaa091b4580c97df4671a3 Mon Sep 17 00:00:00 2001 From: Sudhakara Vasiraju Date: Wed, 4 Nov 2020 13:42:49 -0600 Subject: [PATCH 2/4] Adding more log (#8) --- .../sequenceiq/cloudbreak/domain/Credential.java | 16 ++++++++++++++++ .../validation/template/TemplateValidator.java | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java index ca46b131c4f..dc31c18c3fc 100644 --- a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java +++ b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java @@ -35,6 +35,22 @@ public class Credential implements ProvisionEntity { @Column(nullable = false) private String account; + @Override + public String toString() { + return "Credential{" + + "id=" + id + + ", name='" + name + '\'' + + ", description='" + description + '\'' + + ", owner='" + owner + '\'' + + ", account='" + account + '\'' + + ", publicInAccount=" + publicInAccount + + ", archived=" + archived + + ", cloudPlatform='" + cloudPlatform + '\'' + + ", attributes=" + attributes + + ", topology=" + topology + + '}'; + } + @Column(nullable = false) private boolean publicInAccount; diff --git a/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java b/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java index e778843c6b3..61a813855f3 100644 --- a/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java +++ b/core/src/main/java/com/sequenceiq/cloudbreak/controller/validation/template/TemplateValidator.java @@ -58,9 +58,10 @@ private List getVmTypes(Set availableVmTypes) { public void validateTemplateRequest(Credential credential, Template template, String region, String availabilityZone, String variant) { LOGGER.info("Josh and Toby's logging attempt 4. validateTemplateRequest is invoked"); - + LOGGER.error("SUDHAKAR -- HERE"); + LOGGER.error("SUDHAKAR -- credential >" + credential + "< region >" + region + "< variant >" + variant); CloudVmTypes cloudVmTypes = cloudParameterService.getVmTypesV2(credential, region, variant, new HashMap<>()); - + LOGGER.error("SUDHAKAR -- cloudVmTypes >" + cloudVmTypes); if (StringUtils.isEmpty(template.getInstanceType())) { validateCustomInstanceType(template); } else { From 901d637e2eb19aac18922af410749f0dea388915 Mon Sep 17 00:00:00 2001 From: Sudhakara Vasiraju Date: Wed, 4 Nov 2020 14:07:10 -0600 Subject: [PATCH 3/4] Branch 2.7.2 debug sud (#9) * Adding more log * Adding log --- .../com/sequenceiq/cloudbreak/domain/Credential.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java index dc31c18c3fc..a6323e16fa7 100644 --- a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java +++ b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java @@ -146,4 +146,13 @@ public Topology getTopology() { public void setTopology(Topology topology) { this.topology = topology; } + + @Override + public String toString() { + return "Credential{" + + "id=" + id + ", name='" + name + '\'' + ", description='" + description + '\'' + + ", owner='" + owner + '\'' + ", account='" + account + '\'' + ", publicInAccount=" + publicInAccount + + ", archived=" + archived + ", cloudPlatform='" + cloudPlatform + '\'' + ", attributes=" + attributes + + ", topology=" + topology + '}'; + } } From 367df339bfd7b72c24d4058dda69bf07bec8c9b1 Mon Sep 17 00:00:00 2001 From: Sudhakar Vasiraju Date: Wed, 4 Nov 2020 14:09:30 -0600 Subject: [PATCH 4/4] Adding log --- .../sequenceiq/cloudbreak/domain/Credential.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java index a6323e16fa7..767b5b752e6 100644 --- a/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java +++ b/core-model/src/main/java/com/sequenceiq/cloudbreak/domain/Credential.java @@ -35,22 +35,6 @@ public class Credential implements ProvisionEntity { @Column(nullable = false) private String account; - @Override - public String toString() { - return "Credential{" + - "id=" + id + - ", name='" + name + '\'' + - ", description='" + description + '\'' + - ", owner='" + owner + '\'' + - ", account='" + account + '\'' + - ", publicInAccount=" + publicInAccount + - ", archived=" + archived + - ", cloudPlatform='" + cloudPlatform + '\'' + - ", attributes=" + attributes + - ", topology=" + topology + - '}'; - } - @Column(nullable = false) private boolean publicInAccount;