aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-16 14:29:53 +0200
committerChocobozzz <me@florianbigard.com>2022-06-16 14:29:53 +0200
commit3256771725430ab6fc716e937b88ca2b2b85263b (patch)
tree5ab8e20c9646740cd12151592541af6997ca6d63 /server
parent0c9a83546687d2ae80b3f5299a8ee59d741f894f (diff)
downloadPeerTube-3256771725430ab6fc716e937b88ca2b2b85263b.tar.gz
PeerTube-3256771725430ab6fc716e937b88ca2b2b85263b.tar.zst
PeerTube-3256771725430ab6fc716e937b88ca2b2b85263b.zip
More robust move to object storage job failure
Diffstat (limited to 'server')
-rw-r--r--server/lib/job-queue/handlers/move-to-object-storage.ts17
-rw-r--r--server/lib/job-queue/job-queue.ts11
2 files changed, 23 insertions, 5 deletions
diff --git a/server/lib/job-queue/handlers/move-to-object-storage.ts b/server/lib/job-queue/handlers/move-to-object-storage.ts
index f480b32cd..49064052c 100644
--- a/server/lib/job-queue/handlers/move-to-object-storage.ts
+++ b/server/lib/job-queue/handlers/move-to-object-storage.ts
@@ -48,15 +48,24 @@ export async function processMoveToObjectStorage (job: Job) {
48 await doAfterLastJob({ video, previousVideoState: payload.previousVideoState, isNewVideo: payload.isNewVideo }) 48 await doAfterLastJob({ video, previousVideoState: payload.previousVideoState, isNewVideo: payload.isNewVideo })
49 } 49 }
50 } catch (err) { 50 } catch (err) {
51 logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTags }) 51 await onMoveToObjectStorageFailure(job, err)
52
53 await moveToFailedMoveToObjectStorageState(video)
54 await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')
55 } 52 }
56 53
57 return payload.videoUUID 54 return payload.videoUUID
58} 55}
59 56
57export async function onMoveToObjectStorageFailure (job: Job, err: any) {
58 const payload = job.data as MoveObjectStoragePayload
59
60 const video = await VideoModel.loadWithFiles(payload.videoUUID)
61 if (!video) return
62
63 logger.error('Cannot move video %s to object storage.', video.url, { err, ...lTagsBase(video.uuid, video.url) })
64
65 await moveToFailedMoveToObjectStorageState(video)
66 await VideoJobInfoModel.abortAllTasks(video.uuid, 'pendingMove')
67}
68
60// --------------------------------------------------------------------------- 69// ---------------------------------------------------------------------------
61 70
62async function moveWebTorrentFiles (video: MVideoWithAllFiles) { 71async function moveWebTorrentFiles (video: MVideoWithAllFiles) {
diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts
index d3776c3bf..61e41fb0f 100644
--- a/server/lib/job-queue/job-queue.ts
+++ b/server/lib/job-queue/job-queue.ts
@@ -33,7 +33,7 @@ import { refreshAPObject } from './handlers/activitypub-refresher'
33import { processActorKeys } from './handlers/actor-keys' 33import { processActorKeys } from './handlers/actor-keys'
34import { processEmail } from './handlers/email' 34import { processEmail } from './handlers/email'
35import { processManageVideoTorrent } from './handlers/manage-video-torrent' 35import { processManageVideoTorrent } from './handlers/manage-video-torrent'
36import { processMoveToObjectStorage } from './handlers/move-to-object-storage' 36import { onMoveToObjectStorageFailure, processMoveToObjectStorage } from './handlers/move-to-object-storage'
37import { processVideoFileImport } from './handlers/video-file-import' 37import { processVideoFileImport } from './handlers/video-file-import'
38import { processVideoImport } from './handlers/video-import' 38import { processVideoImport } from './handlers/video-import'
39import { processVideoLiveEnding } from './handlers/video-live-ending' 39import { processVideoLiveEnding } from './handlers/video-live-ending'
@@ -86,6 +86,10 @@ const handlers: { [id in JobType]: (job: Job) => Promise<any> } = {
86 'video-studio-edition': processVideoStudioEdition 86 'video-studio-edition': processVideoStudioEdition
87} 87}
88 88
89const errorHandlers: { [id in JobType]?: (job: Job, err: any) => Promise<any> } = {
90 'move-to-object-storage': onMoveToObjectStorageFailure
91}
92
89const jobTypes: JobType[] = [ 93const jobTypes: JobType[] = [
90 'activitypub-follow', 94 'activitypub-follow',
91 'activitypub-http-broadcast', 95 'activitypub-http-broadcast',
@@ -159,6 +163,11 @@ class JobQueue {
159 : 'error' 163 : 'error'
160 164
161 logger.log(logLevel, 'Cannot execute job %d in queue %s.', job.id, handlerName, { payload: job.data, err }) 165 logger.log(logLevel, 'Cannot execute job %d in queue %s.', job.id, handlerName, { payload: job.data, err })
166
167 if (errorHandlers[job.name]) {
168 errorHandlers[job.name](job, err)
169 .catch(err => logger.error('Cannot run error handler for job failure %d in queue %s.', job.id, handlerName, { err }))
170 }
162 }) 171 })
163 172
164 queue.on('error', err => { 173 queue.on('error', err => {