Skip to content

Commit 967557c

Browse files
authored
Merge efe3336 into b3b8c07
2 parents b3b8c07 + efe3336 commit 967557c

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/OSUtils.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ public static boolean existTenantCodeInLinux(String tenantCode) {
183183
*
184184
* @param userName user name
185185
*/
186-
public static void createUserIfAbsent(String userName) {
186+
public static synchronized void createUserIfAbsent(String userName) {
187187
// if not exists this user, then create
188188
if (!getUserList().contains(userName)) {
189-
boolean isSuccess = createUser(userName);
190-
log.info("create user {} {}", userName, isSuccess ? "success" : "fail");
189+
createUser(userName);
191190
}
192191
}
193192

@@ -197,13 +196,12 @@ public static void createUserIfAbsent(String userName) {
197196
* @param userName user name
198197
* @return true if creation was successful, otherwise false
199198
*/
200-
public static boolean createUser(String userName) {
199+
public static void createUser(String userName) {
201200
try {
202201
String userGroup = getGroup();
203202
if (StringUtils.isEmpty(userGroup)) {
204-
String errorLog = String.format("%s group does not exist for this operating system.", userGroup);
205-
log.error(errorLog);
206-
return false;
203+
throw new UnsupportedOperationException(
204+
"There is no userGroup exist cannot create tenant, please create userGroupFirst");
207205
}
208206
if (SystemUtils.IS_OS_MAC) {
209207
createMacUser(userName, userGroup);
@@ -212,18 +210,17 @@ public static boolean createUser(String userName) {
212210
} else {
213211
createLinuxUser(userName, userGroup);
214212
}
215-
return true;
213+
log.info("Create tenant {} under userGroup: {} success", userName, userGroup);
216214
} catch (Exception e) {
217-
log.error(e.getMessage(), e);
215+
throw new RuntimeException("Create tenant: {} failed", e);
218216
}
219217

220-
return false;
221218
}
222219

223220
/**
224221
* create linux user
225222
*
226-
* @param userName user name
223+
* @param userName user name
227224
* @param userGroup user group
228225
* @throws IOException in case of an I/O error
229226
*/
@@ -237,7 +234,7 @@ private static void createLinuxUser(String userName, String userGroup) throws IO
237234
/**
238235
* create mac user (Supports Mac OSX 10.10+)
239236
*
240-
* @param userName user name
237+
* @param userName user name
241238
* @param userGroup user group
242239
* @throws IOException in case of an I/O error
243240
*/
@@ -256,7 +253,7 @@ private static void createMacUser(String userName, String userGroup) throws IOEx
256253
/**
257254
* create windows user
258255
*
259-
* @param userName user name
256+
* @param userName user name
260257
* @param userGroup user group
261258
* @throws IOException in case of an I/O error
262259
*/
@@ -304,7 +301,7 @@ public static String getGroup() throws IOException {
304301
* get sudo command
305302
*
306303
* @param tenantCode tenantCode
307-
* @param command command
304+
* @param command command
308305
* @return result of sudo execute command
309306
*/
310307
public static String getSudoCmd(String tenantCode, String command) {

dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/utils/TaskExecutionContextUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static String getOrCreateTenant(WorkerConfig workerConfig, TaskExecutionC
7878
throw ex;
7979
} catch (Exception ex) {
8080
throw new TaskException(
81-
String.format("TenantCode: %s doesn't exist", taskExecutionContext.getTenantCode()));
81+
String.format("TenantCode: %s doesn't exist", taskExecutionContext.getTenantCode()), ex);
8282
}
8383
}
8484

0 commit comments

Comments
 (0)