SbloodyS commented on code in PR #10185:
URL: https://github.com/apache/dolphinscheduler/pull/10185#discussion_r882285859
##########
docs/docs/zh/architecture/configuration.md:
##########
@@ -235,6 +235,8 @@ worker.heartbeat.interval|10|worker心跳间隔,单位为秒
worker.max.cpuload.avg|-1|worker最大cpuload均值,只有高于系统cpuload均值时,worker服务才能被派发任务.
默认值为-1: cpu cores * 2
worker.reserved.memory|0.3|worker预留内存,只有低于系统可用内存时,worker服务才能被派发任务,单位为G
worker.groups|default|worker分组配置,逗号分隔,例如'worker.groups=default,test' <br>
worker启动时会根据该配置自动加入对应的分组
+worker.tenant.auto.create|true|租户对应的是worker系统的用户,用于worker提交作业所使用的用户.如果系统中没有这个用户,开启后将会自动创建
Review Comment:
Same as english's doc.
##########
docs/docs/en/architecture/configuration.md:
##########
@@ -246,7 +246,8 @@ worker.heartbeat.interval|10|worker-service heartbeat
interval, the unit is seco
worker.max.cpuload.avg|-1|worker max CPU load avg, only higher than the system
CPU load average, worker server can be dispatched tasks. default value -1: the
number of CPU cores * 2
worker.reserved.memory|0.3|worker reserved memory, only lower than system
available memory, worker server can be dispatched tasks. default value 0.3, the
unit is G
worker.groups|default|worker groups separated by comma, e.g.,
'worker.groups=default,test' <br> worker will join corresponding group
according to this config when startup
-
+worker.tenant.auto.create|true|The tenant is worker's user, which is used by
the worker to submit the job. If system does not have this user, it will be
automatically created after the parameter is true.
Review Comment:
Is it better to use ```it will be automatically created after the parameter
worker.tenant.distributed.user is true.``` instead of ```it will be
automatically created after the parameter is true```?
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java:
##########
@@ -249,6 +249,36 @@ private static List<String> getUserListFromWindows()
throws IOException {
return users;
}
+
+
+ /**
+ * whether the user exists in linux
+ *
+ * @return boolean
+ */
+ public static boolean existTenantCodeInLinux(String tenantCode) {
+ try{
+ String result = exeCmd("id "+ tenantCode);
+ if (!StringUtils.isEmpty(result)){
+ return result.contains("uid=");
+ }
+ }catch (Exception e){
+ String message = e.getMessage();
+ //Because ShellExecutor method throws exception to the linux
return status is not 0
+ //not exist user return status is 1
+ if (message.contains("no such user")){
+ logger.warn(message);
Review Comment:
Is it better to use error instead of warn? Becasue the worker would not
execute any task without user.
##########
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/processor/TaskExecuteProcessor.java:
##########
@@ -116,12 +117,21 @@ public void process(Channel channel, Command command) {
taskExecutionContext.setLogPath(LogUtils.getTaskLogPath(taskExecutionContext));
if (Constants.DRY_RUN_FLAG_NO == taskExecutionContext.getDryRun()) {
- if (CommonUtils.isSudoEnable() &&
workerConfig.isTenantAutoCreate()) {
-
OSUtils.createUserIfAbsent(taskExecutionContext.getTenantCode());
- }
+ boolean osUserExistFlag ;
+ //if Using distributed is true and Currently supported systems are
linux,Should not let it automatically
+ //create tenants,so TenantAutoCreate has no effect
+ if (workerConfig.isTenantDistributedUser() &&
SystemUtils.IS_OS_LINUX){
+ osUserExistFlag =
OSUtils.existTenantCodeInLinux(taskExecutionContext.getTenantCode());
+ }else {
Review Comment:
It's recommand to use ```else if``` instead of ```else{} if() {}````
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java:
##########
@@ -249,6 +249,36 @@ private static List<String> getUserListFromWindows()
throws IOException {
return users;
}
+
+
+ /**
+ * whether the user exists in linux
+ *
+ * @return boolean
+ */
+ public static boolean existTenantCodeInLinux(String tenantCode) {
+ try{
+ String result = exeCmd("id "+ tenantCode);
+ if (!StringUtils.isEmpty(result)){
+ return result.contains("uid=");
+ }
+ }catch (Exception e){
+ String message = e.getMessage();
+ //Because ShellExecutor method throws exception to the linux
return status is not 0
Review Comment:
Please remove duplicated space in ```throws exception```
##########
dolphinscheduler-standalone-server/src/main/resources/application.yaml:
##########
@@ -125,6 +125,9 @@ worker:
host-weight: 100
# worker tenant auto create
tenant-auto-create: true
+ # worker tenant is distributed user. If this is true, tenant-auto-create has
no effect. Will automatically create users without creating user.
Review Comment:
Same as docs.
##########
dolphinscheduler-worker/src/main/resources/application.yaml:
##########
@@ -64,6 +64,9 @@ worker:
host-weight: 100
# worker tenant auto create
tenant-auto-create: true
+ # worker tenant is distributed user. If this is true, tenant-auto-create has
no effect. Will automatically create users without creating user.
Review Comment:
Same as docs.
--
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]