Prevent error in redundancy scheduler
This commit is contained in:
parent
eb8da03d1c
commit
91c72729d8
1 changed files with 17 additions and 4 deletions
|
@ -115,16 +115,29 @@ export class VideosRedundancyScheduler extends AbstractScheduler {
|
||||||
for (const redundancyModel of expired) {
|
for (const redundancyModel of expired) {
|
||||||
try {
|
try {
|
||||||
const redundancyConfig = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy)
|
const redundancyConfig = CONFIG.REDUNDANCY.VIDEOS.STRATEGIES.find(s => s.strategy === redundancyModel.strategy)
|
||||||
|
|
||||||
|
// If the admin disabled the redundancy, remove this redundancy instead of extending it
|
||||||
|
if (!redundancyConfig) {
|
||||||
|
logger.info(
|
||||||
|
'Destroying redundancy %s because the redundancy %s does not exist anymore.',
|
||||||
|
redundancyModel.url, redundancyModel.strategy
|
||||||
|
)
|
||||||
|
|
||||||
|
await removeVideoRedundancy(redundancyModel)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
const { totalUsed } = await VideoRedundancyModel.getStats(redundancyConfig.strategy)
|
const { totalUsed } = await VideoRedundancyModel.getStats(redundancyConfig.strategy)
|
||||||
|
|
||||||
// If the administrator disabled the redundancy or decreased the cache size, remove this redundancy instead of extending it
|
// If the admin decreased the cache size, remove this redundancy instead of extending it
|
||||||
if (!redundancyConfig || totalUsed > redundancyConfig.size) {
|
if (totalUsed > redundancyConfig.size) {
|
||||||
logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy)
|
logger.info('Destroying redundancy %s because the cache size %s is too heavy.', redundancyModel.url, redundancyModel.strategy)
|
||||||
|
|
||||||
await removeVideoRedundancy(redundancyModel)
|
await removeVideoRedundancy(redundancyModel)
|
||||||
} else {
|
continue
|
||||||
await this.extendsRedundancy(redundancyModel)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.extendsRedundancy(redundancyModel)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(
|
logger.error(
|
||||||
'Cannot extend or remove expiration of %s video from our redundancy system.',
|
'Cannot extend or remove expiration of %s video from our redundancy system.',
|
||||||
|
|
Loading…
Reference in a new issue