-
Notifications
You must be signed in to change notification settings - Fork 5k
[Fix-17820][Master] Fix task timeout alerts failed #17818
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
Changes from 1 commit
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -244,6 +244,13 @@ private void saveTaskTimeoutAlert(Alert alert, String content, int alertGroupId) | |||||||||
| public void sendTaskTimeoutAlert(WorkflowInstance workflowInstance, | ||||||||||
| TaskInstance taskInstance, | ||||||||||
| ProjectUser projectUser) { | ||||||||||
| assert projectUser != null; | ||||||||||
|
|
||||||||||
| // A null warningGroupId indicates that the user has explicitly configured a "no-alert" policy. | ||||||||||
| if (workflowInstance.getWarningGroupId() == null) { | ||||||||||
| return; | ||||||||||
| } | ||||||||||
|
||||||||||
| // A null warningGroupId indicates that the user has explicitly configured a "no-alert" policy. | |
| if (workflowInstance.getWarningGroupId() == null) { | |
| return; | |
| } |
Don't add this kind of code, we needn't check at here, the method name is not sendTaskTimeoutAlertIfNeeded
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.
Don't add this kind of code, we needn't check at here, the method name is not
sendTaskTimeoutAlertIfNeeded
If the user chooses not to send alerts, workflowInstance.getWarningGroupId() will be null, which will cause a NullPointerException.
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.
If the user chooses not to send alerts, can this method be called? We need to filter at the upper layer.
If the sendTaskTimeoutAlert method ultimately doesn't send an alert, that would be highly unusual.
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.
If the user chooses not to send alerts, can this method be called? We need to filter at the upper layer. If the
sendTaskTimeoutAlertmethod ultimately doesn't send an alert, that would be highly unusual.
OK,will handle in TaskTimeoutLifecycleEventHandler
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| import org.apache.dolphinscheduler.dao.entity.WorkflowAlertContent; | ||
| import org.apache.dolphinscheduler.dao.entity.WorkflowDefinitionLog; | ||
| import org.apache.dolphinscheduler.dao.entity.WorkflowInstance; | ||
| import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; | ||
| import org.apache.dolphinscheduler.dao.repository.ProjectDao; | ||
| import org.apache.dolphinscheduler.dao.repository.UserDao; | ||
| import org.apache.dolphinscheduler.dao.repository.WorkflowDefinitionLogDao; | ||
|
|
@@ -60,6 +61,9 @@ public class WorkflowAlertManager { | |
| @Autowired | ||
| private ProjectDao projectDao; | ||
|
|
||
| @Autowired | ||
| private ProjectMapper projectMapper; | ||
|
|
||
| /** | ||
| * convert command type to human-readable name | ||
| * | ||
|
|
@@ -260,8 +264,8 @@ public boolean isNeedToSendWarning(WorkflowInstance workflowInstance) { | |
| } | ||
|
|
||
| public void sendTaskTimeoutAlert(WorkflowInstance workflowInstance, | ||
| TaskInstance taskInstance, | ||
| ProjectUser projectUser) { | ||
| TaskInstance taskInstance) { | ||
| ProjectUser projectUser = projectMapper.queryProjectWithUserByWorkflowInstanceId(workflowInstance.getId()); | ||
|
||
| alertDao.sendTaskTimeoutAlert(workflowInstance, taskInstance, projectUser); | ||
| } | ||
| } | ||
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.
assertwill do nothing if the jvm doesn't enable it.And I don't think we need to check the project user here, since this shouldn't affect the alert, alert only need to take care about alert plugin, if the project user is null, it only affects the alert content.
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.
The DS project contains a large number of assert statements—I assumed they were recommended for use.
If we don't check in advance, a NullPointerException (NPE) will occur.
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.
Only a few historical codes contain assert statements.
The proper fix is to set the property to empty, rather than ignore the alert.