apache / dolphinscheduler

Apache DolphinScheduler is the modern data orchestration platform. Agile to create high performance workflow with low-code

Home Page:https://dolphinscheduler.apache.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature][Dynamic] Dynamic-created Subtasks Fail to Run Using Tenant Code Specified at Task Start

stoplyy opened this issue · comments

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Description

I've encountered an issue with Dynamic tasks in DolphinScheduler where the tenantCode specified at the start of the task is not being passed to the subtasks. This results in the tenantCode being null when constructing the command for the day's task.

Upon reviewing the source code, I found that the createCommand method in DynamicCommandUtils does not transfer the ProcessInstance's tenantCode to the command object. This omission seems to be the cause of the issue described above.

Use case

  1. Create a sub-workflow that includes a shell script task to output the current running role:
current_user=$(whoami)
echo "whoami: $current_user"
  1. Create a parent workflow that includes a Dynamic task pointing to the sub-workflow, and associate it with a script task to output the parent task's role:
current_user=$(whoami)
echo "parent task whoami: $current_user"
  1. Run the parent workflow and set the tenant (tenantCode) to root.
  2. Observe the log outputs.

Expected Behavior:

The log output of the sub-workflow task instances should show the role as root.

Actual Behavior:

The log output of the sub-workflow task instances shows the role as default, indicating that it was not passed from the parent task.
image
image

Possible Solution:

It may be necessary to modify the createCommand method in DynamicCommandUtils to include the ProcessInstance's tenantCode when constructing the command object.

I believe this adjustment will ensure that the tenantCode is correctly passed to all subtasks, maintaining consistency and the appropriate execution context.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Similarly, the listParameters type parameters in Dynamic nodes do not accept parameters with the same name passed at the start of the task. Theoretically, it's not always possible to know how many sub-nodes need to be split when creating the task. It might be necessary to pass this information during task execution.

This is more like a bug, are you interested in fixing it?