fix(xo-server): race condition on XOA WebSocket during plugin loading (#9402)

This commit is contained in:
Mathieu
2026-03-09 09:42:53 +01:00
committed by GitHub
parent 385fcf3810
commit 57aec1ab2d
2 changed files with 18 additions and 5 deletions

View File

@@ -16,6 +16,7 @@
> Users must be able to say: “I had this issue, happy to know it's fixed”
- [Backup] snapshots of VM with a CDROM mounted are not removed (PR [#9570](https://github.com/vatesfr/xen-orchestra/pull/9570))
- [OpenMetrics] Fix plugin failing to auto-start after xo-server restart due to XOA WebSocket connection race condition (PR [#9402](https://github.com/vatesfr/xen-orchestra/pull/9402))
- **XO 5**:
- [Self Service] Fix RAM usage not being properly updated in some cases. Please use "Recompute all limits" in the Self Service dashboard to fix any incorrect quota values introduced by this bug. (PR [#9566](https://github.com/vatesfr/xen-orchestra/pull/9566))

View File

@@ -1,6 +1,10 @@
import get from 'lodash/get.js'
import { featureUnauthorized } from 'xo-common/api-errors.js'
import assert from 'assert'
import get from 'lodash/get.js'
import { createLogger } from '@xen-orchestra/log'
import { featureUnauthorized } from 'xo-common/api-errors.js'
import { retry } from 'promise-toolbox'
const log = createLogger('xo:authorization')
const FREE = 1
const STARTER = 2
@@ -53,9 +57,17 @@ export default class Authorization {
}
async #getCurrentPlan() {
const plan = await this.#app.getXoaPlan()
assert.notEqual(PLANS[plan], undefined, `plan ${plan} is not defined in the PLANS object`)
const plan = await retry(() => this.#app.getXoaPlan(), {
when: error => error.message?.includes('invalid status connecting'),
onRetry(error) {
log.warn('XOA connection not ready, retrying', {
attempt: this.attemptNumber,
delay: this.delay,
error,
})
},
})
assert.notEqual(PLANS[plan], undefined, `plan ${plan} is not defined in the PLANS object`)
return PLANS[plan]
}