Skip to content

Commit 8906aa1

Browse files
Merge branch '4.22'
2 parents c07f1fd + 1f5dba9 commit 8906aa1

7 files changed

Lines changed: 39 additions & 29 deletions

File tree

engine/schema/src/main/java/com/cloud/vm/dao/VMInstanceDaoImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ protected void init() {
358358
IdsPowerStateSelectSearch.entity().getPowerHostId(),
359359
IdsPowerStateSelectSearch.entity().getPowerState(),
360360
IdsPowerStateSelectSearch.entity().getPowerStateUpdateCount(),
361-
IdsPowerStateSelectSearch.entity().getPowerStateUpdateTime());
361+
IdsPowerStateSelectSearch.entity().getPowerStateUpdateTime(),
362+
IdsPowerStateSelectSearch.entity().getState());
362363
IdsPowerStateSelectSearch.done();
363364

364365
CountByOfferingId = createSearchBuilder(Integer.class);
@@ -1105,10 +1106,14 @@ public Map<Long, VirtualMachine.PowerState> updatePowerState(
11051106

11061107
private boolean isPowerStateInSyncWithInstanceState(final VirtualMachine.PowerState powerState, final long powerHostId, final VMInstanceVO instance) {
11071108
State instanceState = instance.getState();
1109+
if (instanceState == null) {
1110+
logger.warn("VM {} has null instance state during power state sync check, treating as out of sync", instance);
1111+
return false;
1112+
}
11081113
if ((powerState == VirtualMachine.PowerState.PowerOff && instanceState == State.Running)
11091114
|| (powerState == VirtualMachine.PowerState.PowerOn && instanceState == State.Stopped)) {
11101115
HostVO instanceHost = hostDao.findById(instance.getHostId());
1111-
HostVO powerHost = powerHostId == instance.getHostId() ? instanceHost : hostDao.findById(powerHostId);
1116+
HostVO powerHost = instance.getHostId() != null && powerHostId == instance.getHostId() ? instanceHost : hostDao.findById(powerHostId);
11121117
logger.debug("VM: {} on host: {} and power host : {} is in {} state, but power state is {}",
11131118
instance, instanceHost, powerHost, instanceState, powerState);
11141119
return false;

engine/schema/src/main/resources/META-INF/db/schema-42200to42210-cleanup.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@
1818
--;
1919
-- Schema upgrade cleanup from 4.22.0.0 to 4.22.1.0
2020
--;
21+
22+
-- Entries remaining on `cloud`.`resource_reservation` during the upgrade process are stale, so delete them.
23+
-- This script was added to normalize volume/primary storage reservations that got stuck due to a bug on VM deployment,
24+
-- but it is more interesting to introduce a smarter logic to clean these stale reservations in the future without the need
25+
-- for upgrades (for instance, by having a heartbeat_time column for the reservations and automatically cleaning old entries).
26+
DELETE FROM `cloud`.`resource_reservation`;

server/src/main/java/com/cloud/resourcelimit/ResourceLimitManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,8 @@ public ResourceLimitVO updateResourceLimit(Long accountId, Long domainId, Intege
10421042

10431043
ResourceLimitVO limit = _resourceLimitDao.findByOwnerIdAndTypeAndTag(ownerId, ownerType, resourceType, tag);
10441044

1045-
ActionEventUtils.onActionEvent(caller.getId(), caller.getAccountId(),
1045+
Long callingUserId = CallContext.current().getCallingUserId();
1046+
ActionEventUtils.onActionEvent(callingUserId, caller.getAccountId(),
10461047
caller.getDomainId(), EventTypes.EVENT_RESOURCE_LIMIT_UPDATE,
10471048
"Resource limit updated. Resource Type: " + resourceType + ", New Value: " + max,
10481049
ownerResourceId, ownerResourceType.toString());

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

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4349,22 +4349,20 @@ protected List<String> getResourceLimitStorageTags(long diskOfferingId) {
43494349
return resourceLimitService.getResourceLimitStorageTags(diskOfferingVO);
43504350
}
43514351

4352-
private List<CheckedReservation> reserveStorageResourcesForVm(Account owner, Long diskOfferingId, Long diskSize, List<VmDiskInfo> dataDiskInfoList, Long rootDiskOfferingId, ServiceOfferingVO offering, Long rootDiskSize) throws ResourceAllocationException {
4353-
List <CheckedReservation> checkedReservations = new ArrayList<>();
4354-
4352+
private void reserveStorageResourcesForVm(List<Reserver> checkedReservations, Account owner, Long diskOfferingId, Long diskSize, List<VmDiskInfo> dataDiskInfoList, Long rootDiskOfferingId, ServiceOfferingVO offering, Long rootDiskSize) throws ResourceAllocationException {
43554353
List<String> rootResourceLimitStorageTags = getResourceLimitStorageTags(rootDiskOfferingId != null ? rootDiskOfferingId : offering.getDiskOfferingId());
43564354
CheckedReservation rootVolumeReservation = new CheckedReservation(owner, ResourceType.volume, rootResourceLimitStorageTags, 1L, reservationDao, resourceLimitService);
43574355
checkedReservations.add(rootVolumeReservation);
43584356
CheckedReservation rootPrimaryStorageReservation = new CheckedReservation(owner, ResourceType.primary_storage, rootResourceLimitStorageTags, rootDiskSize, reservationDao, resourceLimitService);
43594357
checkedReservations.add(rootPrimaryStorageReservation);
43604358

43614359
if (diskOfferingId != null) {
4362-
List<String> additionalResourceLimitStorageTags = diskOfferingId != null ? getResourceLimitStorageTags(diskOfferingId) : null;
4360+
List<String> additionalResourceLimitStorageTags = getResourceLimitStorageTags(diskOfferingId);
43634361
DiskOfferingVO diskOffering = _diskOfferingDao.findById(diskOfferingId);
43644362
Long size = verifyAndGetDiskSize(diskOffering, diskSize);
4365-
CheckedReservation additionalVolumeReservation = diskOfferingId != null ? new CheckedReservation(owner, ResourceType.volume, additionalResourceLimitStorageTags, 1L, reservationDao, resourceLimitService) : null;
4363+
CheckedReservation additionalVolumeReservation = new CheckedReservation(owner, ResourceType.volume, additionalResourceLimitStorageTags, 1L, reservationDao, resourceLimitService);
43664364
checkedReservations.add(additionalVolumeReservation);
4367-
CheckedReservation additionalPrimaryStorageReservation = diskOfferingId != null ? new CheckedReservation(owner, ResourceType.primary_storage, additionalResourceLimitStorageTags, size, reservationDao, resourceLimitService) : null;
4365+
CheckedReservation additionalPrimaryStorageReservation = new CheckedReservation(owner, ResourceType.primary_storage, additionalResourceLimitStorageTags, size, reservationDao, resourceLimitService);
43684366
checkedReservations.add(additionalPrimaryStorageReservation);
43694367

43704368
}
@@ -4380,7 +4378,6 @@ private List<CheckedReservation> reserveStorageResourcesForVm(Account owner, Lon
43804378
checkedReservations.add(additionalPrimaryStorageReservation);
43814379
}
43824380
}
4383-
return checkedReservations;
43844381
}
43854382

43864383
private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, String displayName, Account owner,
@@ -4392,10 +4389,10 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
43924389
Map<String, String> userVmOVFPropertiesMap, boolean dynamicScalingEnabled, String vmType, VMTemplateVO template,
43934390
HypervisorType hypervisorType, long accountId, ServiceOfferingVO offering, boolean isIso,
43944391
Long rootDiskOfferingId, long volumesSize, Volume volume, Snapshot snapshot) throws ResourceAllocationException {
4395-
List<CheckedReservation> checkedReservations = new ArrayList<>();
4392+
List<Reserver> checkedReservations = new ArrayList<>();
43964393

43974394
try {
4398-
checkedReservations = reserveStorageResourcesForVm(owner, diskOfferingId, diskSize, dataDiskInfoList, rootDiskOfferingId, offering, volumesSize);
4395+
reserveStorageResourcesForVm(checkedReservations, owner, diskOfferingId, diskSize, dataDiskInfoList, rootDiskOfferingId, offering, volumesSize);
43994396

44004397
// verify security group ids
44014398
if (securityGroupIdList != null) {
@@ -4686,14 +4683,7 @@ private UserVm getUncheckedUserVmResource(DataCenter zone, String hostName, Stri
46864683
logger.error("error during resource reservation and allocation", e);
46874684
throw new CloudRuntimeException(e);
46884685
} finally {
4689-
for (CheckedReservation checkedReservation : checkedReservations) {
4690-
try {
4691-
checkedReservation.close();
4692-
} catch (Exception e) {
4693-
logger.error("error during resource reservation and allocation", e);
4694-
throw new CloudRuntimeException(e);
4695-
}
4696-
}
4686+
ReservationHelper.closeAll(checkedReservations);
46974687
}
46984688
}
46994689

ui/src/views/network/VpnCustomerGateway.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,13 @@ export default {
372372
'Group 15': 'modp3072',
373373
'Group 16': 'modp4096',
374374
'Group 17': 'modp6144',
375-
'Group 18': 'modp8192'
375+
'Group 18': 'modp8192',
376+
'Group 22': 'modp1024s160',
377+
'Group 23': 'modp2048s224',
378+
'Group 24': 'modp2048s256',
379+
'Group 31': 'curve25519'
376380
},
377-
ikeDhGroupInitialKey: 'Group 5',
381+
ikeDhGroupInitialKey: 'Group 31',
378382
isSubmitted: false,
379383
ikeversion: 'ike',
380384
allowedEncryptionAlgos: [],
@@ -401,12 +405,12 @@ export default {
401405
gateway: '',
402406
cidrlist: '',
403407
ipsecpsk: '',
404-
ikeEncryption: '',
405-
ikeHash: '',
406-
ikeversion: '',
407-
ikeDh: '',
408-
espEncryption: '',
409-
espHash: '',
408+
ikeEncryption: 'aes256',
409+
ikeHash: 'sha1',
410+
ikeversion: 'ike',
411+
ikeDh: 'Group 31(curve 25519)',
412+
espEncryption: 'aes256',
413+
espHash: 'sha256',
410414
perfectForwardSecrecy: 'None',
411415
ikelifetime: '86400',
412416
esplifetime: '3600',

utils/src/main/java/com/cloud/utils/net/NetUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ public static boolean isValidS2SVpnPolicy(final String policyType, final String
12651265
if (group == null && policyType.toLowerCase().matches("ike")) {
12661266
return false; // StrongSwan requires a DH group for the IKE policy
12671267
}
1268-
if (group != null && !group.matches("modp1024|modp1536|modp2048|modp3072|modp4096|modp6144|modp8192")) {
1268+
if (group != null && !group.matches("modp1024|modp1536|modp2048|modp3072|modp4096|modp6144|modp8192|modp1024s160|modp2048s224|modp2048s256|curve25519")) {
12691269
return false;
12701270
}
12711271
}

utils/src/test/java/com/cloud/utils/net/NetUtilsTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public void testIsValidS2SVpnPolicy() {
131131
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "3des-md5;modp1024"));
132132
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "3des-sha1;modp3072,aes128-sha1;modp1536"));
133133
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "3des-sha256;modp3072,aes128-sha512;modp1536"));
134+
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "aes256-sha256;modp1024s160"));
135+
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "aes256-sha256;modp2048s224"));
136+
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "aes256-sha256;modp2048s256"));
137+
assertTrue(NetUtils.isValidS2SVpnPolicy("ike", "aes256-sha256;curve25519"));
134138
assertFalse(NetUtils.isValidS2SVpnPolicy("ike", "aes128-sha1"));
135139
assertFalse(NetUtils.isValidS2SVpnPolicy("ike", "3des-sha1"));
136140
assertFalse(NetUtils.isValidS2SVpnPolicy("ike", "3des-sha1,aes256-sha1"));

0 commit comments

Comments
 (0)