Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): disallow retrying gh-ost cut-over task (#2072)
Liu Ji32fec45af3cb
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vueindex d6173b8f9c..912045007e 100644--- a/frontend/src/components/Issue/IssueDetailLayout.vue+++ b/frontend/src/components/Issue/IssueDetailLayout.vue@@ -186,6 +186,8 @@ const {selectTask,taskStatusOfStage,isValidStage,+ allowApplyIssueStatusTransition,+ allowApplyTaskStatusTransition,} = useBaseIssueLogic({ issue, create });const issueLogic = ref<IssueLogic>();@@ -343,6 +345,8 @@ provideIssueLogic(selectTask,onStatusChanged,createIssue,+ allowApplyIssueStatusTransition,+ allowApplyTaskStatusTransition,},true// This is the root logic, could be overwritten by other (standard, gh-ost, tenant...) logic providers.diff --git a/frontend/src/components/Issue/logic/GhostModeProvider.ts b/frontend/src/components/Issue/logic/GhostModeProvider.tsindex 9ccd81a7bc..c7c54002c3 100644--- a/frontend/src/components/Issue/logic/GhostModeProvider.ts+++ b/frontend/src/components/Issue/logic/GhostModeProvider.ts@@ -7,6 +7,7 @@ import {Task,TaskCreate,TaskDatabaseSchemaUpdateGhostSyncPayload,+ TaskStatus,UpdateSchemaGhostContext,} from "@/types";import { useDatabaseStore } from "@/store";@@ -14,7 +15,13 @@ import { useDatabaseStore } from "@/store";export default defineComponent({name: "GhostModeProvider",setup() {- const { create, issue, selectedTask, createIssue } = useIssueLogic();+ const {+ create,+ issue,+ selectedTask,+ createIssue,+ allowApplyTaskStatusTransition: baseAllowApplyTaskStatusTransition,+ } = useIssueLogic();const databaseStore = useDatabaseStore();// In gh-ost mode, each stage can own its SQL statement@@ -59,10 +66,27 @@ export default defineComponent({createIssue(issueCreate);};+ const allowApplyTaskStatusTransition = (+ task: Task,+ to: TaskStatus+ ): boolean => {+ if (+ task.type === "bb.task.database.schema.update.ghost.cutover" &&+ task.status === "FAILED"+ ) {+ if (to === "PENDING" || to === "RUNNING") {+ // RETRYing gh-ost cut-over task is not allowed (yet).+ return false;+ }+ }+ return baseAllowApplyTaskStatusTransition(task, to);+ };+const logic = {...useCommonLogic(),selectedStatement,doCreate,+ allowApplyTaskStatusTransition,};provideIssueLogic(logic);return logic;diff --git a/frontend/src/components/Issue/logic/IssueLogic.ts b/frontend/src/components/Issue/logic/IssueLogic.tsindex e9151d3a79..97ed60c1d5 100644--- a/frontend/src/components/Issue/logic/IssueLogic.ts+++ b/frontend/src/components/Issue/logic/IssueLogic.ts@@ -4,6 +4,7 @@ import {Issue,IssueCreate,IssuePatch,+ IssueStatus,Pipeline,Project,Stage,@@ -68,6 +69,10 @@ type IssueLogic = {taskSlug?: string | undefined) => void;selectTask: (task: Task) => void;++ // status transition+ allowApplyIssueStatusTransition(issue: Issue, to: IssueStatus): boolean;+ allowApplyTaskStatusTransition(task: Task, to: TaskStatus): boolean;};export default IssueLogic;diff --git a/frontend/src/components/Issue/logic/base.ts b/frontend/src/components/Issue/logic/base.tsindex 2ad10ee3f7..664f3f6a94 100644--- a/frontend/src/components/Issue/logic/base.ts+++ b/frontend/src/components/Issue/logic/base.ts@@ -202,6 +202,16 @@ export const useBaseIssueLogic = (params: {return true;};+ const allowApplyIssueStatusTransition = () => {+ // no extra logic by default+ return true;+ };++ const allowApplyTaskStatusTransition = () => {+ // no extra logic by default+ return true;+ };+return {project,isTenantMode,@@ -215,5 +225,7 @@ export const useBaseIssueLogic = (params: {selectTask,taskStatusOfStage,isValidStage,+ allowApplyIssueStatusTransition,+ allowApplyTaskStatusTransition,};};diff --git a/frontend/src/components/Issue/logic/transition.ts b/frontend/src/components/Issue/logic/transition.tsindex 1d653ae8cb..438fac656f 100644--- a/frontend/src/components/Issue/logic/transition.ts+++ b/frontend/src/components/Issue/logic/transition.ts@@ -21,7 +21,12 @@ import {import { useIssueLogic } from ".";export const useIssueTransitionLogic = (issue: Ref<Issue>) => {- const { create, activeTaskOfPipeline } = useIssueLogic();+ const {+ create,+ activeTaskOfPipeline,+ allowApplyIssueStatusTransition,+ allowApplyTaskStatusTransition,+ } = useIssueLogic();const currentUser = useCurrentUser();const getApplicableIssueStatusTransitionList = (@@ -57,7 +62,11 @@ export const useIssueTransitionLogic = (issue: Ref<Issue>) => {}return list- .filter((item) => {+ .map(+ (type: IssueStatusTransitionType) =>+ ISSUE_STATUS_TRANSITION_LIST.get(type)!+ )+ .filter((transition) => {const pipeline = issueEntity.pipeline;// Disallow any issue status transition if the active task is in RUNNING state.if (currentTask.status == "RUNNING") {@@ -67,7 +76,7 @@ export const useIssueTransitionLogic = (issue: Ref<Issue>) => {const taskList = allTaskList(pipeline);// Don't display the Resolve action if the last task is NOT in DONE status.if (- item == "RESOLVE" &&+ transition.type == "RESOLVE" &&taskList.length > 0 &&(currentTask.id != taskList[taskList.length - 1].id ||currentTask.status != "DONE")@@ -75,12 +84,8 @@ export const useIssueTransitionLogic = (issue: Ref<Issue>) => {return false;}- return true;+ return allowApplyIssueStatusTransition(issue, transition.to);})- .map(- (type: IssueStatusTransitionType) =>- ISSUE_STATUS_TRANSITION_LIST.get(type)!- ).reverse();};@@ -96,18 +101,20 @@ export const useIssueTransitionLogic = (issue: Ref<Issue>) => {case "CANCELED":return [];case "OPEN": {- let list: TaskStatusTransition[] = [];-// Allow assignee, or assignee is the system bot and current user is DBA or ownerif (currentUser.value.id === issue.assignee?.id ||(issue.assignee?.id == SYSTEM_BOT_ID &&isDBAOrOwner(currentUser.value.role))) {- list = applicableStageTransition(issue.pipeline);+ const currentTask = activeTaskOfPipeline(issue.pipeline);+ return applicableStageTransition(issue.pipeline).filter(+ (transition) =>+ allowApplyTaskStatusTransition(currentTask, transition.to)+ );}- return list;+ return [];}}console.assert(false, "Should never reach this line");@@ -127,18 +134,19 @@ export const useIssueTransitionLogic = (issue: Ref<Issue>) => {case "CANCELED":return [];case "OPEN": {- let list: TaskStatusTransition[] = [];-// Allow assignee, or assignee is the system bot and current user is DBA or ownerif (currentUser.value.id === issue.assignee?.id ||(issue.assignee?.id == SYSTEM_BOT_ID &&isDBAOrOwner(currentUser.value.role))) {- list = applicableTaskTransition(issue.pipeline);+ const currentTask = activeTaskOfPipeline(issue.pipeline);+ return applicableTaskTransition(issue.pipeline).filter((transition) =>+ allowApplyTaskStatusTransition(currentTask, transition.to)+ );}- return list;+ return [];}}console.assert(false, "Should never reach this line");