From 8e53e0b84478c8ce4f97affafb6a359925c72bdc Mon Sep 17 00:00:00 2001 From: Max Holland Date: Wed, 27 Sep 2023 09:24:41 +0100 Subject: [PATCH] Remove transcode and import tasks (#1891) * Remove transcode task This is no longer used and has been removed from task-runner * review comments * add missing docs back * fix www error * Fix event tab * Fix event tab --- packages/api/src/controllers/asset.ts | 80 +------------------ packages/api/src/controllers/playback.ts | 2 +- packages/api/src/middleware/auth.ts | 2 - packages/api/src/schema/api-schema.yaml | 35 +------- packages/api/src/task/scheduler.ts | 22 ----- .../AssetDetails/AssetEventLogTab.tsx | 14 ++-- 6 files changed, 11 insertions(+), 144 deletions(-) diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index 1084ee18c2..8e5c107e54 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -320,7 +320,6 @@ export function getStaticPlaybackInfo( } export function getPlaybackUrl( - { vodCatalystObjectStoreId }: CliArgs, ingest: string, asset: WithID, os: ObjectStore @@ -337,17 +336,7 @@ export function getPlaybackUrl( (f) => f.type === "catalyst_hls_manifest" ); if (catalystManifest) { - if (os.id !== vodCatalystObjectStoreId) { - return pathJoin(os.publicUrl, asset.playbackId, catalystManifest.path); - } - // TODO: Set up Catalyst playback or a CDN in front of the default object store. return pathJoin(os.publicUrl, asset.playbackId, catalystManifest.path); - // return pathJoin( - // "https://playback.livepeer.monster:10443/", // TODO: Make this a cli arg - // "hls", - // `asset+${asset.playbackId}`, - // "index.m3u8" - // ); } return undefined; } @@ -396,7 +385,7 @@ export async function withPlaybackUrls( ...(asset.status.phase === "ready" && { downloadUrl: getDownloadUrl(config, ingest, asset, os), }), - playbackUrl: getPlaybackUrl(config, ingest, asset, os), + playbackUrl: getPlaybackUrl(ingest, asset, os), }; } @@ -840,73 +829,6 @@ app.post( uploadWithUrlHandler ); -// /:id/transcode and /transcode routes registered right below -const transcodeAssetHandler: RequestHandler = async (req, res) => { - if (!req.params?.id && !req.body.assetId) { - // called from the old `/api/asset/transcode` endpoint - throw new BadRequestError( - "Missing `assetId` payload field of the input asset" - ); - } - if (req.params?.id && req.body.assetId) { - // called from the new `/api/asset/:assetId/transcode` endpoint - throw new BadRequestError( - "Field `assetId` is not allowed in payload when included in the URL" - ); - } - const assetId = req.params?.id || req.body.assetId; - - const inputAsset = await db.asset.get(assetId); - if (!inputAsset) { - throw new NotFoundError(`asset not found`); - } - - const id = uuid(); - const playbackId = await generateUniquePlaybackId(id); - let outputAsset = await validateAssetPayload( - id, - playbackId, - req.user.id, - Date.now(), - await defaultObjectStoreId(req, true), // transcode only in old pipeline for now - req.config, - { - name: req.body.name ?? inputAsset.name, - }, - { type: "transcode", inputAssetId: inputAsset.id } - ); - outputAsset.sourceAssetId = inputAsset.sourceAssetId ?? inputAsset.id; - - await ensureQueueCapacity(req.config, req.user.id); - outputAsset = await createAsset(outputAsset, req.queue); - - const task = await req.taskScheduler.createAndScheduleTask( - "transcode", - { - transcode: { - profile: req.body.profile, - }, - }, - inputAsset, - outputAsset - ); - res.status(201); - res.json({ asset: outputAsset, task: { id: task.id } }); -}; -app.post( - "/:id/transcode", - authorizer({}), - validatePost("transcode-asset-payload"), - transcodeAssetHandler -); -// TODO: Remove this at some point. Registered only for backward compatibility. -app.post( - "/transcode", - authorizer({}), - validatePost("transcode-asset-payload"), - transcodeAssetHandler -); - app.post( "/request-upload", authorizer({}), diff --git a/packages/api/src/controllers/playback.ts b/packages/api/src/controllers/playback.ts index 8692123011..4355baec55 100644 --- a/packages/api/src/controllers/playback.ts +++ b/packages/api/src/controllers/playback.ts @@ -84,7 +84,7 @@ const getAssetPlaybackInfo = async ( return null; } - const playbackUrl = assetPlaybackUrl(config, ingest, asset, os); + const playbackUrl = assetPlaybackUrl(ingest, asset, os); if (!playbackUrl) { return null; diff --git a/packages/api/src/middleware/auth.ts b/packages/api/src/middleware/auth.ts index 30aec8bc1d..1e9ca71b56 100644 --- a/packages/api/src/middleware/auth.ts +++ b/packages/api/src/middleware/auth.ts @@ -210,8 +210,6 @@ export const corsApiKeyAccessRules: AuthRule[] = [ resources: [ "/asset/upload/url", "/asset/request-upload", - "/asset/:id/transcode", - "/asset/transcode", // legacy, remove "/asset/:id/export", ], }, diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 3ce56d94ee..52e9ed5981 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -1377,10 +1377,8 @@ components: description: Type of the task enum: - upload - - import - export - export-data - - transcode - transcode-file createdAt: readOnly: true @@ -1418,14 +1416,6 @@ components: example: "https://cdn.livepeer.com/ABC123/filename.mp4" encryption: $ref: "#/components/schemas/new-asset-payload/properties/encryption" - recordedSessionId: - type: string - description: | - ID of the original recorded session to avoid re-transcoding - of the same content. Only used for import task. - example: 78df0075-b5f3-4683-a618-1086faca35dc - import: - $ref: "#/components/schemas/task/properties/params/properties/upload" export: $ref: "#/components/schemas/export-task-params" exportData: @@ -1446,12 +1436,6 @@ components: id: type: string description: Optional ID of the content - transcode: - additionalProperties: false - description: Parameters for the transcode task - properties: - profile: - $ref: "#/components/schemas/ffmpeg-profile" transcode-file: type: object additionalProperties: false @@ -1567,8 +1551,6 @@ components: writeOnly: true assetSpec: $ref: "#/components/schemas/asset" - import: - $ref: "#/components/schemas/task/properties/output/properties/upload" export: type: object additionalProperties: false @@ -1621,21 +1603,6 @@ components: cid: type: string description: IPFS CID of the exported data - transcode: - type: object - additionalProperties: false - properties: - asset: - type: object - additionalProperties: true - properties: - videoFilePath: - type: string - metadataFilePath: - type: string - assetSpec: - type: object - $ref: "#/components/schemas/asset" input-creator-id: oneOf: - $ref: "#/components/schemas/creator-id" @@ -3730,7 +3697,7 @@ paths: description: | Retrieves the details of a Task, including progress updates and status. Supply the unique Task ID that was returned from your previous request - or from an Asset import or export. + or from an Asset export. parameters: - in: path name: taskId diff --git a/packages/api/src/task/scheduler.ts b/packages/api/src/task/scheduler.ts index 51d087b3d7..8fce9b979d 100644 --- a/packages/api/src/task/scheduler.ts +++ b/packages/api/src/task/scheduler.ts @@ -129,7 +129,6 @@ export class TaskScheduler { let assetSpec: Asset; switch (task.type) { - case "import": case "upload": assetSpec = event.output?.[task.type]?.assetSpec; if (!assetSpec) { @@ -162,27 +161,6 @@ export class TaskScheduler { }); await this.triggerRecordingReadyWebhook(task); break; - case "transcode": - assetSpec = event.output?.transcode?.asset?.assetSpec; - if (!assetSpec) { - const error = "bad task output: missing assetSpec"; - console.error( - `task event process error: err=${error} taskId=${event.task.id}` - ); - await this.failTask(task, error, event.output); - return true; - } - await this.updateAsset(task.outputAssetId, { - size: assetSpec.size, - hash: assetSpec.hash, - videoSpec: assetSpec.videoSpec, - playbackRecordingId: assetSpec.playbackRecordingId, - status: { - phase: "ready", - updatedAt: Date.now(), - }, - }); - break; case "export": const inputAsset = await db.asset.get(task.inputAssetId); if (inputAsset.storage?.status?.tasks.pending === task.id) { diff --git a/packages/www/components/AssetDetails/AssetEventLogTab.tsx b/packages/www/components/AssetDetails/AssetEventLogTab.tsx index 5662482a5f..f648d57a51 100644 --- a/packages/www/components/AssetDetails/AssetEventLogTab.tsx +++ b/packages/www/components/AssetDetails/AssetEventLogTab.tsx @@ -30,12 +30,14 @@ const AssetEventLogTab = ({ asset }: { asset: Asset }) => { task.outputAssetId === asset.id || task.inputAssetId === asset.id ) ?.map((task) => ({ - type: task?.params?.import?.url - ? "url-import" - : task?.params?.import?.uploadedObjectKey - ? "file-import" - : task?.params?.import?.recordedSessionId - ? "recorded-session" + type: ["upload", "import"].includes(task?.type) + ? asset.source?.type == "url" + ? "url-import" + : asset.source?.type == "directUpload" + ? "file-import" + : asset.source?.type == "recording" + ? "recorded-session" + : "other" : task?.params?.export?.["ipfs"] ? "ipfs-upload" : "other",