Skip to content

Commit bd5d2f2

Browse files
authored
Merge branch '4.20' into ghi9800-updateVrOnSettingChange
2 parents f870fad + 17e062a commit bd5d2f2

File tree

27 files changed

+418
-79
lines changed

27 files changed

+418
-79
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ jobs:
236236
237237
- name: Install Python dependencies
238238
run: |
239-
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycrypto mock flask netaddr pylint pycodestyle six astroid pynose
239+
python3 -m pip install --user --upgrade urllib3 lxml paramiko nose texttable ipmisim pyopenssl pycryptodome mock flask netaddr pylint pycodestyle six astroid pynose
240240
241241
- name: Install jacoco dependencies
242242
run: |

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
595595
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
596596
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
597597
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest, null, false, Availability.Optional, null,
598-
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, false, null, false, false, null, false, null, true, true, false, false, null, null, null,true, null, null, false);
598+
defaultVPCOffProviders, true, Network.GuestType.Isolated, false, null, true, null, false, false, null, false, null, true, true, false, false, null, null, null,true, null, null, false);
599599
}
600600

601601
//#6 - default vpc offering with no LB service

engine/schema/src/main/resources/META-INF/db/schema-42000to42010.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,6 @@ CALL `cloud`.`IDEMPOTENT_UPDATE_API_PERMISSION`('Support Admin - Default', 'vali
7979
-- health check status as enum
8080

8181
CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('router_health_check', 'check_result', 'check_result', 'varchar(16) NOT NULL COMMENT "check executions result: SUCCESS, FAILURE, WARNING, UNKNOWN"');
82+
83+
-- Re-apply VPC: update default network offering for vpc tier to conserve_mode=1 (#8309)
84+
UPDATE `cloud`.`network_offerings` SET conserve_mode=1 WHERE name='DefaultIsolatedNetworkOfferingForVpcNetworks';

engine/storage/snapshot/src/main/java/org/apache/cloudstack/storage/vmsnapshot/StorageVMSnapshotStrategy.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
181181
thawAnswer = (FreezeThawVMAnswer) agentMgr.send(hostId, thawCmd);
182182
if (thawAnswer != null && thawAnswer.getResult()) {
183183
logger.info(String.format(
184-
"Virtual machne is thawed. The freeze of virtual machine took %s milliseconds.",
184+
"Virtual machine is thawed. The freeze of virtual machine took %s milliseconds.",
185185
TimeUnit.MILLISECONDS.convert(elapsedTime(startFreeze), TimeUnit.NANOSECONDS)));
186186
}
187187
} else {
@@ -427,9 +427,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
427427
String snapshotName = vmSnapshot.getId() + "_" + vol.getUuid();
428428
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(), vol.getId(), vol.getDiskOfferingId(),
429429
snapshotName, (short) Snapshot.Type.GROUP.ordinal(), Snapshot.Type.GROUP.name(), vol.getSize(), vol.getMinIops(), vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
430+
VMSnapshotOptions options = ((VMSnapshotVO) vmSnapshot).getOptions();
431+
boolean quiescevm = false;
432+
if (options != null) {
433+
quiescevm = options.needQuiesceVM();
434+
}
430435

431436
snapshot = snapshotDao.persist(snapshot);
432-
vol.addPayload(setPayload(vol, snapshot));
437+
vol.addPayload(setPayload(vol, snapshot, quiescevm));
433438
SnapshotInfo snapshotInfo = snapshotDataFactory.getSnapshot(snapshot.getId(), vol.getDataStore());
434439
snapshotInfo.addPayload(vol.getpayload());
435440
SnapshotStrategy snapshotStrategy = storageStrategyFactory.getSnapshotStrategy(snapshotInfo, SnapshotOperation.TAKE);
@@ -447,14 +452,14 @@ protected SnapshotInfo createDiskSnapshot(VMSnapshot vmSnapshot, List<SnapshotIn
447452
return snapshotInfo;
448453
}
449454

450-
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate) {
455+
protected CreateSnapshotPayload setPayload(VolumeInfo vol, SnapshotVO snapshotCreate, boolean quiescevm) {
451456
CreateSnapshotPayload payload = new CreateSnapshotPayload();
452457
payload.setSnapshotId(snapshotCreate.getId());
453458
payload.setSnapshotPolicyId(SnapshotVO.MANUAL_POLICY_ID);
454459
payload.setLocationType(snapshotCreate.getLocationType());
455460
payload.setAccount(accountService.getAccount(vol.getAccountId()));
456461
payload.setAsyncBackup(false);
457-
payload.setQuiescevm(false);
462+
payload.setQuiescevm(quiescevm);
458463
return payload;
459464
}
460465
}

engine/storage/snapshot/src/test/java/org/apache/cloudstack/storage/vmsnapshot/VMSnapshotStrategyKVMTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
3838
import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy.SnapshotOperation;
3939
import org.apache.cloudstack.engine.subsystem.api.storage.StorageStrategyFactory;
40+
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
4041
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
4142
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
4243
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
@@ -151,7 +152,7 @@ public void setUp() throws Exception {
151152

152153
@Test
153154
public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
154-
VMSnapshot vmSnapshot = Mockito.mock(VMSnapshot.class);
155+
VMSnapshotVO vmSnapshot = Mockito.mock(VMSnapshotVO.class);
155156
List<SnapshotInfo> forRollback = new ArrayList<>();
156157
VolumeInfo vol = Mockito.mock(VolumeInfo.class);
157158
SnapshotInfo snapshotInfo = Mockito.mock(SnapshotInfo.class);
@@ -162,6 +163,7 @@ public void testCreateDiskSnapshotBasedOnStrategy() throws Exception {
162163
SnapshotVO snapshot = new SnapshotVO(vol.getDataCenterId(), vol.getAccountId(), vol.getDomainId(),
163164
vol.getId(),vol.getDiskOfferingId(), vmUuid + "_" + volUuid,(short) SnapshotVO.MANUAL_POLICY_ID,
164165
"MANUAL",vol.getSize(),vol.getMinIops(),vol.getMaxIops(), Hypervisor.HypervisorType.KVM, null);
166+
when(vmSnapshot.getOptions()).thenReturn(new VMSnapshotOptions(true));
165167
when(vmSnapshot.getUuid()).thenReturn(vmUuid);
166168
when(vol.getUuid()).thenReturn(volUuid);
167169
when(_snapshotDao.persist(any())).thenReturn(snapshot);

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtRestoreBackupCommandWrapper.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,16 +150,16 @@ private String mountBackupDirectory(String backupRepoAddress, String backupRepoT
150150
String mountDirectory = String.format("%s.%s",BACKUP_TEMP_FILE_PREFIX , randomChars);
151151
try {
152152
mountDirectory = Files.createTempDirectory(mountDirectory).toString();
153-
String mountOpts = null;
154-
if (Objects.nonNull(mountOptions)) {
155-
mountOpts = mountOptions;
156-
if ("cifs".equals(backupRepoType)) {
157-
mountOpts += ",nobrl";
153+
String mount = String.format(MOUNT_COMMAND, backupRepoType, backupRepoAddress, mountDirectory);
154+
if ("cifs".equals(backupRepoType)) {
155+
if (Objects.isNull(mountOptions) || mountOptions.trim().isEmpty()) {
156+
mountOptions = "nobrl";
157+
} else {
158+
mountOptions += ",nobrl";
158159
}
159160
}
160-
String mount = String.format(MOUNT_COMMAND, backupRepoType, backupRepoAddress, mountDirectory);
161-
if (Objects.nonNull(mountOpts)) {
162-
mount += " -o " + mountOpts;
161+
if (Objects.nonNull(mountOptions) && !mountOptions.trim().isEmpty()) {
162+
mount += " -o " + mountOptions;
163163
}
164164
Script.runSimpleBashScript(mount);
165165
} catch (Exception e) {

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,14 @@ private String resizeVolume(DataObject data, String path, VolumeObject vol) {
412412
if (err == null && needResize) {
413413
err = notifyQemuForTheNewSize(data, err, vol, payload);
414414
}
415-
416415
if (err != null) {
417416
// try restoring volume to its initial size
418417
SpApiResponse response = StorPoolUtil.volumeUpdate(name, oldSize, true, oldMaxIops, conn);
419418
if (response.getError() != null) {
420419
logger.debug(String.format("Could not resize StorPool volume %s back to its original size. Error: %s", name, response.getError()));
421420
}
421+
} else {
422+
updateVolumeWithTheNewSize(vol, payload);
422423
}
423424
} catch (Exception e) {
424425
logger.debug("sending resize command failed", e);
@@ -427,6 +428,17 @@ private String resizeVolume(DataObject data, String path, VolumeObject vol) {
427428
return err;
428429
}
429430

431+
private void updateVolumeWithTheNewSize(VolumeObject vol, ResizeVolumePayload payload) {
432+
vol.setSize(payload.newSize);
433+
vol.update();
434+
if (payload.newMaxIops != null) {
435+
VolumeVO volume = volumeDao.findById(vol.getId());
436+
volume.setMaxIops(payload.newMaxIops);
437+
volumeDao.update(volume.getId(), volume);
438+
}
439+
updateStoragePool(vol.getPoolId(), payload.newSize - vol.getSize());
440+
}
441+
430442
private String notifyQemuForTheNewSize(DataObject data, String err, VolumeObject vol, ResizeVolumePayload payload)
431443
throws StorageUnavailableException {
432444
StoragePool pool = (StoragePool)data.getDataStore();
@@ -455,37 +467,34 @@ private String updateStorPoolVolume(VolumeObject vol, ResizeVolumePayload payloa
455467
}
456468
SpApiResponse resp = new SpApiResponse();
457469
if (tier != null || template != null) {
458-
Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, null, null, null, tier);
459-
StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, payload.newSize, tags, null, null, template, null, null,
460-
payload.shrinkOk);
461-
resp = StorPoolUtil.volumeUpdate(spVolume, conn);
470+
resp = updateVolumeByStorPoolQoS(payload, conn, name, tier, template);
462471
} else {
463-
long maxIops = payload.newMaxIops == null ? Long.valueOf(0) : payload.newMaxIops;
464-
465-
StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, payload.newSize, null, null, maxIops, null, null, null,
466-
payload.shrinkOk);
467-
StorPoolUtil.spLog(
468-
"StorpoolPrimaryDataStoreDriverImpl.resize: name=%s, uuid=%s, oldSize=%d, newSize=%s, shrinkOk=%s, maxIops=%s",
469-
name, vol.getUuid(), vol.getSize(), payload.newSize, payload.shrinkOk, maxIops);
470-
471-
resp = StorPoolUtil.volumeUpdate(spVolume, conn);
472+
resp = updateVolumeByOffering(vol, payload, conn, name);
472473
}
473474
if (resp.getError() != null) {
474475
err = String.format("Could not resize StorPool volume %s. Error: %s", name, resp.getError());
475-
} else {
476-
vol.setSize(payload.newSize);
477-
vol.update();
478-
if (payload.newMaxIops != null) {
479-
VolumeVO volume = volumeDao.findById(vol.getId());
480-
volume.setMaxIops(payload.newMaxIops);
481-
volumeDao.update(volume.getId(), volume);
482-
}
483-
484-
updateStoragePool(vol.getPoolId(), payload.newSize - vol.getSize());
485476
}
486477
return err;
487478
}
488479

480+
private static SpApiResponse updateVolumeByStorPoolQoS(ResizeVolumePayload payload, SpConnectionDesc conn, String name, String tier, String template) {
481+
Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, null, null, null, tier);
482+
StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, payload.newSize, tags, null, null, template, null, null,
483+
payload.shrinkOk);
484+
return StorPoolUtil.volumeUpdate(spVolume, conn);
485+
}
486+
487+
private static SpApiResponse updateVolumeByOffering(VolumeObject vol, ResizeVolumePayload payload, SpConnectionDesc conn, String name) {
488+
long maxIops = payload.newMaxIops == null ? Long.valueOf(0) : payload.newMaxIops;
489+
490+
StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, payload.newSize, null, null, maxIops, null, null, null,
491+
payload.shrinkOk);
492+
StorPoolUtil.spLog(
493+
"StorpoolPrimaryDataStoreDriverImpl.resize: name=%s, uuid=%s, oldSize=%d, newSize=%s, shrinkOk=%s, maxIops=%s",
494+
name, vol.getUuid(), vol.getSize(), payload.newSize, payload.shrinkOk, maxIops);
495+
return StorPoolUtil.volumeUpdate(spVolume, conn);
496+
}
497+
489498
@Override
490499
public void deleteAsync(DataStore dataStore, DataObject data, AsyncCompletionCallback<CommandResult> callback) {
491500
String err = null;

test/integration/smoke/test_guest_os.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,14 @@ def setUpClass(cls):
4747

4848
cls.hypervisor = cls.get_hypervisor_type()
4949

50-
@classmethod
5150
def setUp(self):
5251
self.apiclient = self.testClient.getApiClient()
5352

5453
#build cleanup list
5554
self.cleanup = []
5655

57-
@classmethod
5856
def tearDown(self):
59-
try:
60-
cleanup_resources(self.apiclient, self.cleanup)
61-
except Exception as e:
62-
self.debug("Warning! Exception in tearDown: %s" % e)
57+
super(TestGuestOS, self).tearDown()
6358

6459
@classmethod
6560
def get_hypervisor_type(cls):
@@ -95,6 +90,7 @@ def test_CRUD_operations_guest_OS(self):
9590
osdisplayname="testCentOS",
9691
oscategoryid=os_category.id
9792
)
93+
self.cleanup.append(self.guestos1)
9894
list_guestos = GuestOS.list(self.apiclient, id=self.guestos1.id, listall=True)
9995
self.assertNotEqual(
10096
len(list_guestos),
@@ -112,6 +108,7 @@ def test_CRUD_operations_guest_OS(self):
112108
self.apiclient,
113109
id=self.guestos1.id
114110
)
111+
self.cleanup.remove(self.guestos1)
115112

116113
@attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False)
117114
def test_CRUD_operations_guest_OS_mapping(self):
@@ -127,6 +124,7 @@ def test_CRUD_operations_guest_OS_mapping(self):
127124
osdisplayname="testCentOS",
128125
oscategoryid=os_category.id
129126
)
127+
self.cleanup.append(self.guestos1)
130128

131129
if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]:
132130
raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware")
@@ -138,6 +136,7 @@ def test_CRUD_operations_guest_OS_mapping(self):
138136
hypervisorversion=self.hypervisor.hypervisorversion,
139137
osnameforhypervisor="testOSMappingName"
140138
)
139+
self.cleanup.append(self.guestosmapping1)
141140

