fix(xo-server/listReplicatedVms): dont use snapshot_time
(#3394)
It is not always set on VMs imported from snapshots, add a new metadata in `other_config` and use the timestamp in the name_label a fallback. Fixes #3391
This commit is contained in:
parent
8213601df6
commit
bcab6bb584
@ -19,6 +19,7 @@
|
|||||||
- [New VM] Selecting multiple VMs and clicking Create then Cancel used to redirect to Home [#3268](https://github.com/vatesfr/xen-orchestra/issues/3268) (PR [#3371](https://github.com/vatesfr/xen-orchestra/pull/3371))
|
- [New VM] Selecting multiple VMs and clicking Create then Cancel used to redirect to Home [#3268](https://github.com/vatesfr/xen-orchestra/issues/3268) (PR [#3371](https://github.com/vatesfr/xen-orchestra/pull/3371))
|
||||||
- [Remotes] `cannot read 'properties' of undefined` error (PR [#3382](https://github.com/vatesfr/xen-orchestra/pull/3382))
|
- [Remotes] `cannot read 'properties' of undefined` error (PR [#3382](https://github.com/vatesfr/xen-orchestra/pull/3382))
|
||||||
- [Servers] Various issues when adding a new server [#3385](https://github.com/vatesfr/xen-orchestra/issues/3385) (PR [#3388](https://github.com/vatesfr/xen-orchestra/pull/3388))
|
- [Servers] Various issues when adding a new server [#3385](https://github.com/vatesfr/xen-orchestra/issues/3385) (PR [#3388](https://github.com/vatesfr/xen-orchestra/pull/3388))
|
||||||
|
- [Backup NG] Always delete the correct old replications [#3391](https://github.com/vatesfr/xen-orchestra/issues/3391) (PR [#3394](https://github.com/vatesfr/xen-orchestra/pull/3394))
|
||||||
|
|
||||||
### Released packages
|
### Released packages
|
||||||
|
|
||||||
|
@ -104,6 +104,16 @@ type Metadata = MetadataDelta | MetadataFull
|
|||||||
const compareSnapshotTime = (a: Vm, b: Vm): number =>
|
const compareSnapshotTime = (a: Vm, b: Vm): number =>
|
||||||
a.snapshot_time < b.snapshot_time ? -1 : 1
|
a.snapshot_time < b.snapshot_time ? -1 : 1
|
||||||
|
|
||||||
|
const getReplicatedVmDatetime = (vm: Vm) => {
|
||||||
|
const {
|
||||||
|
'xo:backup:datetime': datetime = vm.name_label.slice(-17, -1),
|
||||||
|
} = vm.other_config
|
||||||
|
return datetime
|
||||||
|
}
|
||||||
|
|
||||||
|
const compareReplicatedVmDatetime = (a: Vm, b: Vm): number =>
|
||||||
|
getReplicatedVmDatetime(a) < getReplicatedVmDatetime(b) ? -1 : 1
|
||||||
|
|
||||||
const compareTimestamp = (a: Metadata, b: Metadata): number =>
|
const compareTimestamp = (a: Metadata, b: Metadata): number =>
|
||||||
a.timestamp - b.timestamp
|
a.timestamp - b.timestamp
|
||||||
|
|
||||||
@ -183,9 +193,7 @@ const listReplicatedVms = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the replicated VMs have been created from a snapshot, therefore we can use
|
return values(vms).sort(compareReplicatedVmDatetime)
|
||||||
// `snapshot_time` as the creation time
|
|
||||||
return values(vms).sort(compareSnapshotTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const importers: $Dict<
|
const importers: $Dict<
|
||||||
@ -762,6 +770,7 @@ export default class BackupNg {
|
|||||||
parentId: taskId,
|
parentId: taskId,
|
||||||
},
|
},
|
||||||
xapi._updateObjectMapProperty(vm, 'other_config', {
|
xapi._updateObjectMapProperty(vm, 'other_config', {
|
||||||
|
'xo:backup:datetime': null,
|
||||||
'xo:backup:job': null,
|
'xo:backup:job': null,
|
||||||
'xo:backup:schedule': null,
|
'xo:backup:schedule': null,
|
||||||
'xo:backup:vm': null,
|
'xo:backup:vm': null,
|
||||||
@ -873,6 +882,7 @@ export default class BackupNg {
|
|||||||
parentId: taskId,
|
parentId: taskId,
|
||||||
},
|
},
|
||||||
xapi._updateObjectMapProperty(snapshot, 'other_config', {
|
xapi._updateObjectMapProperty(snapshot, 'other_config', {
|
||||||
|
'xo:backup:datetime': snapshot.snapshot_time,
|
||||||
'xo:backup:job': jobId,
|
'xo:backup:job': jobId,
|
||||||
'xo:backup:schedule': scheduleId,
|
'xo:backup:schedule': scheduleId,
|
||||||
'xo:backup:vm': vmUuid,
|
'xo:backup:vm': vmUuid,
|
||||||
|
Loading…
Reference in New Issue
Block a user