fix(package): upgrade golike-defer to v0.1.0 (#555)

Errors are automatically caught and reported.
This commit is contained in:
Julien Fontanet 2017-05-29 10:46:41 +02:00 committed by GitHub
parent 039075736c
commit 83f3fcd913
6 changed files with 28 additions and 26 deletions

View File

@ -62,7 +62,7 @@
"fatfs": "^0.10.4", "fatfs": "^0.10.4",
"from2": "^2.3.0", "from2": "^2.3.0",
"fs-extra": "^3.0.1", "fs-extra": "^3.0.1",
"golike-defer": "^0.0.0", "golike-defer": "^0.1.0",
"hashy": "~0.6.1", "hashy": "~0.6.1",
"helmet": "^3.6.0", "helmet": "^3.6.0",
"highland": "^2.10.5", "highland": "^2.10.5",

View File

@ -6,14 +6,14 @@ import fromPairs from 'lodash/fromPairs'
import fs from 'fs-extra' import fs from 'fs-extra'
import map from 'lodash/map' import map from 'lodash/map'
import splitLines from 'split-lines' import splitLines from 'split-lines'
import { tap } from 'promise-toolbox'
import { import {
filter, filter,
includes includes
} from 'lodash' } from 'lodash'
import { import {
noop, asyncMap,
pCatch,
pFromCallback, pFromCallback,
splitFirst splitFirst
} from '../utils' } from '../utils'
@ -185,7 +185,7 @@ const createNetworkAndInsertHosts = defer.onFailure(async function ($onFailure,
mtu: 9000, mtu: 9000,
vlan: +vlan vlan: +vlan
}) })
$onFailure(() => xapi.deleteNetwork(xosanNetwork)::pCatch(noop)) $onFailure(() => xapi.deleteNetwork(xosanNetwork))
await Promise.all(xosanNetwork.$PIFs.map(pif => setPifIp(xapi, pif, NETWORK_PREFIX + (hostIpLastNumber++)))) await Promise.all(xosanNetwork.$PIFs.map(pif => setPifIp(xapi, pif, NETWORK_PREFIX + (hostIpLastNumber++))))
return xosanNetwork return xosanNetwork
@ -272,7 +272,7 @@ export const createSR = defer.onFailure(async function ($onFailure, { template,
CURRENTLY_CREATING_SRS[xapi.pool.$id] = true CURRENTLY_CREATING_SRS[xapi.pool.$id] = true
try { try {
const xosanNetwork = await createNetworkAndInsertHosts(xapi, pif, vlan) const xosanNetwork = await createNetworkAndInsertHosts(xapi, pif, vlan)
$onFailure(() => xapi.deleteNetwork(xosanNetwork)::pCatch(noop)) $onFailure(() => xapi.deleteNetwork(xosanNetwork))
const sshKey = await getOrCreateSshKey(xapi) const sshKey = await getOrCreateSshKey(xapi)
const srsObjects = map(srs, srId => xapi.getObject(srId)) const srsObjects = map(srs, srId => xapi.getObject(srId))
@ -304,13 +304,15 @@ export const createSR = defer.onFailure(async function ($onFailure, { template,
await this.requestResource('xosan', template.id, template.version), await this.requestResource('xosan', template.id, template.version),
{ srId: vmParameters[0].sr.$ref, type: 'xva' } { srId: vmParameters[0].sr.$ref, type: 'xva' }
) )
$onFailure(() => xapi.deleteVm(firstVM)::pCatch(noop)) $onFailure(() => xapi.deleteVm(firstVM))
await xapi.editVm(firstVM, { await xapi.editVm(firstVM, {
autoPoweron: true autoPoweron: true
}) })
const copiedVms = await Promise.all(vmParameters.slice(1).map(param => copyVm(xapi, firstVM, param))) const copiedVms = await asyncMap(vmParameters.slice(1), param =>
// TODO: Promise.all() is certainly not the right operation to execute all the given promises whether they fulfill or reject. copyVm(xapi, firstVM, param)::tap(({ vm }) =>
$onFailure(() => Promise.all(copiedVms.map(vm => xapi.deleteVm(vm.vm)::pCatch(noop)))) $onFailure(() => xapi.deleteVm(vm))
)
)
const vmsAndParams = [{ const vmsAndParams = [{
vm: firstVM, vm: firstVM,
params: vmParameters[0] params: vmParameters[0]
@ -332,7 +334,7 @@ export const createSR = defer.onFailure(async function ($onFailure, { template,
} }
} }
const arbiterVm = await copyVm(xapi, firstVM, arbiterConfig) const arbiterVm = await copyVm(xapi, firstVM, arbiterConfig)
$onFailure(() => xapi.deleteVm(arbiterVm.vm)::pCatch(noop)) $onFailure(() => xapi.deleteVm(arbiterVm.vm))
arbiter = await prepareGlusterVm(xapi, arbiterVm, xosanNetwork, false) arbiter = await prepareGlusterVm(xapi, arbiterVm, xosanNetwork, false)
} }
const ipAndHosts = await Promise.all(map(vmsAndParams, vmAndParam => prepareGlusterVm(xapi, vmAndParam, xosanNetwork))) const ipAndHosts = await Promise.all(map(vmsAndParams, vmAndParam => prepareGlusterVm(xapi, vmAndParam, xosanNetwork)))
@ -345,7 +347,7 @@ export const createSR = defer.onFailure(async function ($onFailure, { template,
ipAndHosts.push(arbiter) ipAndHosts.push(arbiter)
} }
// we just forget because the cleanup actions will be executed before. // we just forget because the cleanup actions will be executed before.
$onFailure(() => xapi.forgetSr(xosanSr)::pCatch(noop)) $onFailure(() => xapi.forgetSr(xosanSr))
await xapi.xo.setData(xosanSr, 'xosan_config', { await xapi.xo.setData(xosanSr, 'xosan_config', {
nodes: ipAndHosts.map(param => ({ nodes: ipAndHosts.map(param => ({
host: param.host.$id, host: param.host.$id,

View File

@ -825,7 +825,7 @@ export default class Xapi extends XapiBase {
this._assertHealthyVdiChains(this.getObject(vmId)) this._assertHealthyVdiChains(this.getObject(vmId))
const vm = await this.snapshotVm(vmId) const vm = await this.snapshotVm(vmId)
$onFailure(() => this._deleteVm(vm)::pCatch(noop)) $onFailure(() => this._deleteVm(vm))
if (snapshotNameLabel) { if (snapshotNameLabel) {
this._setObjectProperties(vm, { this._setObjectProperties(vm, {
nameLabel: snapshotNameLabel nameLabel: snapshotNameLabel
@ -896,7 +896,7 @@ export default class Xapi extends XapiBase {
$SR$uuid: vdi.$SR.uuid $SR$uuid: vdi.$SR.uuid
} }
const stream = streams[`${vdiRef}.vhd`] = this._exportVdi(vdi, baseVdi, VDI_FORMAT_VHD) const stream = streams[`${vdiRef}.vhd`] = this._exportVdi(vdi, baseVdi, VDI_FORMAT_VHD)
$onFailure(() => stream.cancel()::pCatch(noop)) $onFailure(() => stream.cancel())
}) })
const vifs = {} const vifs = {}
@ -972,7 +972,7 @@ export default class Xapi extends XapiBase {
is_a_template: false is_a_template: false
}) })
) )
$onFailure(() => this._deleteVm(vm)::pCatch(noop)) $onFailure(() => this._deleteVm(vm))
await Promise.all([ await Promise.all([
this._setObjectProperties(vm, { this._setObjectProperties(vm, {
@ -1005,7 +1005,7 @@ export default class Xapi extends XapiBase {
}, },
sr: sr.$id sr: sr.$id
}) })
$onFailure(() => this._deleteVdi(newVdi)::pCatch(noop)) $onFailure(() => this._deleteVdi(newVdi))
return newVdi return newVdi
} }
@ -1021,7 +1021,7 @@ export default class Xapi extends XapiBase {
const newVdi = await this._getOrWaitObject( const newVdi = await this._getOrWaitObject(
await this._cloneVdi(baseVdi) await this._cloneVdi(baseVdi)
) )
$onFailure(() => this._deleteVdi(newVdi)::pCatch(noop)) $onFailure(() => this._deleteVdi(newVdi))
await this._updateObjectMapProperty(newVdi, 'other_config', { await this._updateObjectMapProperty(newVdi, 'other_config', {
[TAG_COPY_SRC]: vdi.uuid [TAG_COPY_SRC]: vdi.uuid
@ -1292,7 +1292,7 @@ export default class Xapi extends XapiBase {
VCPUs_max: nCpus VCPUs_max: nCpus
}) })
) )
$onFailure(() => this._deleteVm(vm)::pCatch(noop)) $onFailure(() => this._deleteVm(vm))
// Disable start and change the VM name label during import. // Disable start and change the VM name label during import.
await Promise.all([ await Promise.all([
this.addForbiddenOperationToVm(vm.$id, 'start', 'OVA import in progress...'), this.addForbiddenOperationToVm(vm.$id, 'start', 'OVA import in progress...'),
@ -1309,7 +1309,7 @@ export default class Xapi extends XapiBase {
name_label: disk.nameLabel, name_label: disk.nameLabel,
sr: sr.$ref sr: sr.$ref
}) })
$onFailure(() => this._deleteVdi(vdi)::pCatch(noop)) $onFailure(() => this._deleteVdi(vdi))
return this._createVbd(vm, vdi, { position: disk.position }) return this._createVbd(vm, vdi, { position: disk.position })
}).concat(map(networks, (networkId, i) => ( }).concat(map(networks, (networkId, i) => (
@ -2185,7 +2185,7 @@ export default class Xapi extends XapiBase {
name_label, name_label,
name_description name_description
}) })
$onFailure(() => this._deleteVdi(vdi)::pCatch(noop)) $onFailure(() => this._deleteVdi(vdi))
await this.importVdiContent(vdi.$id, stream, { format: VDI_FORMAT_RAW }) await this.importVdiContent(vdi.$id, stream, { format: VDI_FORMAT_RAW })

View File

@ -58,7 +58,7 @@ export default {
// Clones the template. // Clones the template.
const vmRef = await this[clone ? '_cloneVm' : '_copyVm'](template, nameLabel) const vmRef = await this[clone ? '_cloneVm' : '_copyVm'](template, nameLabel)
$onFailure(() => this.deleteVm(vmRef)::pCatch(noop)) $onFailure(() => this.deleteVm(vmRef))
// TODO: copy BIOS strings? // TODO: copy BIOS strings?

View File

@ -845,7 +845,7 @@ export default class {
const backupFormat = `${date}_${vm.name_label}` const backupFormat = `${date}_${vm.name_label}`
const infoPath = `${dir}/${backupFormat}${DELTA_BACKUP_EXT}` const infoPath = `${dir}/${backupFormat}${DELTA_BACKUP_EXT}`
$onFailure(() => handler.unlink(infoPath)::pCatch(noop)) $onFailure(() => handler.unlink(infoPath))
// Write Metadata. // Write Metadata.
await handler.outputFile(infoPath, JSON.stringify(delta, null, 2)) await handler.outputFile(infoPath, JSON.stringify(delta, null, 2))

View File

@ -2913,9 +2913,9 @@ glogg@^1.0.0:
dependencies: dependencies:
sparkles "^1.0.0" sparkles "^1.0.0"
golike-defer@^0.0.0: golike-defer@^0.1.0:
version "0.0.0" version "0.1.0"
resolved "https://registry.yarnpkg.com/golike-defer/-/golike-defer-0.0.0.tgz#2de7ae0cb812b58aa7d8735b4ba69d4169098cf2" resolved "https://registry.yarnpkg.com/golike-defer/-/golike-defer-0.1.0.tgz#70a3d8991cdfe41845956bfb578f69bc3e49f525"
graceful-fs@4.X, graceful-fs@^4.0.0, graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: graceful-fs@4.X, graceful-fs@^4.0.0, graceful-fs@^4.1.0, graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
version "4.1.11" version "4.1.11"
@ -4435,11 +4435,11 @@ ltgt@^2.1.2, ltgt@~2.1.1:
version "2.1.3" version "2.1.3"
resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34" resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.1.3.tgz#10851a06d9964b971178441c23c9e52698eece34"
make-error@^1, make-error@^1.0.2, make-error@^1.2.1, make-error@^1.2.2: make-error@^1, make-error@^1.2.2:
version "1.2.3" version "1.2.3"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.2.3.tgz#6c4402df732e0977ac6faf754a5074b3d2b1d19d" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.2.3.tgz#6c4402df732e0977ac6faf754a5074b3d2b1d19d"
make-error@^1.2.0, make-error@^1.3.0: make-error@^1.0.2, make-error@^1.2.0, make-error@^1.2.1, make-error@^1.3.0:
version "1.3.0" version "1.3.0"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.0.tgz#52ad3a339ccf10ce62b4040b708fe707244b8b96" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.0.tgz#52ad3a339ccf10ce62b4040b708fe707244b8b96"