142141
list_guestos_mapping = GuestOsMapping.list(self.apiclient, id=self.guestosmapping1.id, listall=True)
143142
self.assertNotEqual(
@@ -156,11 +155,13 @@ def test_CRUD_operations_guest_OS_mapping(self):
156155
self.apiclient,
157156
id=self.guestosmapping1.id
158157
)
158+
self.cleanup.remove(self.guestosmapping1)
159159

160160
GuestOS.remove(
161161
self.apiclient,
162162
id=self.guestos1.id
163163
)
164+
self.cleanup.remove(self.guestos1)
164165

165166
@attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False)
166167
def test_guest_OS_mapping_check_with_hypervisor(self):
@@ -176,6 +177,7 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
176177
osdisplayname="testOSname1",
177178
oscategoryid=os_category.id
178179
)
180+
self.cleanup.append(self.guestos1)
179181

180182
if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]:
181183
raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware")
@@ -193,6 +195,7 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
193195
osnameforhypervisor=testosname,
194196
osmappingcheckenabled=True
195197
)
198+
self.cleanup.append(self.guestosmapping1)
196199

197200
list_guestos_mapping = GuestOsMapping.list(self.apiclient, id=self.guestosmapping1.id, listall=True)
198201
self.assertNotEqual(
@@ -211,11 +214,13 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
211214
self.apiclient,
212215
id=self.guestosmapping1.id
213216
)
217+
self.cleanup.remove(self.guestosmapping1)
214218

