-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cleanVm): add recovery method for duplicated vhd uuid containing… #6314
Conversation
6512d23
to
4a1c481
Compare
4a1c481
to
64a6b62
Compare
packages/vhd-lib/Vhd/VhdAbstract.js
Outdated
* check if all the data of a child are already contained in this vhd | ||
*/ | ||
|
||
async contains(child) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More explicit name, which make it more obvious that this is not a light operation:
async contains(child) { | |
async containsAllBlockOf(child) { |
await this.readBlockAllocationTable() | ||
await child.readBlockAllocationTable() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this method (and some others), are pitfalls, and should be implcitely called when necessary (e.g., when calling blocks).
If you agree, I'll do the change.
async contains(child) { | ||
await this.readBlockAllocationTable() | ||
await child.readBlockAllocationTable() | ||
for await (const block of child.blocks()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't read blocks before checking the parent contains them.
Maybe we should add another iterator (blockIds()
)?
@xen-orchestra/backups/_cleanVm.js
Outdated
const duplicate = vhdIds.get(vhd.footer.uuid) | ||
if (duplicate) { | ||
logWarn('uuid is duplicated', { uuid: vhd.footer.uuid }) | ||
// uuid is already present |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment really necessary?
It's obvious by the if (duplicate)
or am I missing something?
@xen-orchestra/backups/_cleanVm.js
Outdated
@@ -208,6 +209,19 @@ exports.cleanVm = async function cleanVm( | |||
} | |||
vhdChildren[parent] = path | |||
} | |||
const duplicate = vhdIds.get(vhd.footer.uuid) | |||
if (duplicate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per current XO coding style: never rely on implicit boolean conversation, ie explicit comparison.
@xen-orchestra/backups/_cleanVm.js
Outdated
@@ -189,6 +189,7 @@ exports.cleanVm = async function cleanVm( | |||
const vhdsToJSons = new Set() | |||
const vhdParents = { __proto__: null } | |||
const vhdChildren = { __proto__: null } | |||
const vhdIds = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const vhdIds = new Map() | |
const vhdById = new Map() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise I think it's a set when reading the code 🙂
const duplicate = vhdById.get(vhd.footer.uuid) | ||
if (duplicate !== undefined) { | ||
logWarn('uuid is duplicated', { uuid: vhd.footer.uuid }) | ||
if (duplicate.containsAllDataOf(vhd)) { | ||
logWarn(`should delete ${path}`) | ||
} else if (vhd.containsAllDataOf(duplicate)) { | ||
logWarn(`should delete ${duplicate._path}`) | ||
} else { | ||
logWarn(`same ids but different content`) | ||
} | ||
} | ||
vhdById.set(vhd.footer.uuid, vhd) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to release this in prod?
- xo-web minor | ||
- vhd-lib minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alphabetic order please 🙂
supeseed by #6317 |
… the same data
Check list
Fixes #007
orSee xoa-support#42
)CHANGELOG.unreleased.md
:${name} v${new version}
)cron/parse.spec.js
)xo-server
API changes, the corresponding test has been added to/updated onxo-server-test
Process
WiP:
(Work in Progress) if not ready to be mergedFrom the Four Agreements: