use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class ClusterUpgradeAvailabilityService method checkForUpgradesByName.
public UpgradeV4Response checkForUpgradesByName(Stack stack, boolean lockComponents, boolean replaceVms, InternalUpgradeSettings internalUpgradeSettings) {
UpgradeV4Response upgradeOptions = checkForUpgrades(stack, lockComponents, internalUpgradeSettings);
upgradeOptions.setReplaceVms(replaceVms);
if (StringUtils.isEmpty(upgradeOptions.getReason())) {
if (!stack.getStatus().isAvailable()) {
upgradeOptions.setReason(String.format("Cannot upgrade cluster because it is in %s state.", stack.getStatus()));
LOGGER.warn(upgradeOptions.getReason());
} else if (instanceMetaDataService.anyInstanceStopped(stack.getId())) {
upgradeOptions.setReason("Cannot upgrade cluster because there is stopped instance.");
LOGGER.warn(upgradeOptions.getReason());
} else if (shouldValidateForRepair(lockComponents, replaceVms)) {
LOGGER.debug("Validate for repair");
Result<Map<HostGroupName, Set<InstanceMetaData>>, RepairValidation> validationResult = clusterRepairService.repairWithDryRun(stack.getId());
if (validationResult.isError()) {
upgradeOptions.setReason(String.join(",", validationResult.getError().getValidationErrors()));
LOGGER.warn(String.format("Cannot upgrade cluster because: %s", upgradeOptions.getReason()));
}
}
}
return upgradeOptions;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrixButUpgradeMatrixCheckSkippedInImageFilterParams.
@Test
public void testPermitStackUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrixButUpgradeMatrixCheckSkippedInImageFilterParams() {
String currentVersion = "7.2.1";
String targetVersion = "7.2.2";
Image currentImage = createImage(currentVersion, "2002");
Image candidateImage = createImage(targetVersion, "2001");
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), StackType.WORKLOAD, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
when(supportedRuntimes.isSupported("7.2.2")).thenReturn(true);
boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
assertTrue(actual);
verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
verify(upgradeMatrixService, never()).permitByUpgradeMatrix(currentVersion, targetVersion);
verifyNoInteractions(componentBuildNumberComparator);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitCmUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrix.
@Test
public void testPermitCmUpgradeShouldReturnTrueWhenTheUpgradeNotPermittedByTheUpgradeMatrix() {
String currentVersion = "7.2.1";
String targetVersion = "7.2.2";
Image currentImage = createImage(currentVersion, "2002");
Image candidateImage = createImage(targetVersion, "2001");
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(true);
boolean actual = underTest.permitCmUpgrade(imageFilterParams, candidateImage);
assertTrue(actual);
verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
verify(upgradeMatrixService, never()).permitByUpgradeMatrix(currentVersion, targetVersion);
verifyNoInteractions(componentBuildNumberComparator);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheCandidateCmVersionIsLower.
@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheCandidateCmVersionIsLower() {
String currentVersion = "7.2.1";
String targetVersion = "7.1.2";
Image currentImage = createImage(currentVersion, "2002");
Image candidateImage = createImage(targetVersion, "2001");
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentVersionComparator.permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion)).thenReturn(false);
when(supportedRuntimes.isSupported("7.1.2")).thenReturn(true);
boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
assertFalse(actual);
verify(componentVersionComparator).permitCmAndStackUpgradeByComponentVersion(currentVersion, targetVersion);
verifyNoInteractions(componentBuildNumberComparator, upgradeMatrixService);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.InternalUpgradeSettings in project cloudbreak by hortonworks.
the class UpgradePermissionProviderTest method testPermitStackUpgradeShouldReturnFalseWhenTheCmBuildNumberIsNotAvailable.
@Test
public void testPermitStackUpgradeShouldReturnFalseWhenTheCmBuildNumberIsNotAvailable() {
Image currentImage = createImage("7.2.1", "2002");
Image candidateImage = createImage("7.2.1", null);
ImageFilterParams imageFilterParams = new ImageFilterParams(currentImage, true, Map.of(), DATALAKE_STACK_TYPE, null, STACK_ID, new InternalUpgradeSettings(false, true, true), imageCatalogPlatform(CLOUD_PLATFORM));
when(componentBuildNumberComparator.compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey())).thenReturn(false);
when(supportedRuntimes.isSupported("7.2.1")).thenReturn(true);
boolean actual = underTest.permitStackUpgrade(imageFilterParams, candidateImage);
assertFalse(actual);
verify(componentBuildNumberComparator).compare(currentImage, candidateImage, ImagePackageVersion.CDH_BUILD_NUMBER.getKey());
verifyNoInteractions(upgradeMatrixService, componentVersionComparator);
}
Aggregations