-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[DSIP-107] Add separate workflow instance logs for UI viewing, similar to task logs. #18130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 6 commits
68a5e89
1efe619
1952489
5a4d175
f38aa56
94708ed
2ef11be
c2e475a
e71f415
5689ffe
8df0376
bf4e76e
c81b961
ca022f7
c6ff5c9
26d09c0
e7bcda8
4062178
65f9377
3911cab
0931712
d93f2ba
9f06e8b
1064e23
cbcffb9
0e06a2f
9914755
136128a
612977a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| ALTER TABLE `t_ds_workflow_instance` | ||
| ADD COLUMN `log_path` longtext NULL COMMENT 'workflow instance log path'; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| ALTER TABLE t_ds_workflow_instance ADD COLUMN IF NOT EXISTS "log_path" text DEFAULT NULL; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| import org.apache.dolphinscheduler.server.master.engine.task.execution.TaskExecutionBuilder; | ||
| import org.apache.dolphinscheduler.server.master.engine.task.execution.TaskInstanceFactories; | ||
| import org.apache.dolphinscheduler.server.master.runner.WorkflowExecuteContext.WorkflowExecuteContextBuilder; | ||
| import org.apache.dolphinscheduler.server.master.utils.WorkflowLogUtils; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.HashSet; | ||
|
|
@@ -95,6 +96,12 @@ protected void assembleWorkflowInstance( | |
| workflowInstance.setStateWithDesc(WorkflowExecutionStatus.RUNNING_EXECUTION, command.getCommandType().name()); | ||
| workflowInstance.setCommandType(command.getCommandType()); | ||
| workflowInstance.setHost(masterConfig.getMasterAddress()); | ||
| workflowInstance.setLogPath(WorkflowLogUtils.getWorkflowInstanceLogFullPath( | ||
| workflowInstance.getStartTime(), | ||
| workflowInstance.getWorkflowDefinitionCode(), | ||
| workflowInstance.getWorkflowDefinitionVersion(), | ||
| workflowInstance.getId())); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's best to inject the log path at runtime. You can write the code at
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a great idea! With your guidance, I found an even better way to implement it: we can uniformly set the logPath value in the abstract parent class AbstractCommandHandler.
|
||
| workflowInstanceDao.updateById(workflowInstance); | ||
|
|
||
| workflowExecuteContextBuilder.setWorkflowInstance(workflowInstance); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.dolphinscheduler.server.master.log; | ||
|
|
||
| import org.apache.dolphinscheduler.server.master.utils.WorkflowLogUtils; | ||
|
|
||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import org.slf4j.MDC; | ||
|
|
||
| import ch.qos.logback.classic.spi.ILoggingEvent; | ||
| import ch.qos.logback.core.sift.AbstractDiscriminator; | ||
|
|
||
| /** | ||
| * Workflow Log Discriminator | ||
| */ | ||
| @Slf4j | ||
| @Getter | ||
| @Setter | ||
| public class WorkflowLogDiscriminator extends AbstractDiscriminator<ILoggingEvent> { | ||
|
|
||
| private String key; | ||
Check noticeCode scanning / CodeQL Missing Override annotation Note
This method overrides
Discriminator.getKey Error loading related location Loading |
||
|
|
||
|
|
||
| private String logBase; | ||
|
|
||
| @Override | ||
| public String getDiscriminatingValue(ILoggingEvent event) { | ||
| String workflowInstanceLogPath = MDC.get(WorkflowLogUtils.WORKFLOW_INSTANCE_LOG_FULL_PATH_MDC_KEY); | ||
| if (workflowInstanceLogPath == null) { | ||
| log.error("The workflow instance log path is null, please check the logback configuration, log: {}", event); | ||
| } | ||
| return workflowInstanceLogPath; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,thanks