Copilot commented on code in PR #18063:
URL:
https://github.com/apache/dolphinscheduler/pull/18063#discussion_r2985363612
##########
dolphinscheduler-master/src/test/java/org/apache/dolphinscheduler/server/master/integration/WorkflowOperator.java:
##########
@@ -67,6 +68,7 @@ public Integer manualTriggerWorkflow(final WorkflowTriggerDTO
workflowTriggerDTO
.dryRun(workflowTriggerDTO.getDryRun())
.taskDependType(workflowTriggerDTO.getTaskDependType())
.failureStrategy(workflowTriggerDTO.getFailureStrategy())
+ .warningGroupId(workflowTriggerDTO.getWarningGroupId())
Review Comment:
`WorkflowTriggerDTO` now contains `warningType`, but `manualTriggerWorkflow`
doesn't propagate it into `WorkflowManualTriggerRequest` (only `warningGroupId`
is set). This makes the DTO field ineffective and can lead to confusion when
writing tests that intend to control `warningType`. Either remove `warningType`
from the DTO or pass it through to the request builder.
```suggestion
.warningGroupId(workflowTriggerDTO.getWarningGroupId())
.warningType(workflowTriggerDTO.getWarningType())
```
##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/engine/workflow/lifecycle/event/WorkflowTimeoutLifecycleEvent.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * 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.engine.workflow.lifecycle.event;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import org.apache.dolphinscheduler.dao.entity.WorkflowInstance;
+import org.apache.dolphinscheduler.server.master.engine.ILifecycleEventType;
+import
org.apache.dolphinscheduler.server.master.engine.workflow.lifecycle.AbstractWorkflowLifecycleLifecycleEvent;
+import
org.apache.dolphinscheduler.server.master.engine.workflow.lifecycle.WorkflowLifecycleEventType;
+import
org.apache.dolphinscheduler.server.master.engine.workflow.runnable.IWorkflowExecutionRunnable;
+
+import java.util.concurrent.TimeUnit;
+
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public class WorkflowTimeoutLifecycleEvent extends
AbstractWorkflowLifecycleLifecycleEvent {
+
+ private IWorkflowExecutionRunnable workflowExecutionRunnable;
+
+ protected WorkflowTimeoutLifecycleEvent(final IWorkflowExecutionRunnable
workflowExecutionRunnable,
+ final long timeout) {
+ super(timeout);
+ this.workflowExecutionRunnable = workflowExecutionRunnable;
+ }
+
+ public static WorkflowTimeoutLifecycleEvent of(IWorkflowExecutionRunnable
workflowExecutionRunnable) {
+ final WorkflowInstance workflowInstance =
workflowExecutionRunnable.getWorkflowInstance();
+ checkState(workflowInstance != null,
+ "The workflow instance must be initialized before creating
workflow timeout event.");
+
+ final int timeout = workflowInstance.getTimeout();
+ checkState(timeout > 0, "The workflow timeout: %s must > 0 minutes",
timeout);
+
+ long delayTime = System.currentTimeMillis() -
workflowInstance.getRestartTime().getTime()
+ + TimeUnit.MINUTES.toMillis(timeout);
Review Comment:
`WorkflowTimeoutLifecycleEvent.of` assumes
`workflowInstance.getRestartTime()` is non-null and uses it to compute
`delayTime`. In practice `restartTime` can be null (there are call sites that
explicitly fall back to `startTime` when it's missing), which would cause an
NPE and prevent timeout handling. Additionally, the current delay calculation
adds the elapsed time since `restartTime` to the configured timeout, which
schedules the event later than the configured timeout if there is any delay
between setting `restartTime` and publishing the event. Consider falling back
to `startTime` when `restartTime` is null and computing the remaining delay
until `(restart/start time + timeout)` (clamping to 0 if already exceeded).
```suggestion
final long baseTimeMillis =
workflowInstance.getRestartTime() != null
? workflowInstance.getRestartTime().getTime()
: (workflowInstance.getStartTime() != null
? workflowInstance.getStartTime().getTime()
: 0L);
checkState(baseTimeMillis > 0,
"The workflow instance startTime and restartTime must not
both be null when creating workflow timeout event.");
final long timeoutMillis = TimeUnit.MINUTES.toMillis(timeout);
final long deadlineMillis = baseTimeMillis + timeoutMillis;
final long delayTime = Math.max(0L, deadlineMillis -
System.currentTimeMillis());
```
--
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]