fix(xo-server-perf-alert): smart mode: select only running VMs and hosts (#5811)

This commit is contained in:
Rajaa.BARHTAOUI
2021-06-17 11:56:04 +02:00
committed by GitHub
parent 36c290ffea
commit 9a8138d07b
2 changed files with 15 additions and 7 deletions

View File

@@ -18,6 +18,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`
- [Plugins/perf-alert] All mode: only selects running hosts and VMs (PR [5811](https://github.com/vatesfr/xen-orchestra/pull/5811))
### Packages to release
@@ -40,5 +41,6 @@
- @xen-orchestra/xapi patch
- @xen-orchestra/backups patch
- @xen-orchestra/proxy patch
- xo-server-perf-alert patch
- xo-server patch
- xo-web minor

View File

@@ -1,6 +1,6 @@
import JSON5 from 'json5'
import { createSchedule } from '@xen-orchestra/cron'
import { forOwn, map, mean } from 'lodash'
import { filter, forOwn, map, mean } from 'lodash'
import { utcParse } from 'd3-time-format'
const XAPI_TO_XENCENTER = {
@@ -158,9 +158,9 @@ export const configurationSchema = {
type: 'object',
properties: {
smartMode: {
title: 'All hosts',
title: 'All running hosts',
type: 'boolean',
description: 'When enabled, all hosts will be considered for the alert.',
description: 'When enabled, all running hosts will be considered for the alert.',
default: false,
},
uuids: {
@@ -218,9 +218,9 @@ export const configurationSchema = {
type: 'object',
properties: {
smartMode: {
title: 'All VMs',
title: 'All running VMs',
type: 'boolean',
description: 'When enabled, all VMs will be considered for the alert.',
description: 'When enabled, all running VMs will be considered for the alert.',
default: false,
},
uuids: {
@@ -419,7 +419,8 @@ ${monitorBodies.join('\n')}`
}
_parseDefinition(definition) {
const lcObjectType = definition.objectType.toLowerCase()
const { objectType } = definition
const lcObjectType = objectType.toLowerCase()
const alarmId = `${lcObjectType}|${definition.variableName}|${definition.alarmTriggerLevel}`
const typeFunction = TYPE_FUNCTION_MAP[lcObjectType][definition.variableName]
const parseData = (result, uuid) => {
@@ -470,7 +471,12 @@ ${monitorBodies.join('\n')}`
return Promise.all(
map(
definition.smartMode
? map(this._xo.getObjects({ filter: { type: definition.objectType } }), obj => obj.uuid)
? filter(
this._xo.getObjects(),
obj =>
obj.type === objectType &&
((objectType !== 'VM' && objectType !== 'host') || obj.power_state === 'Running')
).map(obj => obj.uuid)
: definition.uuids,
async uuid => {
try {