use of com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult in project titus-control-plane by Netflix.
the class AwsInstanceCloudConnector method scaleUp.
@Override
public Completable scaleUp(String instanceGroupId, int scaleUpCount) {
return getInstanceGroups(singletonList(instanceGroupId)).map(list -> list.get(0)).flatMap(instanceGroup -> {
int newDesired = instanceGroup.getDesired() + scaleUpCount;
if (newDesired > instanceGroup.getMax()) {
return Observable.error(CloudConnectorException.invalidArgument("Instance group requested desired size %s > max size %s", newDesired, instanceGroup.getMax()));
}
logger.info("Scaling up instance group {}, by {} instances (desired changed from {} to {})", instanceGroup, scaleUpCount, instanceGroup.getDesired(), newDesired);
UpdateAutoScalingGroupRequest request = new UpdateAutoScalingGroupRequest().withAutoScalingGroupName(instanceGroupId).withDesiredCapacity(newDesired);
Observable<UpdateAutoScalingGroupResult> observable = toObservable(request, autoScalingClient::updateAutoScalingGroupAsync);
return observable;
}).toCompletable().timeout(configuration.getAwsRequestTimeoutMs(), TimeUnit.MILLISECONDS);
}
use of com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult in project cloudbreak by hortonworks.
the class AwsLaunchTemplateUpdateService method updateAutoScalingGroup.
private UpdateAutoScalingGroupResult updateAutoScalingGroup(Map<LaunchTemplateField, String> updatableFields, AmazonAutoScalingClient autoScalingClient, AutoScalingGroup autoScalingGroup, LaunchTemplateSpecification launchTemplateSpecification, CreateLaunchTemplateVersionResult createLaunchTemplateVersionResult) {
LaunchTemplateSpecification newLaunchTemplateSpecification = new LaunchTemplateSpecification().withLaunchTemplateId(launchTemplateSpecification.getLaunchTemplateId()).withVersion(createLaunchTemplateVersionResult.getLaunchTemplateVersion().getVersionNumber().toString());
UpdateAutoScalingGroupResult updateAutoScalingGroupResult = autoScalingClient.updateAutoScalingGroup(new UpdateAutoScalingGroupRequest().withAutoScalingGroupName(autoScalingGroup.getAutoScalingGroupName()).withLaunchTemplate(newLaunchTemplateSpecification));
LOGGER.info("Create new LauncTemplateVersion {} with new fields {} and attached it to the {} autoscaling group.", newLaunchTemplateSpecification, updatableFields, autoScalingGroup.getAutoScalingGroupName());
return updateAutoScalingGroupResult;
}
use of com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult in project cloudbreak by hortonworks.
the class AwsLaunchTemplateUpdateServiceTest method shouldUpdateImage.
@Test
public void shouldUpdateImage() throws IOException {
// GIVEN
String cfStackName = "cf";
CloudResource cfResource = CloudResource.builder().type(ResourceType.CLOUDFORMATION_STACK).name(cfStackName).build();
String template = FileReaderUtils.readFileFromClasspath("json/aws-cf-template.json");
String cfTemplateBody = JsonUtil.minify(String.format(template, "{\"Ref\":\"AMI\"}"));
when(cloudFormationClient.getTemplate(any())).thenReturn(new GetTemplateResult().withTemplateBody(cfTemplateBody));
Map<AutoScalingGroup, String> autoScalingGroupsResult = createAutoScalingGroupHandler();
when(autoScalingGroupHandler.getAutoScalingGroups(cloudFormationClient, autoScalingClient, cfResource.getName())).thenReturn(autoScalingGroupsResult);
when(ec2Client.createLaunchTemplateVersion(any(CreateLaunchTemplateVersionRequest.class))).thenReturn(new CreateLaunchTemplateVersionResult().withLaunchTemplateVersion(new LaunchTemplateVersion().withVersionNumber(1L)));
when(ec2Client.modifyLaunchTemplate(any(ModifyLaunchTemplateRequest.class))).thenReturn(new ModifyLaunchTemplateResult());
when(autoScalingClient.updateAutoScalingGroup(any(UpdateAutoScalingGroupRequest.class))).thenReturn(new UpdateAutoScalingGroupResult());
// WHEN
underTest.updateFields(ac, cfResource.getName(), Map.of(LaunchTemplateField.IMAGE_ID, stack.getImage().getImageName()));
// THEN
Mockito.verify(ec2Client).createLaunchTemplateVersion(argumentCaptor.capture());
CreateLaunchTemplateVersionRequest request = argumentCaptor.getValue();
Assertions.assertEquals(stack.getImage().getImageName(), request.getLaunchTemplateData().getImageId());
}
use of com.amazonaws.services.autoscaling.model.UpdateAutoScalingGroupResult in project bazel-buildfarm by bazelbuild.
the class AdminServiceImpl method scaleGroup.
@Override
public String scaleGroup(String asgName, Integer desiredInstances) {
logger.info("Scaling group {} to {} instances", asgName, desiredInstances);
UpdateAutoScalingGroupRequest request = new UpdateAutoScalingGroupRequest().withAutoScalingGroupName(asgName).withDesiredCapacity(desiredInstances);
UpdateAutoScalingGroupResult response = autoScale.updateAutoScalingGroup(request);
return response.toString();
}
Aggregations