Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public String updateWorkflow(WorkflowModel workflowModel) {
} else {
indexDAO.asyncIndexWorkflow(new WorkflowSummary(workflowModel.toWorkflow()));
}
if (workflowModel.getStatus().isTerminal()) {
if (workflowModel.getStatus().isTerminal() && properties.isTaskIndexingEnabled()) {
workflowModel
.getTasks()
.forEach(
Expand Down Expand Up @@ -539,6 +539,9 @@ public void removeTask(String taskId) {

private void removeTaskIndex(WorkflowModel workflow, TaskModel task, boolean archiveTask)
throws JsonProcessingException {
if (!properties.isTaskIndexingEnabled()) {
return;
}
if (archiveTask) {
if (task.getStatus().isTerminal()) {
// Only allow archival if task is in terminal state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package com.netflix.conductor.core.dal;

import java.io.InputStream;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Expand All @@ -28,6 +29,7 @@

import com.netflix.conductor.common.config.TestObjectMapperConfiguration;
import com.netflix.conductor.common.metadata.events.EventExecution;
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.run.Workflow;
import com.netflix.conductor.common.utils.ExternalPayloadStorage;
Expand Down Expand Up @@ -69,6 +71,7 @@ public void setUp() {
ConductorProperties properties = mock(ConductorProperties.class);
when(properties.isEventExecutionIndexingEnabled()).thenReturn(true);
when(properties.isAsyncIndexingEnabled()).thenReturn(true);
when(properties.isTaskIndexingEnabled()).thenReturn(true);
executionDAOFacade =
new ExecutionDAOFacade(
executionDAO,
Expand Down Expand Up @@ -144,6 +147,7 @@ public void testRemoveWorkflow() {

TaskModel task = new TaskModel();
task.setTaskId("taskId");
task.setStatus(TaskModel.Status.COMPLETED);
workflow.setTasks(Collections.singletonList(task));

when(executionDAO.getWorkflow(anyString(), anyBoolean())).thenReturn(workflow);
Expand Down Expand Up @@ -171,6 +175,81 @@ public void testArchiveWorkflow() throws Exception {
verify(indexDAO, never()).removeTask(anyString(), anyString());
}

@Test
public void testUpdateWorkflowSkipsTaskIndexingWhenDisabled() {
WorkflowModel workflow = new WorkflowModel();
WorkflowDef workflowDef = new WorkflowDef();
workflowDef.setName("workflowName");
workflowDef.setVersion(1);
workflow.setWorkflowDefinition(workflowDef);
workflow.setWorkflowId("workflowId");
workflow.setStatus(WorkflowModel.Status.COMPLETED);
workflow.setCreateTime(System.currentTimeMillis() - 10_000);

TaskModel task = new TaskModel();
task.setTaskId("taskId");
task.setStatus(TaskModel.Status.COMPLETED);
workflow.setTasks(Collections.singletonList(task));

ConductorProperties properties = mock(ConductorProperties.class);
when(properties.isEventExecutionIndexingEnabled()).thenReturn(true);
when(properties.isAsyncIndexingEnabled()).thenReturn(true);
when(properties.isTaskIndexingEnabled()).thenReturn(false);
when(properties.getAsyncUpdateShortRunningWorkflowDuration())
.thenReturn(Duration.ofSeconds(1));
when(properties.getAsyncUpdateDelay()).thenReturn(Duration.ofSeconds(0));
ExecutionDAOFacade disabledTaskIndexingFacade =
new ExecutionDAOFacade(
executionDAO,
mock(QueueDAO.class),
indexDAO,
mock(RateLimitingDAO.class),
mock(ConcurrentExecutionLimitDAO.class),
mock(PollDataDAO.class),
objectMapper,
properties,
externalPayloadStorageUtils);

disabledTaskIndexingFacade.updateWorkflow(workflow);

verify(indexDAO, never()).asyncIndexTask(any());
}

@Test
public void testRemoveWorkflowWithTaskIndexingDisabled() {
WorkflowModel workflow = new WorkflowModel();
workflow.setWorkflowId("workflowId");
workflow.setStatus(WorkflowModel.Status.COMPLETED);

TaskModel task = new TaskModel();
task.setTaskId("taskId");
workflow.setTasks(Collections.singletonList(task));

ConductorProperties properties = mock(ConductorProperties.class);
when(properties.isEventExecutionIndexingEnabled()).thenReturn(true);
when(properties.isAsyncIndexingEnabled()).thenReturn(true);
when(properties.isTaskIndexingEnabled()).thenReturn(false);
ExecutionDAOFacade disabledTaskIndexingFacade =
new ExecutionDAOFacade(
executionDAO,
mock(QueueDAO.class),
indexDAO,
mock(RateLimitingDAO.class),
mock(ConcurrentExecutionLimitDAO.class),
mock(PollDataDAO.class),
objectMapper,
properties,
externalPayloadStorageUtils);

when(executionDAO.getWorkflow(anyString(), anyBoolean())).thenReturn(workflow);

disabledTaskIndexingFacade.removeWorkflow("workflowId", false);

verify(indexDAO, times(1)).asyncRemoveWorkflow(anyString());
verify(indexDAO, never()).asyncRemoveTask(anyString(), anyString());
verify(indexDAO, never()).updateTask(anyString(), anyString(), any(), any());
}

@Test
public void testAddEventExecution() {
when(executionDAO.addEventExecution(any())).thenReturn(false);
Expand Down