Skip to content

Commit

Permalink
Fixed Template Update Location and Improved Logger Statements in Repr…
Browse files Browse the repository at this point in the history
…ovisionWorkflowTransportAction (#918)

* Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction

Signed-off-by: saimedhi <[email protected]>

* Update ReprovisionWorkflowTransportAction.java

Signed-off-by: Sai Medhini Reddy Maryada <[email protected]>

* Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction

Signed-off-by: saimedhi <[email protected]>

* Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction

Signed-off-by: saimedhi <[email protected]>

* Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction

Signed-off-by: saimedhi <[email protected]>

* fixed changelog

Signed-off-by: saimedhi <[email protected]>

---------

Signed-off-by: saimedhi <[email protected]>
Signed-off-by: Sai Medhini Reddy Maryada <[email protected]>
(cherry picked from commit 8b387c9)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 22, 2024
1 parent 7325008 commit b5d8419
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
- Incrementally remove resources from workflow state during deprovisioning ([#898](https://github.com/opensearch-project/flow-framework/pull/898))

### Bug Fixes
- Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction ([#918](https://github.com/opensearch-project/flow-framework/pull/918))

### Infrastructure
### Documentation
- Add knowledge base alert agent into sample templates ([#874](https://github.com/opensearch-project/flow-framework/pull/874))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,28 @@ private void executeWorkflowAsync(
ActionListener<WorkflowResponse> listener
) {
try {
threadPool.executor(PROVISION_WORKFLOW_THREAD_POOL).execute(() -> { executeWorkflow(template, workflowSequence, workflowId); });
threadPool.executor(PROVISION_WORKFLOW_THREAD_POOL).execute(() -> {
updateTemplate(template, workflowId);
executeWorkflow(template, workflowSequence, workflowId);
});

Check warning on line 276 in src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java#L273-L276

Added lines #L273 - L276 were not covered by tests
} catch (Exception exception) {
listener.onFailure(new FlowFrameworkException("Failed to execute workflow " + workflowId, ExceptionsHelper.status(exception)));
}
}

/**
* Replace template document
* @param template The template to store after reprovisioning completes successfully
* @param workflowId The workflowId associated with the workflow that is executing
*/
private void updateTemplate(Template template, String workflowId) {
flowFrameworkIndicesHandler.updateTemplateInGlobalContext(workflowId, template, ActionListener.wrap(templateResponse -> {
logger.info("Updated template for {}", workflowId);
}, exception -> { logger.error("Failed to update use case template for {}", workflowId, exception); }),

Check warning on line 290 in src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java#L288-L290

Added lines #L288 - L290 were not covered by tests
true // ignores NOT_STARTED state if request is to reprovision
);
}

Check warning on line 293 in src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java#L293

Added line #L293 was not covered by tests

/**
* Executes the given workflow sequence
* @param template The template to store after reprovisioning completes successfully
Expand All @@ -289,8 +305,9 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
for (ProcessNode processNode : workflowSequence) {
List<ProcessNode> predecessors = processNode.predecessors();
logger.info(
"Queueing process [{}].{}",
"Queueing Process [{} (type: {})].{}",
processNode.id(),
processNode.workflowStep().getName(),

Check warning on line 310 in src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/flowframework/transport/ReprovisionWorkflowTransportAction.java#L310

Added line #L310 was not covered by tests
predecessors.isEmpty()
? " Can start immediately!"
: String.format(
Expand Down Expand Up @@ -321,18 +338,6 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen

logger.info("updated workflow {} state to {}", workflowId, State.COMPLETED);

// Replace template document
flowFrameworkIndicesHandler.updateTemplateInGlobalContext(
workflowId,
template,
ActionListener.wrap(templateResponse -> {
logger.info("Updated template for {}", workflowId, State.COMPLETED);
}, exception -> {
String errorMessage = "Failed to update use case template for " + workflowId;
logger.error(errorMessage, exception);
}),
true // ignores NOT_STARTED state if request is to reprovision
);
}, exception -> { logger.error("Failed to update workflow state for workflow {}", workflowId, exception); })
);
} catch (Exception ex) {
Expand Down

0 comments on commit b5d8419

Please sign in to comment.