Repository navigation
[Improvement-18806][API] Remove cross-project workflow modifications - #18807
ruanwenjun wants to merge 6 commits into
Conversation
1123bd5 to
b1c378b
Compare
SbloodyS
left a comment
There was a problem hiding this comment.
Validate the current DAG before replacing its relations
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:1686
Version switching validates the selected historical DAG but skips the persisted current relations. A workflow moved from project A to B and back through the legacy API can have a valid project-A snapshot and still retain current relations stamped with project B. Restoring the project-A snapshot deletes only project-A rows. Queries by workflow code then return the leftover project-B rows alongside the restored relations.
Validate the persisted current relations before replacing the DAG, including during definition edits and instance saves with syncDefine=true. Add a regression with a valid target snapshot and a current relation stamped with another project, and verify that the operation rejects it before any write.
Preserve workflow versions required for instance updates
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java:423dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:1796
Instance updates now require the recorded workflow definition version to exist, including with syncDefine=false. The version-delete endpoint still allows deleting a non-current version referenced by a finished instance. After that deletion, a direct API client submitting a complete, valid same-project DAG receives WORKFLOW_DEFINITION_NOT_EXIST before the payload is read. Previously, the update could save the submitted DAG as a new version.
Preserve the recorded version while an editable instance references it, and document the behavior for instances whose recorded versions were already deleted. Add a regression that attempts to delete a non-current version referenced by a finished instance and verifies that the instance remains editable.
|
@SbloodyS Thanks for the review. Both points are addressed in 28f22b1.
For recorded versions deleted before upgrading, instance editing still returns Validation: all nine new regression cases pass. Full API |
SbloodyS
left a comment
There was a problem hiding this comment.
Reject workflow version restores that reference missing task versions
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowDefinitionServiceImpl.java:1697
The restore preflight checks ownership only for task versions returned by the database. The task-version delete API allows deleting a non-current task version that an older workflow DAG still references. When restoring a two-task DAG with one of those versions missing, switchWorkflowTaskRelationVersion writes both relations and reports success if the other task switches successfully. The Master then fails to build the graph because an edge references a missing task.
Before writing, compare the distinct (taskCode, version) pairs referenced by the selected DAG with the task logs returned by the query. Report any missing pair and reject the restore. Add a regression with one available and one deleted task version, and verify that the current workflow version, DAG relations, and schedule remain unchanged.
|
@SbloodyS Addressed this review comment in 10971c1. The restore preflight now compares the distinct Added regressions for a two-task DAG with either the predecessor or successor task version missing. They verify that the current definition version and relations remain unchanged and that version switching, relation writes, scheduler updates, and lineage updates are not invoked. The successful-restore test also covers repeated references and task logs returned in a different order. Validation: |
Restore tasks that exist only in version history
Saving an instance with Restore each current task row from its validated version log, inserting the row when needed, and roll back the workflow restore if any task cannot be restored. Add a regression that saves an instance with one existing task and one new task using |
|
@SbloodyS Addressed this comment in 4af5d6b.
Workflow restoration now requires every task restore to succeed. A missing task version or a zero-row insert/update returns failure, causing the API to throw and roll back its transaction instead of committing a partially restored DAG. Added an H2-backed regression that saves a finished instance with one existing task and one new task using Validation: API |
…ferenced versions
4af5d6b to
fb92ef5
Compare
Was this PR generated or assisted by AI?
YES. Implementation, regression tests, and the description were assisted by OpenAI Codex.
Purpose of the pull request
Fixes #18806.
Remove the legacy workflow
batch-moveAPI, which has no frontend caller, and keep existing workflow/task project ownership unchanged through definition edits, instance updates, and version switching. Reject inconsistent persisted or historical ownership before saving instead of moving records between projects implicitly.Brief change log
TaskProjectValidatorandWorkflowRelationValidator, each implementingIValidatorwith a nestedContext. Relation validation reuses task validation; simple project comparisons remain in the service entry points.(taskCode, version)pairs referenced by the selected DAG with the returned task logs. Reject any missing pair withTASK_DEFINE_NOT_EXIST, including the missing task codes and versions, before any writes.syncDefine=true. Reject foreign-project relation rows before replacing the DAG.WORKFLOW_DEFINITION_VERSION_IS_USEDerror.Related: #18718 contains project-authorization work; this PR isolates the move removal and ownership rules. #18798 / #18799 continue to cover DEPENDENT self-reference remapping during ordinary copying.
Verify this pull request
syncDefine=false, restores the saved version, and verifies both tasks through the task detail HTTP endpoint using MockMvc.verifyand packaging passed with Java 8 and an isolated Maven local repository: 821 tests, 10 skipped, zero failures/errors. This includes 63 tests inWorkflowDefinitionServiceTest, 32 inWorkflowInstanceServiceTest, and three database-backed cases inWorkflowVersionRestoreTest.verifypassed: 38 tests, zero failures/errors, using UTC as required by the existing business-parameter timestamp test../mvnw -o spotless:check -B) andgit diff --checkpassed, including the root Markdown formatter and all Maven modules.Commands (offline, after preparing dependencies and installing the updated service module in the isolated Maven local repository):
The Docker-based
dolphinscheduler-api-testsuite, E2E tests, the full frontend build, and deployed-environment validation were not run. CI results are tracked separately by the PR checks.Pull Request Notice
This removes a public API, rejects updates of inconsistent historical ownership, and prevents deleting workflow versions referenced by existing instances. Editing instances whose recorded versions were already deleted remains rejected, including with
syncDefine=false. Compatibility notes are included in the English and Chinese upgrade guides; no automatic migration is performed.Pull Request Notice