Skip to content

Commit 9b17298

Browse files
committed
feat: 支持npu自动扩缩容
1 parent 5c2f3d9 commit 9b17298

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

backend/services/data-cleaning-service/src/main/java/com/datamate/cleaning/application/CleaningTaskService.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import lombok.RequiredArgsConstructor;
3232
import lombok.extern.slf4j.Slf4j;
3333
import org.apache.commons.collections4.CollectionUtils;
34+
import org.apache.commons.io.FileUtils;
3435
import org.apache.commons.lang3.StringUtils;
3536
import org.springframework.stereotype.Service;
3637
import org.springframework.transaction.annotation.Transactional;
@@ -76,9 +77,12 @@ public class CleaningTaskService {
7677

7778
private final String FLOW_PATH = "/flow";
7879

79-
private final Pattern LEVEL_PATTERN = Pattern.compile(
80-
"\\b(TRACE|DEBUG|INFO|WARN|WARNING|ERROR|FATAL)\\b",
81-
Pattern.CASE_INSENSITIVE
80+
private static final Pattern STANDARD_LEVEL_PATTERN = Pattern.compile(
81+
"\\b(DEBUG|Debug|INFO|Info|WARN|Warn|WARNING|Warning|ERROR|Error|FATAL|Fatal)\\b"
82+
);
83+
84+
private static final Pattern EXCEPTION_SUFFIX_PATTERN = Pattern.compile(
85+
"\\b\\w+(Warning|Error|Exception)\\b"
8286
);
8387

8488
private final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
@@ -168,9 +172,16 @@ private String getLogLevel(String logLine, String defaultLevel) {
168172
return defaultLevel;
169173
}
170174

171-
Matcher matcher = LEVEL_PATTERN.matcher(logLine);
172-
if (matcher.find()) {
173-
return matcher.group(1).toUpperCase();
175+
Matcher stdMatcher = STANDARD_LEVEL_PATTERN.matcher(logLine);
176+
if (stdMatcher.find()) {
177+
return stdMatcher.group(1).toUpperCase();
178+
}
179+
180+
Matcher exMatcher = EXCEPTION_SUFFIX_PATTERN.matcher(logLine);
181+
if (exMatcher.find()) {
182+
String match = exMatcher.group(1).toUpperCase();
183+
if ("WARNING".equals(match)) return "WARN";
184+
if ("ERROR".equals(match) || "EXCEPTION".equals(match)) return "ERROR";
174185
}
175186
return defaultLevel;
176187
}
@@ -180,6 +191,11 @@ public void deleteTask(String taskId) {
180191
cleaningTaskRepo.deleteTaskById(taskId);
181192
operatorInstanceRepo.deleteByInstanceId(taskId);
182193
cleaningResultRepo.deleteByInstanceId(taskId);
194+
try {
195+
FileUtils.deleteDirectory(new File(FLOW_PATH + "/" + taskId));
196+
} catch (IOException e) {
197+
log.warn("Can't delete flow path with task id: {}.", taskId, e);
198+
}
183199
}
184200

185201
public void executeTask(String taskId) {

deployment/helm/datamate/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,19 @@ ray-cluster:
320320
value: *dbPass
321321
- name: MYSQL_DATABASE
322322
value: "datamate"
323+
- name: POD_NAME
324+
valueFrom:
325+
fieldRef:
326+
fieldPath: metadata.name
323327
resources:
324328
limits:
325329
cpu: "8"
326330
memory: "64G"
331+
huawei.com/Ascend910: 1
327332
requests:
328333
cpu: "1"
329334
memory: "2G"
335+
huawei.com/Ascend910: 1
330336
volumes:
331337
- *datasetVolume
332338
- *flowVolume
@@ -335,7 +341,7 @@ ray-cluster:
335341
volumeMounts:
336342
- mountPath: /tmp/ray
337343
name: log-volume
338-
subPath: ray/worker
344+
subPathExpr: ray/$(POD_NAME)
339345
- mountPath: /dataset
340346
name: dataset-volume
341347
- mountPath: /flow

0 commit comments

Comments
 (0)