215219
GuestOS.remove(
216220
self.apiclient,
217221
id=self.guestos1.id
218222
)
223+
self.cleanup.remove(self.guestos1)
219224

220225
@attr(tags=['advanced', 'simulator', 'basic', 'sg'], required_hardware=False)
221226
def test_guest_OS_mapping_check_with_hypervisor_failure(self):
@@ -231,6 +236,7 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
231236
osdisplayname="testOSname2",
232237
oscategoryid=os_category.id
233238
)
239+
self.cleanup.append(self.guestos1)
234240

235241
if self.hypervisor.hypervisor.lower() not in ["xenserver", "vmware"]:
236242
raise unittest.SkipTest("OS name check with hypervisor is supported only on XenServer and VMware")
@@ -246,15 +252,18 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
246252
osnameforhypervisor=testosname,
247253
osmappingcheckenabled=True
248254
)
255+
self.cleanup.append(self.guestosmapping1)
249256
GuestOsMapping.remove(
250257
self.apiclient,
251258
id=self.guestosmapping1.id
252259
)
260+
self.cleanup.remove(self.guestosmapping1)
253261
self.fail("Since os mapping name is wrong, this API should fail")
254262
except CloudstackAPIException as e:
255263
self.debug("Addition guest OS mapping failed as expected %s " % e)
256264
GuestOS.remove(
257265
self.apiclient,
258266
id=self.guestos1.id
259267
)
268+
self.cleanup.remove(self.guestos1)
260269
return

test/integration/smoke/test_hostha_simulator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ def checkHaOwnershipExpiry(fakeMsId):
457457

458458
retry_interval = 1 + (pingInterval * pingTimeout / 10)
459459

460-
res, _ = wait_until(retry_interval, 20, removeFakeMgmtServer, self.getFakeMsRunId())
460+
res, _ = wait_until(retry_interval, 100, removeFakeMgmtServer, self.getFakeMsRunId())
461461
if not res:
462462
self.fail("Management server failed to turn down or remove fake mgmt server")
463463

test/integration/smoke/test_outofbandmanagement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def checkOobmOwnershipExpiry(serverPort, fakeMsId):
544544

545545
retry_interval = 1 + (pingInterval * pingTimeout / 10)
546546

547-
res, _ = wait_until(retry_interval, 10, removeFakeMgmtServer, self.getFakeMsRunId())
547+
res, _ = wait_until(retry_interval, 100, removeFakeMgmtServer, self.getFakeMsRunId())
548548
if not res:
549549
self.fail("Management server failed to turn down or remove fake mgmt server")
550550

0 commit comments

Comments
 (0)