Skip to content

Commit ee6ed21

Browse files
committed
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)
2 parents dc1a452 + 792f835 commit ee6ed21

File tree

6 files changed

+46
-15
lines changed

6 files changed

+46
-15
lines changed

api/src/main/java/com/cloud/storage/VolumeApiService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account acc
162162

163163
Volume recoverVolume(long volumeId);
164164

165+
void validateCustomDiskOfferingSizeRange(Long sizeInGB);
166+
165167
boolean validateVolumeSizeInBytes(long size);
166168

167169
Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd) throws ResourceAllocationException;

scripts/util/keystore-setup

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ KS_VALIDITY="$4"
2323
CSR_FILE="$5"
2424

2525
ALIAS="cloud"
26+
LIBVIRTD_FILE="/etc/libvirt/libvirtd.conf"
2627

2728
# Re-use existing password or use the one provided
2829
if [ -f "$PROPS_FILE" ]; then
@@ -46,6 +47,27 @@ keytool -genkey -storepass "$KS_PASS" -keypass "$KS_PASS" -alias "$ALIAS" -keyal
4647
rm -f "$CSR_FILE"
4748
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' ',')
4849
keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" > /dev/null 2>&1
50+
51+
if [ $? -ne 0 ];then
52+
echo "Failed to generate CSR file, retrying after removing existing settings"
53+
54+
if [ -f "$LIBVIRTD_FILE" ]; then
55+
echo "Reverting libvirtd to not listen on TLS"
56+
sed -i "s,^listen_tls=1,listen_tls=0,g" $LIBVIRTD_FILE
57+
systemctl restart libvirtd
58+
fi
59+
60+
echo "Removing cloud.* files in /etc/cloudstack/agent"
61+
rm -f /etc/cloudstack/agent/cloud.*
62+
63+
echo "Retrying to generate CSR file"
64+
keytool -certreq -storepass "$KS_PASS" -alias "$ALIAS" -file $CSR_FILE -keystore "$KS_FILE" -ext san="$addresses" >/dev/null 2>&1
65+
if [ $? -ne 0 ];then
66+
echo "Failed to generate CSR file while retrying"
67+
exit 1
68+
fi
69+
fi
70+
4971
cat "$CSR_FILE"
5072

5173
# Fix file permissions

server/src/main/java/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,11 @@ private void setupAgentSecurity(final Connection sshConnection, final String age
260260

261261
final String privateKey = _configDao.getValue("ssh.privatekey");
262262
if (!SSHCmdHelper.acquireAuthorizedConnectionWithPublicKey(sshConnection, username, privateKey)) {
263-
s_logger.error("Failed to authenticate with ssh key");
264263
if (org.apache.commons.lang3.StringUtils.isEmpty(password)) {
264+
s_logger.error("Failed to authenticate with ssh key");
265265
throw new DiscoveredWithErrorException("Authentication error with ssh private key");
266266
}
267+
s_logger.info("Failed to authenticate with ssh key, retrying with password");
267268
if (!sshConnection.authenticateWithPassword(username, password)) {
268269
s_logger.error("Failed to authenticate with password");
269270
throw new DiscoveredWithErrorException("Authentication error with host password");

server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,7 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
724724
if (size == null) {
725725
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
726726
}
727-
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
728-
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
729-
730-
if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) {
731-
throw new InvalidParameterValueException("Volume size: " + sizeInGB + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize + " Min:" + customDiskOfferingMinSize);
732-
}
727+
validateCustomDiskOfferingSizeRange(sizeInGB);
733728
}
734729

735730
if (!diskOffering.isCustomized() && size != null) {
@@ -886,6 +881,16 @@ public VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationExcept
886881
_uuidMgr.generateUuid(Volume.class, cmd.getCustomId()), details);
887882
}
888883

884+
@Override
885+
public void validateCustomDiskOfferingSizeRange(Long sizeInGB) {
886+
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
887+
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
888+
889+
if ((sizeInGB < customDiskOfferingMinSize) || (sizeInGB > customDiskOfferingMaxSize)) {
890+
throw new InvalidParameterValueException(String.format("Volume size: %s GB is out of allowed range. Min: %s. Max: %s", sizeInGB, customDiskOfferingMinSize, customDiskOfferingMaxSize));
891+
}
892+
}
893+
889894
private VolumeVO commitVolume(final CreateVolumeCmd cmd, final Account caller, final Account owner, final Boolean displayVolume, final Long zoneId, final Long diskOfferingId,
890895
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) {
891896
return Transaction.execute(new TransactionCallback<VolumeVO>() {
@@ -1075,6 +1080,10 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
10751080
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()));
10761081
}
10771082

1083+
if (diskOffering.isCustomized()) {
1084+
validateCustomDiskOfferingSizeRange(newSize);
1085+
}
1086+
10781087
if (isNotPossibleToResize(volume, diskOffering)) {
10791088
throw new InvalidParameterValueException(
10801089
"Failed to resize Root volume. The service offering of this Volume has been configured with a root disk size; "
@@ -1158,6 +1167,8 @@ public VolumeVO resizeVolume(ResizeVolumeCmd cmd) throws ResourceAllocationExcep
11581167
throw new InvalidParameterValueException("The new disk offering requires that a size be specified.");
11591168
}
11601169

1170+
validateCustomDiskOfferingSizeRange(newSize);
1171+
11611172
// convert from GiB to bytes
11621173
newSize = newSize << 30;
11631174
} else {

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4332,12 +4332,7 @@ private long verifyAndGetDiskSize(DiskOfferingVO diskOffering, Long diskSize) {
43324332
if (diskSize == null) {
43334333
throw new InvalidParameterValueException("This disk offering requires a custom size specified");
43344334
}
4335-
Long customDiskOfferingMaxSize = VolumeOrchestrationService.CustomDiskOfferingMaxSize.value();
4336-
Long customDiskOfferingMinSize = VolumeOrchestrationService.CustomDiskOfferingMinSize.value();
4337-
if ((diskSize < customDiskOfferingMinSize) || (diskSize > customDiskOfferingMaxSize)) {
4338-
throw new InvalidParameterValueException("VM Creation failed. Volume size: " + diskSize + "GB is out of allowed range. Max: " + customDiskOfferingMaxSize
4339-
+ " Min:" + customDiskOfferingMinSize);
4340-
}
4335+
_volumeService.validateCustomDiskOfferingSizeRange(diskSize);
43414336
size = diskSize * GiB_TO_BYTES;
43424337
} else {
43434338
size = diskOffering.getDiskSize();

ui/src/components/view/InfoCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
<div class="resource-detail-item__label">{{ $t('label.cpu') }}</div>
144144
<div class="resource-detail-item__details">
145145
<appstore-outlined />
146-
<span v-if="resource.cputotal">{{ resource.cputotal }}</span>
147-
<span v-else>{{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz</span>
146+
<span v-if="'cpunumber' in resource && 'cpuspeed' in resource">{{ resource.cpunumber }} CPU x {{ parseFloat(resource.cpuspeed / 1000.0).toFixed(2) }} Ghz</span>
147+
<span v-else>{{ resource.cputotal }}</span>
148148
</div>
149149
<div>
150150
<span v-if="resource.cpuused">

0 commit comments

Comments
 (0)