-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #713 from desci-labs/publish-task-q
Improve Publish tracking/recovery
- Loading branch information
Showing
24 changed files
with
1,301 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
desci-server/prisma/migrations/20241205220126_add_publish_status/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- CreateTable | ||
CREATE TABLE "PublishStatus" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"nodeUuid" TEXT NOT NULL, | ||
"version" INTEGER NOT NULL, | ||
"versionId" INTEGER, | ||
"commitId" TEXT, | ||
"ceramicComit" BOOLEAN, | ||
"assignDpid" BOOLEAN, | ||
"createPdr" BOOLEAN, | ||
"fireDeferredEmails" BOOLEAN, | ||
"fireNotifications" BOOLEAN, | ||
"updateAttestations" BOOLEAN, | ||
"transformDraftComments" BOOLEAN, | ||
"triggerDoiMint" BOOLEAN, | ||
|
||
CONSTRAINT "PublishStatus_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "PublishStatus_nodeUuid_key" ON "PublishStatus"("nodeUuid"); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "PublishStatus_nodeUuid_idx" ON "PublishStatus"("nodeUuid"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "PublishStatus_nodeUuid_version_key" ON "PublishStatus"("nodeUuid", "version"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "PublishStatus" ADD CONSTRAINT "PublishStatus_versionId_fkey" FOREIGN KEY ("versionId") REFERENCES "NodeVersion"("id") ON DELETE SET NULL ON UPDATE CASCADE; | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "PublishStatus" ADD CONSTRAINT "PublishStatus_nodeUuid_fkey" FOREIGN KEY ("nodeUuid") REFERENCES "Node"("uuid") ON DELETE RESTRICT ON UPDATE CASCADE; |
2 changes: 2 additions & 0 deletions
2
...erver/prisma/migrations/20241206120942_fix_publish_status_unique_constraint/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- DropIndex | ||
DROP INDEX "PublishStatus_nodeUuid_key"; |
2 changes: 2 additions & 0 deletions
2
...server/prisma/migrations/20241210102946_add_handle_node_version_entry_check/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "PublishStatus" ADD COLUMN "handleNodeVersionEntry" BOOLEAN; |
13 changes: 13 additions & 0 deletions
13
...-server/prisma/migrations/20241211184344_add_unique_constraint_on_commit_id/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
Warnings: | ||
- You are about to drop the column `ceramicComit` on the `PublishStatus` table. All the data in the column will be lost. | ||
- A unique constraint covering the columns `[commitId]` on the table `PublishStatus` will be added. If there are existing duplicate values, this will fail. | ||
*/ | ||
-- AlterTable | ||
ALTER TABLE "PublishStatus" DROP COLUMN "ceramicComit", | ||
ADD COLUMN "ceramicCommit" BOOLEAN; | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "PublishStatus_commitId_key" ON "PublishStatus"("commitId"); |
2 changes: 2 additions & 0 deletions
2
...rver/prisma/migrations/20241211203631_add_manifest_cid_publish_status_table/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- AlterTable | ||
ALTER TABLE "PublishStatus" ADD COLUMN "manifestCid" TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
desci-server/src/controllers/admin/publish/resumePublish.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { User } from '@prisma/client'; | ||
import { Request, Response } from 'express'; | ||
import { z } from 'zod'; | ||
|
||
import { logger as parentLogger } from '../../../logger.js'; | ||
import { publishSequencer } from '../../../services/PublishServices.js'; | ||
|
||
const ResumePublishSchema = z | ||
.object({ | ||
publishStatusId: z.number().optional(), | ||
commitId: z.string().optional(), | ||
nodeUuid: z.string().optional(), | ||
version: z.number().optional(), | ||
}) | ||
.refine((data) => !!(data.publishStatusId || data.commitId || (data.nodeUuid && data.version)), { | ||
message: 'Must provide either publishStatusId, commitId, or both nodeUuid and version', | ||
}); | ||
|
||
export interface AuthenticatedRequest extends Request { | ||
user: User; | ||
} | ||
|
||
export interface ErrorResponse { | ||
allStepsSucceeded: false; | ||
error: string; | ||
details?: z.ZodIssue[] | string; | ||
} | ||
|
||
export const resumePublish = async ( | ||
req: AuthenticatedRequest & { body: z.infer<typeof ResumePublishSchema> }, | ||
res: Response<{ allStepsSucceeded: boolean } | ErrorResponse>, | ||
) => { | ||
const logger = parentLogger.child({ | ||
module: 'Admin:Publish::resumePublish', | ||
userId: req.user?.id, | ||
body: req.body, | ||
}); | ||
try { | ||
const args = ResumePublishSchema.parse(req.body); | ||
logger.debug({ args }, 'Resuming publish'); | ||
const success = await publishSequencer(args); | ||
|
||
return res.status(success ? 200 : 500).json({ allStepsSucceeded: success }); | ||
} catch (error) { | ||
if (error instanceof z.ZodError) { | ||
return res.status(400).json({ | ||
allStepsSucceeded: false, | ||
error: 'Invalid request parameters', | ||
details: error.errors, | ||
}); | ||
} | ||
|
||
logger.error({ error }, 'Error resuming publish'); | ||
return res.status(500).json({ | ||
allStepsSucceeded: false, | ||
error: error instanceof Error ? error.message : String(error), | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.