Merge release branch 4.17 to main

* 4.17:
  KVM: revert libvirtd config and retry if fail to add a host (#7090)
  UI: display cpu cores and speed instead of cputotal by default (#7106)
  storage: validate disk size range of custom disk offering when resize volume (#7073)
This commit is contained in:
Daan Hoogland 2023-01-18 15:39:18 +01:00
commit ee6ed215c2
6 changed files with 46 additions and 15 deletions

View File

@ -162,6 +162,8 @@ public interface VolumeApiService {
Volume recoverVolume(long volumeId);
void validateCustomDiskOfferingSizeRange(Long sizeInGB);
boolean validateVolumeSizeInBytes(long size);
Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd) throws ResourceAllocationException;

View File

@ -23,6 +23,7 @@ KS_VALIDITY="$4"
CSR_FILE="$5"
ALIAS="cloud"
LIBVIRTD_FILE="/etc/libvirt/libvirtd.conf"
# Re-use existing password or use the one provided
if [ -f "$PROPS_FILE" ]; then
@ -46,6 +47,27 @@ keytool -genkey -storepass "$KS_PASS" -keypass "$KS_PASS" -alias "$ALIAS" -keyal
rm -f "$CSR_FILE"
addresses=$(ip address | grep inet | awk '{print $2}' | sed 's/\/.*//g' | grep -v '^169.254.' | grep -v '^127.0.0.1' | egrep -v '^::1|^fe80' | grep -v '^::1' | sed 's/^/ip:/g' | tr '\r\n' ',')
keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" > /dev/null 2>&1
if [ $? -ne 0 ];then
echo "Failed to generate CSR file, retrying after removing existing settings"
if [ -f "$LIBVIRTD_FILE" ]; then
echo "Reverting libvirtd to not listen on TLS"
sed -i "s,^listen_tls=1,listen_tls=0,g" $LIBVIRTD_FILE
systemctl restart libvirtd
fi
echo "Removing cloud.* files in /etc/cloudstack/agent"
rm -f /etc/cloudstack/agent/cloud.*
echo "Retrying to generate CSR file"
keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" >/dev/null 2>&1
if [ $? -ne 0 ];then
echo "Failed to generate CSR file while retrying"
exit 1
fi
fi
cat "$CSR_FILE"
# Fix file permissions

View File

@ -260,10 +260,11 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
final String privateKey = _configDao.getValue("ssh.privatekey");
if (!SSHCmdHelper.acquireAuthorizedConnectionWithPublicKey(sshConnection, username, privateKey)) {
s_logger.error("Failed to authenticate with ssh key");
if (org.apache.commons.lang3.StringUtils.isEmpty(password)) {
s_logger.error("Failed to authenticate with ssh key");
throw new DiscoveredWithErrorException("Authentication error with ssh private key");
}
s_logger.info("Failed to authenticate with ssh key, retrying with password");
if (!sshConnection.authenticateWithPassword(username, password)) {
s_logger.error("Failed to authenticate with password");
throw new DiscoveredWithErrorException("Authentication error with host password");

View File

@ -724,12 +724,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
if (size == null) {
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
}
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) {
throw new InvalidParameterValueException("Volume size: " + sizeInGB + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize + " Min:" + customDiskOfferingMinSize);
}
validateCustomDiskOfferingSizeRange(sizeInGB);
}
if (!diskOffering.isCustomized() && size != null) {
@ -886,6 +881,16 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
_uuidMgr.generateUuid(Volume.class, cmd.getCustomId()), details);
}
@Override
public void validateCustomDiskOfferingSizeRange(Long sizeInGB) {
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) {
throw new InvalidParameterValueException(String.format("Volume size: %s GB is out of allowed range. Min: %s. Max: %s", sizeInGB, customDiskOfferingMinSize, customDiskOfferingMaxSize));
}
}
private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account caller, final Account owner, final Boolean displayVolume, final Long zoneId, final Long diskOfferingId,
final Storage.ProvisioningType provisioningType, final Long size, final Long minIops, final Long maxIops, final VolumeVO parentVolume, final String userSpecifiedName, final String uuid, final Map<String, String> details) {
return Transaction.execute(new TransactionCallback<VolumeVO>() {
@ -1075,6 +1080,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
throw new InvalidParameterValueException(String.format("Resize of volume %s is not allowed, since disk size is strictly fixed as per the disk offering", volume.getUuid()));
}
if (diskOffering.isCustomized()) {
validateCustomDiskOfferingSizeRange(newSize);
}
if (isNotPossibleToResize(volume, diskOffering)) {
throw new InvalidParameterValueException(
"Failed to resize Root volume. The service offering of this Volume has been configured with a root disk size; "
@ -1158,6 +1167,8 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
throw new InvalidParameterValueException("The new disk offering requires that a size be specified.");
}
validateCustomDiskOfferingSizeRange(newSize);
// convert from GiB to bytes
newSize = newSize << 30;
} else {

View File

@ -4332,12 +4332,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (diskSize == null) {
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
}
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
if ((diskSize < customDiskOfferingMinSize) || (diskSize > customDiskOfferingMaxSize)) {
throw new InvalidParameterValueException("VM Creation failed. Volume size: " + diskSize + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize
+ " Min:" + customDiskOfferingMinSize);
}
_volumeService.validateCustomDiskOfferingSizeRange(diskSize);
size = diskSize * GiB_TO_BYTES;
} else {
size = diskOffering.getDiskSize();

View File

@ -143,8 +143,8 @@
<div class="resource-detail-item__label">{{ $t('label.cpu') }}</div>
<div class="resource-detail-item__details">
<appstore-outlined />
<span v-if="resource.cputotal">{{ resource.cputotal }}</span>
<span v-else>{{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz</span>
<span v-if="'cpunumber' in resource && 'cpuspeed' in resource">{{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz</span>
<span v-else>{{ resource.cputotal }}</span>
</div>
<div>
<span v-if="resource.cpuused">