Skip to content

Commit a8cb7ab

Browse files
Add new column last_id to the table volumes (#9759)
Co-authored-by: João Jandre <[email protected]>
1 parent 37eec06 commit a8cb7ab

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

engine/schema/src/main/java/com/cloud/storage/VolumeVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public class VolumeVO implements Volume {
4848
@Column(name = "id")
4949
long id;
5050

51+
@Column(name = "last_id")
52+
private long lastId;
53+
5154
@Column(name = "name")
5255
String name;
5356

@@ -677,4 +680,12 @@ public void setExternalUuid(String externalUuid) {
677680
public String getEncryptFormat() { return encryptFormat; }
678681

679682
public void setEncryptFormat(String encryptFormat) { this.encryptFormat = encryptFormat; }
683+
684+
public long getLastId() {
685+
return lastId;
686+
}
687+
688+
public void setLastId(long lastId) {
689+
this.lastId = lastId;
690+
}
680691
}

engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,6 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user_data', 'removed', 'datetime COM
7070
UPDATE `cloud`.`configuration` SET
7171
`options` = 'FirstFitRouting,RandomAllocator,TestingAllocator,FirstFitAllocator,RecreateHostAllocator'
7272
WHERE `name` = 'host.allocators.order';
73+
74+
-- Add last_id to the volumes table
75+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('volumes','last_id', 'bigint(20) unsigned DEFAULT NULL');

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2292,6 +2292,8 @@ private void handlePostMigration(boolean success, Map<VolumeInfo, VolumeInfo> sr
22922292
if (success) {
22932293
VolumeVO volumeVO = _volumeDao.findById(destVolumeInfo.getId());
22942294
volumeVO.setFormat(ImageFormat.QCOW2);
2295+
volumeVO.setLastId(srcVolumeInfo.getId());
2296+
22952297
_volumeDao.update(volumeVO.getId(), volumeVO);
22962298

22972299
_volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed, null, srcVolumeInfo, destVolumeInfo, false);

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,7 @@ protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool po
17201720
newVol.setPassphraseId(volume.getPassphraseId());
17211721
newVol.setEncryptFormat(volume.getEncryptFormat());
17221722
}
1723+
newVol.setLastId(volume.getId());
17231724
return volDao.persist(newVol);
17241725
}
17251726

0 commit comments

Comments
 (0)