Skip to content

Commit

Permalink
feat(xapi/VDI_importContent): add SR name_label to task name_label (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ggunullu authored and fbeauchamp committed Oct 10, 2023
1 parent b86cb12 commit 2cb986b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions @vates/nbd-client/index.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from 'node:assert'
import { Socket } from 'node:net'
import { connect } from 'node:tls'
import { fromCallback, pRetry, pDelay, pTimeout } from 'promise-toolbox'
import { fromCallback, pRetry, pDelay, pTimeout, pFromCallback } from 'promise-toolbox'
import { readChunkStrict } from '@vates/read-chunk'
import { createLogger } from '@xen-orchestra/log'

Expand Down Expand Up @@ -112,18 +112,22 @@ export default class NbdClient {
}

async disconnect() {
warn('will try to disconnect', { serverAddress: this.#serverAddress })
if (!this.#connected) {
warn('was already disconnected', { serverAddress: this.#serverAddress })
return
}
warn('will really disconnect', { serverAddress: this.#serverAddress })

const buffer = Buffer.alloc(28)
buffer.writeInt32BE(NBD_REQUEST_MAGIC, 0) // it is a nbd request
buffer.writeInt16BE(0, 4) // no command flags for a disconnect
buffer.writeInt16BE(NBD_CMD_DISC, 6) // we want to disconnect from nbd server
await this.#write(buffer)
await this.#serverSocket.destroy()
warn('will send end buffer', { serverAddress: this.#serverAddress })
this.#connected = false // optimistically mark as disconnected to ensure we don' send another disconnection while handling this one
await pFromCallback(cb => this.#serverSocket.end(buffer, cb))
warn('end buffer sent', { serverAddress: this.#serverAddress })
this.#serverSocket = undefined
this.#connected = false
}

#clearReconnectPromise = () => {
Expand Down
2 changes: 1 addition & 1 deletion @xen-orchestra/xapi/vdi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Vdi {
error.SR = await this.getRecord('SR', vdi.SR)
error.VDI = vdi
error.nbdClient = nbdClient
nbdClient?.disconnect()
await nbdClient?.disconnect()
throw error
}
}
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@

> Users must be able to say: “I had this issue, happy to know it's fixed”
- [Backup/Mirror] Fix backup report not being sent (PR [#7049](https://github.com/vatesfr/xen-orchestra/pull/7049))
- [New VM] Only add MBR to cloud-init drive on Windows VMs to avoid booting issues (e.g. with Talos) (PR [#7050](https://github.com/vatesfr/xen-orchestra/pull/7050))
- [VDI Import] Add the SR name to the corresponding XAPI task (PR [#6979](https://github.com/vatesfr/xen-orchestra/pull/6979))

### Packages to release

> When modifying a package, add it here with its release type.
Expand Down

0 comments on commit 2cb986b

Please sign in to comment.