feat(xo-server/pool): disable scheduled job when starting RPU (#6244)
See zammad#5377, zammad#5333
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
> Users must be able to say: “Nice enhancement, I'm eager to test it”
|
||||
|
||||
- Created SRs will now have auto-scan enabled similarly to what XenCenter does (PR [#6246](https://github.com/vatesfr/xen-orchestra/pull/6246))
|
||||
- [RPU] Disable scheduled backup jobs during RPU (PR [#6244](https://github.com/vatesfr/xen-orchestra/pull/6244))
|
||||
|
||||
### Bug fixes
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { asyncMap } from '@xen-orchestra/async-map'
|
||||
import { createLogger } from '@xen-orchestra/log'
|
||||
import { createPredicate } from 'value-matcher'
|
||||
import { defer as deferrable } from 'golike-defer'
|
||||
import { extractIdsFromSimplePattern } from '@xen-orchestra/backups/extractIdsFromSimplePattern.js'
|
||||
import { format } from 'json-rpc-peer'
|
||||
import { Ref } from 'xen-api'
|
||||
import { incorrectState } from 'xo-common/api-errors.js'
|
||||
@@ -175,6 +177,44 @@ export const rollingUpdate = deferrable(async function ($defer, { bypassBackupCh
|
||||
await backupGuard.call(this, poolId)
|
||||
}
|
||||
|
||||
const poolId = pool.id
|
||||
const [schedules, jobs] = await Promise.all([this.getAllSchedules(), this.getAllJobs('backup')])
|
||||
|
||||
const jobsOfthePool = []
|
||||
jobs.forEach(({ id: jobId, vms }) => {
|
||||
if (vms.id !== undefined) {
|
||||
for (const vmId of extractIdsFromSimplePattern(vms)) {
|
||||
// try/catch to avoid `no such object`
|
||||
try {
|
||||
if (this.getObject(vmId).$poolId === poolId) {
|
||||
jobsOfthePool.push(jobId)
|
||||
break
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
} else {
|
||||
// Smart mode
|
||||
// For smart mode, we take a simplified approach:
|
||||
// - if smart mode is explicitly 'resident' or 'not resident' on pools, we
|
||||
// check if it concerns this pool
|
||||
// - if not, the job may concern this pool so we add it to `jobsOfThePool`
|
||||
if (vms.$pool === undefined || createPredicate(vms.$pool)(poolId)) {
|
||||
jobsOfthePool.push(jobId)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Disable schedules
|
||||
await Promise.all(
|
||||
schedules
|
||||
.filter(schedule => jobsOfthePool.includes(schedule.jobId) && schedule.enabled)
|
||||
.map(async schedule => {
|
||||
await this.updateSchedule({ ...schedule, enabled: false })
|
||||
$defer(() => this.updateSchedule({ ...schedule, enabled: true }))
|
||||
})
|
||||
)
|
||||
|
||||
// Disable load balancer
|
||||
if ((await this.getOptionalPlugin('load-balancer'))?.loaded) {
|
||||
await this.unloadPlugin('load-balancer')
|
||||
$defer(() => this.loadPlugin('load-balancer'))
|
||||
|
||||
@@ -1011,7 +1011,7 @@ const messages = {
|
||||
'This will automatically restart the toolstack on every host. Running VMs will not be affected. Are you sure you want to continue and install all the patches on this pool?',
|
||||
rollingPoolUpdate: 'Rolling pool update',
|
||||
rollingPoolUpdateMessage:
|
||||
'Are you sure you want to start a rolling pool update? Running VMs will be migrated back and forth and this can take a while.',
|
||||
'Are you sure you want to start a rolling pool update? Running VMs will be migrated back and forth and this can take a while. Scheduled backups that may concern this pool will be disabled.',
|
||||
rollingPoolUpdateHaWarning: 'High Availability is enabled. This will automatically disable it during the update.',
|
||||
rollingPoolUpdateLoadBalancerWarning:
|
||||
'Load Balancer plugin is running. This will automatically pause it during the update.',
|
||||
|
||||
Reference in New Issue
Block a user