feat(xen-api): limit concurrent calls to 20

Fixes xoa-support#3767

Can be changed via `callConcurrency` option.
This commit is contained in:
Julien Fontanet
2021-06-14 18:37:04 +02:00
parent dafa4ced27
commit 51f013851d
3 changed files with 5 additions and 0 deletions

View File

@@ -16,6 +16,7 @@
- [IPs] Handle space-delimited IP address format provided by outdated guest tools [5801](https://github.com/vatesfr/xen-orchestra/issues/5801) (PR [5805](https://github.com/vatesfr/xen-orchestra/pull/5805))
- [API/pool.listPoolsMatchingCriteria] fix `unknown error from the peer` error (PR [5807](https://github.com/vatesfr/xen-orchestra/pull/5807))
- [Backup] Limit number of connections to hosts, which should reduce the occurences of `ECONNRESET`
### Packages to release

View File

@@ -38,6 +38,7 @@
"jest-diff": "^26.4.2",
"json-rpc-protocol": "^0.13.1",
"kindof": "^2.0.0",
"limit-concurrency-decorator": "^0.5.0",
"lodash": "^4.17.4",
"make-error": "^1.3.0",
"minimist": "^1.2.0",

View File

@@ -7,6 +7,7 @@ import { Collection } from 'xo-collection'
import { EventEmitter } from 'events'
import { map, noop, omit } from 'lodash'
import { cancelable, defer, fromCallback, fromEvents, ignoreErrors, pDelay, pRetry, pTimeout } from 'promise-toolbox'
import { limitConcurrency } from 'limit-concurrency-decorator'
import autoTransport from './transports/auto'
import coalesceCalls from './_coalesceCalls'
@@ -88,6 +89,8 @@ export class Xapi extends EventEmitter {
this._RecordsByType = { __proto__: null }
this._reverseHostIpAddresses = opts.reverseHostIpAddresses ?? false
this._call = limitConcurrency(opts.callConcurrency ?? 20)(this._call)
this._roCallRetryOptions = {
delay: 1e3,
tries: 10,