chore(xen-api/_sessionCall): dont use _interruptOnDisconnect

This commit is contained in:
Julien Fontanet 2019-04-04 13:39:21 +02:00
parent 975de1954e
commit 7289e856d9

View File

@ -680,11 +680,20 @@ export class Xapi extends EventEmitter {
])
}
async _sessionCall(method, args, timeout) {
_sessionCallRetryOptions = {
tries: 2,
when: error =>
this._status !== DISCONNECTED && error?.code === 'SESSION_INVALID',
onRetry: () => this._sessionOpen(),
}
_sessionCall(method, args, timeout) {
if (method.startsWith('session.')) {
throw new Error('session.*() methods are disabled from this interface')
return Promise.reject(
new Error('session.*() methods are disabled from this interface')
)
}
return pRetry(() => {
const sessionId = this._sessionId
assert.notStrictEqual(sessionId, undefined)
@ -693,14 +702,8 @@ export class Xapi extends EventEmitter {
newArgs.push.apply(newArgs, args)
}
return pRetry(
() => this._interruptOnDisconnect(this._call(method, newArgs, timeout)),
{
tries: 2,
when: { code: 'SESSION_INVALID' },
onRetry: () => this._sessionOpen(),
}
)
return this._call(method, newArgs, timeout)
}, this._sessionCallRetryOptions)
}
// FIXME: (probably rare) race condition leading to unnecessary login when: