Compare commits

...

7 Commits

Author SHA1 Message Date
Mohamedox
6bf2399495 adapt to PR comments 2019-06-27 17:03:08 +02:00
Mohamedox
76fb2a159d fix 2019-06-27 16:09:52 +02:00
Mohamedox
f8a7249e32 fix 2019-06-27 15:16:30 +02:00
Mohamedox
4c2dd689e4 fix 2019-06-27 15:03:55 +02:00
Mohamedox
456e55d54a add enable/disable button 2019-06-27 14:16:31 +02:00
Mohamedox
862e382c12 chore(xen-server/xen-servers): disconnect server if events not been fetched since 5 minutes 2019-06-27 12:09:47 +02:00
Mohamedox
203a5c681e feat(xen-api): Expose last (successful/failed) events time 2019-06-26 16:38:36 +02:00
6 changed files with 34 additions and 6 deletions

View File

@@ -12,6 +12,7 @@
- [Host] Display warning when host's time differs too much from XOA's time [#4113](https://github.com/vatesfr/xen-orchestra/issues/4113) (PR [#4173](https://github.com/vatesfr/xen-orchestra/pull/4173)) - [Host] Display warning when host's time differs too much from XOA's time [#4113](https://github.com/vatesfr/xen-orchestra/issues/4113) (PR [#4173](https://github.com/vatesfr/xen-orchestra/pull/4173))
- [Host/storages, SR/hosts] Display PBD details [#4264](https://github.com/vatesfr/xen-orchestra/issues/4161) (PR [#4268](https://github.com/vatesfr/xen-orchestra/pull/4284)) - [Host/storages, SR/hosts] Display PBD details [#4264](https://github.com/vatesfr/xen-orchestra/issues/4161) (PR [#4268](https://github.com/vatesfr/xen-orchestra/pull/4284))
- [VM/network] Display and set bandwidth rate-limit of a VIF [#4215](https://github.com/vatesfr/xen-orchestra/issues/4215) (PR [#4293](https://github.com/vatesfr/xen-orchestra/pull/4293)) - [VM/network] Display and set bandwidth rate-limit of a VIF [#4215](https://github.com/vatesfr/xen-orchestra/issues/4215) (PR [#4293](https://github.com/vatesfr/xen-orchestra/pull/4293))
- [Settings/servers] Display servers connection issues [#4300](https://github.com/vatesfr/xen-orchestra/issues/4300) (PR [#4310](https://github.com/vatesfr/xen-orchestra/pull/4310))
### Bug fixes ### Bug fixes
@@ -20,6 +21,7 @@
### Released packages ### Released packages
- xen-api v0.26.0
- xo-server-auth-saml v0.6.0 - xo-server-auth-saml v0.6.0
- xo-server-backup-reports v0.16.2 - xo-server-backup-reports v0.16.2
- xo-server v5.44.0 - xo-server v5.44.0

View File

@@ -99,6 +99,9 @@ export class Xapi extends EventEmitter {
this._sessionId = undefined this._sessionId = undefined
this._status = DISCONNECTED this._status = DISCONNECTED
this._lastCatchedEventError = null
this._lastSuccessfulFetchTime = undefined
this._debounce = opts.debounce ?? 200 this._debounce = opts.debounce ?? 200
this._objects = new Collection() this._objects = new Collection()
this._objectsByRef = { __proto__: null } this._objectsByRef = { __proto__: null }
@@ -585,6 +588,14 @@ export class Xapi extends EventEmitter {
throw new Error('no object with UUID: ' + uuid) throw new Error('no object with UUID: ' + uuid)
} }
get lastCatchedEventError() {
return this._lastCatchedEventError
}
get lastSuccessfulFetchTime() {
return this._lastSuccessfulFetchTime
}
// manually run events watching if set to `false` in constructor // manually run events watching if set to `false` in constructor
watchEvents() { watchEvents() {
ignoreErrors.call(this._watchEvents()) ignoreErrors.call(this._watchEvents())
@@ -945,12 +956,14 @@ export class Xapi extends EventEmitter {
], ],
EVENT_TIMEOUT * 1e3 * 1.1 EVENT_TIMEOUT * 1e3 * 1.1
) )
this._lastSuccessfulFetchTime = Date.now()
} catch (error) { } catch (error) {
if (error?.code === 'EVENTS_LOST') { if (error?.code === 'EVENTS_LOST') {
// eslint-disable-next-line no-labels // eslint-disable-next-line no-labels
continue mainLoop continue mainLoop
} }
this._lastCatchedEventError = error
console.warn('_watchEvents', error) console.warn('_watchEvents', error)
await pDelay(this._eventPollDelay) await pDelay(this._eventPollDelay)
continue continue

View File

@@ -87,5 +87,8 @@ mountsDir = '/run/xo-server/mounts'
# timeout in milliseconds (set to 0 to disable) # timeout in milliseconds (set to 0 to disable)
timeout = 600e3 timeout = 600e3
# timeout before reporting server issue
noEventsTimeout = '5 minutes'
# see https:#github.com/vatesfr/xen-orchestra/issues/3419 # see https:#github.com/vatesfr/xen-orchestra/issues/3419
# useSudo = false # useSudo = false

View File

@@ -5,6 +5,7 @@ import { noSuchObject } from 'xo-common/api-errors'
import { pDelay, ignoreErrors } from 'promise-toolbox' import { pDelay, ignoreErrors } from 'promise-toolbox'
import * as XenStore from '../_XenStore' import * as XenStore from '../_XenStore'
import parseDuration from '../_parseDuration'
import Xapi from '../xapi' import Xapi from '../xapi'
import xapiObjectToXo from '../xapi-object-to-xo' import xapiObjectToXo from '../xapi-object-to-xo'
import XapiStats from '../xapi-stats' import XapiStats from '../xapi-stats'
@@ -41,7 +42,7 @@ const log = createLogger('xo:xo-mixins:xen-servers')
// - _xapis[server.id] id defined // - _xapis[server.id] id defined
// - _serverIdsByPool[xapi.pool.$id] is server.id // - _serverIdsByPool[xapi.pool.$id] is server.id
export default class { export default class {
constructor(xo, { guessVhdSizeOnImport, xapiOptions }) { constructor(xo, { guessVhdSizeOnImport, noEventsTimeout, xapiOptions }) {
this._objectConflicts = { __proto__: null } // TODO: clean when a server is disconnected. this._objectConflicts = { __proto__: null } // TODO: clean when a server is disconnected.
const serversDb = (this._servers = new Servers({ const serversDb = (this._servers = new Servers({
connection: xo._redis, connection: xo._redis,
@@ -56,6 +57,7 @@ export default class {
} }
this._xapis = { __proto__: null } this._xapis = { __proto__: null }
this._xo = xo this._xo = xo
this._noEventsTimeout = parseDuration(noEventsTimeout)
xo.on('clean', () => serversDb.rebuildIndexes()) xo.on('clean', () => serversDb.rebuildIndexes())
xo.on('start', async () => { xo.on('start', async () => {
@@ -473,6 +475,11 @@ export default class {
const servers = await this._servers.get() const servers = await this._servers.get()
const xapis = this._xapis const xapis = this._xapis
forEach(servers, server => { forEach(servers, server => {
const lastSuccessfulFetchTime = xapis[server.id]?.lastSuccessfulFetchTime
const currentTime = new Date().getTime()
if (currentTime > lastSuccessfulFetchTime + this._noEventsTimeout) {
server.error = xapis[server.id].lastCatchedEventError
}
server.status = this._getXenServerStatus(server.id) server.status = this._getXenServerStatus(server.id)
if (server.status === 'connected') { if (server.status === 'connected') {
server.poolId = xapis[server.id].pool.uuid server.poolId = xapis[server.id].pool.uuid

View File

@@ -1676,6 +1676,9 @@ const messages = {
serverSelfSignedCertError: 'Invalid self-signed certificate', serverSelfSignedCertError: 'Invalid self-signed certificate',
serverSelfSignedCertQuestion: serverSelfSignedCertQuestion:
'Do you want to accept self-signed certificate for this server even though it would decrease security?', 'Do you want to accept self-signed certificate for this server even though it would decrease security?',
serverEnabled: 'Enabled',
serverDisabled: 'Disabled',
serverDisable: 'Disable server',
// ----- Copy VM ----- // ----- Copy VM -----
copyVm: 'Copy VM', copyVm: 'Copy VM',

View File

@@ -100,17 +100,17 @@ const COLUMNS = [
itemRenderer: server => ( itemRenderer: server => (
<div> <div>
<StateButton <StateButton
disabledLabel={_('serverDisconnected')} disabledLabel={_('serverDisabled')}
disabledHandler={connectServer} disabledHandler={connectServer}
disabledTooltip={_('serverConnect')} disabledTooltip={_('serverDisabled')}
enabledLabel={_('serverConnected')} enabledLabel={_('serverEnabled')}
enabledHandler={disconnectServer} enabledHandler={disconnectServer}
enabledTooltip={_('serverDisconnect')} enabledTooltip={_('serverDisable')}
handlerParam={server} handlerParam={server}
pending={server.status === 'connecting'} pending={server.status === 'connecting'}
state={server.status === 'connected'} state={server.status === 'connected'}
/>{' '} />{' '}
{server.error && ( {server.status === 'connected' && server.error && (
<Tooltip content={_('serverConnectionFailed')}> <Tooltip content={_('serverConnectionFailed')}>
<a <a
className='text-danger btn btn-link btn-sm' className='text-danger btn btn-link btn-sm'