stoplyy opened a new issue, #15937:
URL: https://github.com/apache/dolphinscheduler/issues/15937

   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) 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:  
   ```shell
   current_user=$(whoami)
   echo "whoami: $current_user"
   ```
   2. 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:
   ```shell
   current_user=$(whoami)
   echo "parent task whoami: $current_user"
   ```
   3. Run the parent workflow and set the tenant (tenantCode) to root.
   4. 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](https://github.com/apache/dolphinscheduler/assets/19727083/d93f481d-4c2f-41fe-b133-2f0f131213b8)
   
![image](https://github.com/apache/dolphinscheduler/assets/19727083/3e4bbdb9-0080-45b7-ad4d-5a9d6af2d302)
   
   
   
   ### 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?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: 
[email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to