Update volume's passphrase to null if diskOffering doesn't support encryption (#8904)

This commit is contained in:
Vishesh 2024-04-29 12:18:09 +05:30 committed by GitHub
parent e409c6d870
commit 80a8b80a9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 11 deletions

View File

@ -85,7 +85,7 @@ public interface VolumeOrchestrationService {
VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
throws ConcurrentOperationException, StorageUnavailableException;
Volume allocateDuplicateVolume(Volume oldVol, Long templateId);
Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId);
boolean volumeOnSharedStoragePool(Volume volume);

View File

@ -305,11 +305,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
}
@Override
public Volume allocateDuplicateVolume(Volume oldVol, Long templateId) {
return allocateDuplicateVolumeVO(oldVol, templateId);
public Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId) {
return allocateDuplicateVolumeVO(oldVol, diskOffering, templateId);
}
public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, DiskOffering diskOffering, Long templateId) {
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(),
oldVol.getProvisioningType(), oldVol.getSize(), oldVol.getMinIops(), oldVol.getMaxIops(), oldVol.get_iScsiName());
if (templateId != null) {
@ -321,8 +321,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
newVol.setInstanceId(oldVol.getInstanceId());
newVol.setRecreatable(oldVol.isRecreatable());
newVol.setFormat(oldVol.getFormat());
if (oldVol.getPassphraseId() != null) {
if ((diskOffering == null || diskOffering.getEncrypt()) && oldVol.getPassphraseId() != null) {
PassphraseVO passphrase = passphraseDao.persist(new PassphraseVO(true));
newVol.setPassphraseId(passphrase.getId());
}
@ -1180,7 +1179,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
return Transaction.execute(new TransactionCallback<VolumeVO>() {
@Override
public VolumeVO doInTransaction(TransactionStatus status) {
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, templateIdToUseFinal);
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, null, templateIdToUseFinal);
try {
stateTransitTo(existingVolume, Volume.Event.DestroyRequested);
} catch (NoTransitionException e) {

View File

@ -1236,7 +1236,7 @@ public class VolumeServiceImpl implements VolumeService {
volumeInfo.processEvent(Event.DestroyRequested);
Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null);
Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null, null);
VolumeVO newVolume = (VolumeVO) newVol;
newVolume.set_iScsiName(null);
volDao.update(newVolume.getId(), newVolume);

View File

@ -7863,19 +7863,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
Volume newVol = null;
if (newTemplateId != null) {
if (isISO) {
newVol = volumeMgr.allocateDuplicateVolume(root, null);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
userVm.setIsoId(newTemplateId);
userVm.setGuestOSId(template.getGuestOSId());
userVm.setTemplateId(newTemplateId);
} else {
newVol = volumeMgr.allocateDuplicateVolume(root, newTemplateId);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, newTemplateId);
userVm.setGuestOSId(template.getGuestOSId());
userVm.setTemplateId(newTemplateId);
}
// check and update VM if it can be dynamically scalable with the new template
updateVMDynamicallyScalabilityUsingTemplate(userVm, newTemplateId);
} else {
newVol = volumeMgr.allocateDuplicateVolume(root, null);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
}
updateVolume(newVol, template, userVm, diskOffering, details);