Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.

Commit 615eb8f

Browse files
committed
Merge branch 'dev'
2 parents 95b8a1b + 514c0f9 commit 615eb8f

15 files changed

Lines changed: 198 additions & 20 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ ui/.settings
1414
.settings
1515
dump.rdb
1616
.idea
17-
out/
17+
*.iml
18+
out/

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
}
1111
}
1212
plugins {
13-
id 'nebula.netflixoss' version '3.6.0'
13+
id 'nebula.netflixoss' version '5.0.0'
1414
}
1515

1616
// Establish version and status

client/go/httpclient/httpclient.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ func (c *HttpClient) logResponse(statusCode string, response string) {
4949
}
5050

5151
func genParamString(paramMap map[string]string) string {
52-
5352
if paramMap == nil || len(paramMap) == 0 {
5453
return ""
5554
}
@@ -78,7 +77,6 @@ func (c *HttpClient) httpRequest(url string, requestType string, headers map[str
7877
if err != nil {
7978
return "", err
8079
}
81-
8280
// Default Headers
8381
for key, value := range c.Headers {
8482
req.Header.Set(key, value)

common/src/main/java/com/netflix/conductor/common/run/Workflow.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
package com.netflix.conductor.common.run;
1717

1818
import java.util.HashMap;
19+
import java.util.HashSet;
1920
import java.util.LinkedList;
2021
import java.util.List;
2122
import java.util.Map;
23+
import java.util.Set;
2224

2325
import com.netflix.conductor.common.metadata.Auditable;
2426
import com.netflix.conductor.common.metadata.tasks.Task;
@@ -50,13 +52,13 @@ public boolean isSuccessful(){
5052
private WorkflowStatus status = WorkflowStatus.RUNNING;
5153

5254
private long endTime;
53-
55+
5456
private String workflowId;
5557

5658
private String parentWorkflowId;
57-
59+
5860
private String parentWorkflowTaskId;
59-
61+
6062
private List<Task> tasks = new LinkedList<>();
6163

6264
private Map<String, Object> input = new HashMap<>();
@@ -79,6 +81,8 @@ public boolean isSuccessful(){
7981

8082
private Map<String, String> taskToDomain = new HashMap<>();
8183

84+
private Set<String> failedReferenceTaskNames = new HashSet<>();
85+
8286
public Workflow(){
8387

8488
}
@@ -301,7 +305,15 @@ public String getEvent() {
301305
public void setEvent(String event) {
302306
this.event = event;
303307
}
304-
308+
309+
public Set<String> getFailedReferenceTaskNames() {
310+
return failedReferenceTaskNames;
311+
}
312+
313+
public void setFailedReferenceTaskNames(Set<String> failedReferenceTaskNames) {
314+
this.failedReferenceTaskNames = failedReferenceTaskNames;
315+
}
316+
305317
@Override
306318
public String toString() {
307319
return workflowType + "." + version + "/" + workflowId + "." + status;

common/src/main/java/com/netflix/conductor/common/run/WorkflowSummary.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.text.SimpleDateFormat;
2222
import java.util.Date;
2323
import java.util.TimeZone;
24+
import java.util.stream.Collectors;
2425

2526
import com.netflix.conductor.common.run.Workflow.WorkflowStatus;
2627

@@ -60,6 +61,8 @@ public class WorkflowSummary {
6061
private long executionTime;
6162

6263
private String event;
64+
65+
private String failedReferenceTaskNames = "";
6366

6467
public WorkflowSummary() {
6568

@@ -90,6 +93,7 @@ public WorkflowSummary(Workflow workflow) {
9093
this.executionTime = workflow.getEndTime() - workflow.getStartTime();
9194
}
9295
this.event = workflow.getEvent();
96+
this.failedReferenceTaskNames = workflow.getFailedReferenceTaskNames().stream().collect(Collectors.joining(","));
9397
}
9498

9599
/**
@@ -193,4 +197,12 @@ public String getEvent() {
193197
public void setEvent(String event) {
194198
this.event = event;
195199
}
200+
201+
public String getFailedReferenceTaskNames() {
202+
return failedReferenceTaskNames;
203+
}
204+
205+
public void setFailedReferenceTaskNames(String failedReferenceTaskNames) {
206+
this.failedReferenceTaskNames = failedReferenceTaskNames;
207+
}
196208
}

core/src/main/java/com/netflix/conductor/core/execution/DeciderService.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ private DeciderOutcome decide(final WorkflowDef def, final Workflow workflow, Li
130130
TaskDef taskDef = metadata.getTaskDef(task.getTaskDefName());
131131
if(taskDef != null) {
132132
checkForTimeout(taskDef, task);
133+
// If the task has not been updated for "responseTimeout" then rescheduled it.
134+
if(checkForResponseTimeout(taskDef, task)){
135+
outcome.tasksToBeRequeued.add(task);
136+
}
133137
}
134138

135139
if (!task.getStatus().isSuccessful()) {
@@ -374,6 +378,30 @@ void checkForTimeout(TaskDef taskType, Task task) {
374378
return;
375379
}
376380

381+
@VisibleForTesting
382+
boolean checkForResponseTimeout(TaskDef taskType, Task task) {
383+
384+
if(taskType == null){
385+
logger.warn("missing task type " + task.getTaskDefName() + ", workflowId=" + task.getWorkflowInstanceId());
386+
return false;
387+
}
388+
if (task.getStatus().isTerminal() || taskType.getTimeoutSeconds() <= 0 ||
389+
!task.getStatus().equals(Status.IN_PROGRESS) || taskType.getResponseTimeoutSeconds() == 0) {
390+
return false;
391+
}
392+
393+
long responseTimeout = 1000 * taskType.getResponseTimeoutSeconds();
394+
long now = System.currentTimeMillis();
395+
long noResponseTime = now - task.getUpdateTime();
396+
397+
if (noResponseTime < responseTimeout) {
398+
return false;
399+
}
400+
Monitors.recordTaskResponseTimeout(task.getTaskDefName());
401+
402+
return true;
403+
}
404+
377405
private List<Task> getTasksToBeScheduled(WorkflowDef def, Workflow workflow, WorkflowTask taskToSchedule, int retryCount) {
378406
return getTasksToBeScheduled(def, workflow, taskToSchedule, retryCount, null);
379407
}
@@ -672,6 +700,8 @@ public static class DeciderOutcome {
672700
List<Task> tasksToBeScheduled = new LinkedList<>();
673701

674702
List<Task> tasksToBeUpdated = new LinkedList<>();
703+
704+
List<Task> tasksToBeRequeued = new LinkedList<>();
675705

676706
boolean isComplete;
677707

core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,16 @@ public void updateTask(TaskResult result) throws Exception {
434434
if (task.getStatus().isTerminal()) {
435435
task.setEndTime(System.currentTimeMillis());
436436
}
437+
437438
edao.updateTask(task);
438439

440+
//If the task has failed update the failed task reference name in the workflow.
441+
//This gives the ability to look at workflow and see what tasks have failed at a high level.
442+
if(Status.FAILED.equals(task.getStatus())) {
443+
wf.getFailedReferenceTaskNames().add(task.getReferenceTaskName());
444+
edao.updateWorkflow(wf);
445+
}
446+
439447
result.getLogs().forEach(tl -> tl.setTaskId(task.getTaskId()));
440448
edao.addTaskExecLog(result.getLogs());
441449

@@ -511,8 +519,12 @@ public boolean decide(String workflowId) throws Exception {
511519
List<Task> tasksToBeScheduled = outcome.tasksToBeScheduled;
512520
setTaskDomains(tasksToBeScheduled, workflow);
513521
List<Task> tasksToBeUpdated = outcome.tasksToBeUpdated;
522+
List<Task> tasksToBeRequeued = outcome.tasksToBeRequeued;
514523
boolean stateChanged = false;
515524

525+
if(!tasksToBeRequeued.isEmpty()){
526+
addTaskToQueue(tasksToBeRequeued);
527+
}
516528
workflow.getTasks().addAll(tasksToBeScheduled);
517529
for(Task task : tasksToBeScheduled) {
518530
if (SystemTaskType.is(task.getTaskType()) && !task.getStatus().isTerminal()) {

core/src/main/java/com/netflix/conductor/metrics/Monitors.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ public static void recordTaskTimeout(String taskType) {
184184
counter(classQualifier, "task_timeout", "taskType", taskType);
185185
}
186186

187+
public static void recordTaskResponseTimeout(String taskType) {
188+
counter(classQualifier, "task_response_timeout", "taskType", taskType);
189+
}
190+
187191
public static void recordWorkflowTermination(String workflowType, WorkflowStatus status, String ownerApp) {
188192
counter(classQualifier, "workflow_failure", "workflowName", workflowType, "status", status.name(), "ownerApp", ""+ownerApp);
189193
}

es5-persistence/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Usage
22

3-
1. In `server/build.gradle` file, add `compile project(':conductor-es5-persistence')` dependencie
3+
1. In `server/build.gradle` file, add `compile project(':conductor-es5-persistence')` in dependencies
44
1. In `server/ConductorServer.java` file , replace `import com.netflix.conductor.dao.es.EmbeddedElasticSearch` with `import com.netflix.conductor.dao.es5.es.EmbeddedElasticSearch`
55
1. In `server/ServerModule.java` file, replace `import com.netflix.conductor.dao.index.ElasticSearchDAO; import com.netflix.conductor.dao.index.ElasticsearchModule` with `import com.netflix.conductor.dao.es5.index.ElasticSearchDAO; import com.netflix.conductor.dao.es5.index.ElasticsearchModule;`
66
1. Config property 'workflow.elasticsearch.cluster.name' , value with your elasticsearch cluster name

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-bin.zip

0 commit comments

Comments
 (0)