if (getApplicationName() != null) sb.append("ApplicationName: ").append(getApplicationName()).append(","); if (getVersionLabel() != null) sb.append("VersionLabel: ").append(getVersionLabel()).append(","); if (getSolutionStackName() != null) sb.append("SolutionStackName: ").append(getSolutionStackName()).append(",");
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getEnvironmentName() == null) ? 0 : getEnvironmentName().hashCode()); hashCode = prime * hashCode + ((getEnvironmentId() == null) ? 0 : getEnvironmentId().hashCode()); hashCode = prime * hashCode + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode()); hashCode = prime * hashCode + ((getVersionLabel() == null) ? 0 : getVersionLabel().hashCode()); hashCode = prime * hashCode + ((getSolutionStackName() == null) ? 0 : getSolutionStackName().hashCode()); hashCode = prime * hashCode + ((getPlatformArn() == null) ? 0 : getPlatformArn().hashCode()); hashCode = prime * hashCode + ((getTemplateName() == null) ? 0 : getTemplateName().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getEndpointURL() == null) ? 0 : getEndpointURL().hashCode()); hashCode = prime * hashCode + ((getCNAME() == null) ? 0 : getCNAME().hashCode()); hashCode = prime * hashCode + ((getDateCreated() == null) ? 0 : getDateCreated().hashCode()); hashCode = prime * hashCode + ((getDateUpdated() == null) ? 0 : getDateUpdated().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getAbortableOperationInProgress() == null) ? 0 : getAbortableOperationInProgress().hashCode()); hashCode = prime * hashCode + ((getHealth() == null) ? 0 : getHealth().hashCode()); hashCode = prime * hashCode + ((getHealthStatus() == null) ? 0 : getHealthStatus().hashCode()); hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); hashCode = prime * hashCode + ((getTier() == null) ? 0 : getTier().hashCode()); hashCode = prime * hashCode + ((getEnvironmentLinks() == null) ? 0 : getEnvironmentLinks().hashCode()); hashCode = prime * hashCode + ((getEnvironmentArn() == null) ? 0 : getEnvironmentArn().hashCode()); return hashCode; }
if (other.getApplicationName() != null && other.getApplicationName().equals(this.getApplicationName()) == false) return false; if (other.getVersionLabel() == null ^ this.getVersionLabel() == null) return false; if (other.getVersionLabel() != null && other.getVersionLabel().equals(this.getVersionLabel()) == false) return false; if (other.getSolutionStackName() == null ^ this.getSolutionStackName() == null)
private Set<String> findDeployedLabels(String applicationName) { DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest(); req.setApplicationName(applicationName); Set<String> result = new TreeSet<String>(); for (EnvironmentDescription description : elasticBeanstalk.describeEnvironments(req).getEnvironments()) { if (description.getVersionLabel() != null) { // Ignore null value (for example when environment is launching) result.add(description.getVersionLabel()); } } return result; } }
private Set<String> findDeployedLabels(String applicationName) { DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest(); req.setApplicationName(applicationName); Set<String> result = new TreeSet<String>(); for (EnvironmentDescription description : elasticBeanstalk.describeEnvironments(req).getEnvironments()) { if (description.getVersionLabel() != null) { // Ignore null value (for example when environment is launching) result.add(description.getVersionLabel()); } } return result; } }
private void checkEnvironment(AWSElasticBeanstalk client, String environment) { // Environment needs to be ready to start an update // We query the environment in a loop to wait and report it status is ready // Unfortunately the elastic beanstalk sdk doesn't have waiters yet // https://aws.amazon.com/blogs/developer/waiters-in-the-aws-sdk-for-java/ for (int retries = 0; retries <= MAX_CHECK_ENVIRONMENT_RETRIES; retries++) { Optional<EnvironmentDescription> environmentDescriptionOpt = SimpleEnvironmentDescriber.describe(client, awsAppName, environment); if (!environmentDescriptionOpt.isPresent()) { log.info("Failed to describe environment"); } else { EnvironmentDescription result = environmentDescriptionOpt.get(); if (AWS_ENVIRONMENT_STATUS_READY.equals(result.getStatus()) && newVersion.equals(result.getVersionLabel())) { throw new GradleException("The application version to deploy and the currently used are the same."); } else if (AWS_ENVIRONMENT_STATUS_READY.equals(result.getStatus())) { log.fine("Status is '" + result.getStatus() + "'"); break; } else { log.fine("Status is '" + result.getStatus() + "'. Waiting for environment to get ready to update."); try { sleep(MILLIS_TO_WAIT); } catch (InterruptedException ie) { log.info("Application failed to sleep " + ie.getMessage()); } } } } throw new GradleException("Checking environment timed out."); }
EnvironmentDescription result = environmentDescriptionOpt.get(); if (newVersion.equals(result.getVersionLabel()) && AWS_ENVIRONMENT_STATUS_READY.equals(result.getStatus())) { log.info("Version reported is '" + result.getVersionLabel() + "'. Environment is '" + result.getStatus() + "' and " + "'" + result.getHealth()); break; } else { log.info("Version reported is '" + result.getVersionLabel() + "'. Environment is '" + result.getStatus() + "' and '" + result.getHealth() + "'.");
if (getApplicationName() != null) sb.append("ApplicationName: ").append(getApplicationName()).append(","); if (getVersionLabel() != null) sb.append("VersionLabel: ").append(getVersionLabel()).append(","); if (getSolutionStackName() != null) sb.append("SolutionStackName: ").append(getSolutionStackName()).append(",");
@TaskAction public void deleteVersion() { // to enable conventionMappings feature String appName = getAppName(); boolean deleteSourceBundle = isDeleteSourceBundle(); AwsBeanstalkPluginExtension ext = getProject().getExtensions().getByType(AwsBeanstalkPluginExtension.class); AWSElasticBeanstalk eb = ext.getClient(); DescribeEnvironmentsResult der = eb.describeEnvironments(new DescribeEnvironmentsRequest() .withApplicationName(appName)); List<String> usingVersions = der.getEnvironments().stream().map(ed -> ed.getVersionLabel()).collect(Collectors.toList()); DescribeApplicationVersionsResult davr = eb.describeApplicationVersions(new DescribeApplicationVersionsRequest() .withApplicationName(appName)); List<String> versionLabelsToDelete = davr.getApplicationVersions().stream() .filter(avd -> usingVersions.contains(avd.getVersionLabel()) == false && avd.getVersionLabel().contains("-SNAPSHOT-")) .map(avd -> avd.getVersionLabel()).collect(Collectors.toList()); versionLabelsToDelete.forEach(versionLabel -> { getLogger().info("version " + versionLabel + " deleted"); eb.deleteApplicationVersion(new DeleteApplicationVersionRequest() .withApplicationName(appName) .withVersionLabel(versionLabel) .withDeleteSourceBundle(deleteSourceBundle)); }); } }
for (ListIterator<EnvironmentDescription> i = result.getEnvironments().listIterator(); i.hasNext(); ) { EnvironmentDescription element = i.next(); final String environmentLabel = element.getVersionLabel(); if (null != environmentLabel && environmentLabel.equals(getVersionLabel())) { log("The version to deploy and currently used are the same. Even if you overwrite, AWSEB won't allow you to update." +
String curVersionLabel = d.getVersionLabel();
ApplicationVersionDescription appVersion = appVersionIterator.next(); boolean bMatchesVersion = appVersion.getVersionLabel().equals(d.getVersionLabel());
@Override public boolean release() { final Collection<String> environmentIds = getEnvironmentIds(); final DescribeEnvironmentsRequest req = new DescribeEnvironmentsRequest(). withApplicationName(c.config.getApplicationName()). withEnvironmentIds(environmentIds). withIncludeDeleted(false); final Map<String, EnvironmentDescription> environmentMap = new TreeMap<>(); final DescribeEnvironmentsResult result = getAwseb().describeEnvironments(req); for (EnvironmentDescription environment : result.getEnvironments()) environmentMap.put(environment.getEnvironmentId(), environment); boolean bInvalid = false; for (String environmentId : environmentIds) { EnvironmentDescription curEnv = environmentMap.get(environmentId); if (null == curEnv) { log("WARNING: Environment Not found (environmentId=%s)", environmentId); bInvalid = false; continue; } if (!curEnv.getVersionLabel().equals(c.versionLabel)) { log("WARNING: Environment (environmentId='%s') doesn't have matching versionLabels (expected: %s; found: %s)", environmentId, c.getVersionLabel(), curEnv.getVersionLabel()); bInvalid = false; } else { log("VersionLabels are matching for environmentId:'%s' and version:'%s')", environmentId, c.getVersionLabel()); } } return bInvalid; } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getEnvironmentName() == null) ? 0 : getEnvironmentName().hashCode()); hashCode = prime * hashCode + ((getEnvironmentId() == null) ? 0 : getEnvironmentId().hashCode()); hashCode = prime * hashCode + ((getApplicationName() == null) ? 0 : getApplicationName().hashCode()); hashCode = prime * hashCode + ((getVersionLabel() == null) ? 0 : getVersionLabel().hashCode()); hashCode = prime * hashCode + ((getSolutionStackName() == null) ? 0 : getSolutionStackName().hashCode()); hashCode = prime * hashCode + ((getPlatformArn() == null) ? 0 : getPlatformArn().hashCode()); hashCode = prime * hashCode + ((getTemplateName() == null) ? 0 : getTemplateName().hashCode()); hashCode = prime * hashCode + ((getDescription() == null) ? 0 : getDescription().hashCode()); hashCode = prime * hashCode + ((getEndpointURL() == null) ? 0 : getEndpointURL().hashCode()); hashCode = prime * hashCode + ((getCNAME() == null) ? 0 : getCNAME().hashCode()); hashCode = prime * hashCode + ((getDateCreated() == null) ? 0 : getDateCreated().hashCode()); hashCode = prime * hashCode + ((getDateUpdated() == null) ? 0 : getDateUpdated().hashCode()); hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode()); hashCode = prime * hashCode + ((getAbortableOperationInProgress() == null) ? 0 : getAbortableOperationInProgress().hashCode()); hashCode = prime * hashCode + ((getHealth() == null) ? 0 : getHealth().hashCode()); hashCode = prime * hashCode + ((getHealthStatus() == null) ? 0 : getHealthStatus().hashCode()); hashCode = prime * hashCode + ((getResources() == null) ? 0 : getResources().hashCode()); hashCode = prime * hashCode + ((getTier() == null) ? 0 : getTier().hashCode()); hashCode = prime * hashCode + ((getEnvironmentLinks() == null) ? 0 : getEnvironmentLinks().hashCode()); hashCode = prime * hashCode + ((getEnvironmentArn() == null) ? 0 : getEnvironmentArn().hashCode()); return hashCode; }
if (curEnv.getVersionLabel().equals(versionLabel) && skipIfSameVersion) { getLog().warn(format("Environment is running version %s and skipIfSameVersion is true. Returning", versionLabel));
Object changeToVersion(EnvironmentDescription d, ApplicationVersionDescription latestVersionDescription) { String curVersionLabel = d.getVersionLabel(); String versionLabel = latestVersionDescription.getVersionLabel(); UpdateEnvironmentRequest request = new UpdateEnvironmentRequest().withEnvironmentId(d.getEnvironmentId()).withVersionLabel(versionLabel); getLog() .info( "Changing versionLabel for Environment[name=" + curEnv.getEnvironmentName() + "; environmentId=" + curEnv.getEnvironmentId() + "] from version " + curVersionLabel + " to version " + latestVersionDescription.getVersionLabel()); if (dryRun) { return null; } return getService().updateEnvironment(request); } }
@Override public boolean perform() throws Exception { environmentNames = generateEnvironmentNames(); EnvironmentDescription environmentDescription; for (String environmentName : environmentNames) { try { List<String> envName = Lists.newArrayList(environmentName); environmentDescription = lookupEnvironmentIds(envName); environmentId = environmentDescription.getEnvironmentId(); } catch (InvalidDeploymentTypeException exc) { log("Zero Downtime isn't valid for Worker Environments."); return true; } catch (InvalidEnvironmentsSizeException exc) { log("Unable to find any suitable environment. Aborting."); return true; } if (environmentDescription.getVersionLabel().equals(getVersionLabel())) { log("The version to deploy and currently used are the same. Even if you overwrite, AWSEB won't allow you to update." + "Skipping."); return true; } templateName = createConfigurationTemplate(environmentId); String clonedEnvironmentId = createEnvironment(getVersionLabel(), getVersionDescription(), templateName, environmentNames); setEnvironmentId(clonedEnvironmentId); log("From now on, we'll use '%s' as the environmentId, but once finished, we'll swap and replace with '%s'", getEnvironmentId(), environmentId); } return false; }
environmentDescription.getVersionLabel(), getVersionLabel(), String.valueOf(bHasDifferentVersion));
if (other.getApplicationName() != null && other.getApplicationName().equals(this.getApplicationName()) == false) return false; if (other.getVersionLabel() == null ^ this.getVersionLabel() == null) return false; if (other.getVersionLabel() != null && other.getVersionLabel().equals(this.getVersionLabel()) == false) return false; if (other.getSolutionStackName() == null ^ this.getSolutionStackName() == null)
protected Object executeInternal() throws AbstractMojoExecutionException { versionLabel = lookupVersionLabel(applicationName, versionLabel); waitForNotUpdating(); if (null == optionSettings) { optionSettings = super.introspectOptionSettings(); } UpdateEnvironmentContextBuilder builder = UpdateEnvironmentContextBuilder.updateEnvironmentContext() .withEnvironmentId(curEnv.getEnvironmentId()) // .withEnvironmentDescription(environmentDescription) // .withEnvironmentName(curEnv.getEnvironmentName()) // .withOptionSettings(optionSettings) // .withOptionsToRemove(optionsToRemove) // .withTemplateName(lookupTemplateName(applicationName, templateName)) // .withVersionLabel(versionLabel) // .withEnvironmentTierType(environmentTierType) // .withEnvironmentTierName(environmentTierName) // .withEnvironmentTierVersion(environmentTierVersion) // .withLatestVersionLabel(curEnv.getVersionLabel()); UpdateEnvironmentContext context = builder.build(); UpdateEnvironmentCommand command = new UpdateEnvironmentCommand(this); return command.execute(context); } }