Skip to content

Commit

Permalink
Changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Pizzosaure authored and julien-f committed Nov 20, 2023
1 parent 7e4c7f1 commit e851ec3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/xo-server/src/xo-mixins/resource-sets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,10 @@ export default class {
}

await xapi.xo.setData(vmId, 'resourceSet', resourceSetId === undefined ? null : resourceSetId)
await xapi.barrier(xapi.getObject(vmId).$ref)
// barrier function is used to ensure completion of previous asynchronous operations
// on the vmId object, guaranteeing that all modifications are considered before
// retrieving the resourceSetId value.
$defer.onFailure(() =>
xapi.xo.setData(vmId, 'resourceSet', previousResourceSetId === undefined ? null : previousResourceSetId)
)
Expand All @@ -444,9 +448,6 @@ export default class {

async shareVmResourceSet(vmId) {
const xapi = this._app.getXapi(vmId)
await xapi.barrier(xapi.getObject(vmId).$ref)
// barrier function is used to ensure completion of previous asynchronous operations
// on the vmId object, guaranteeing that all modifications are considered before retrieving the resourceSetId value.
const resourceSetId = xapi.xo.getData(vmId, 'resourceSet')
if (resourceSetId === undefined) {
throw new Error('the vm is not in a resource set')
Expand Down

0 comments on commit e851ec3

Please sign in to comment.