Skip to content

Commit 6441da7

Browse files
[Backport 2.x] Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction (#925)
Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction (#918) * Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction * Update ReprovisionWorkflowTransportAction.java * Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction * Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction * Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction * fixed changelog --------- (cherry picked from commit 8b387c9) Signed-off-by: saimedhi <[email protected]> Signed-off-by: Sai Medhini Reddy Maryada <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 7325008 commit 6441da7

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
2525
- Incrementally remove resources from workflow state during deprovisioning ([#898](https://github.com/opensearch-project/flow-framework/pull/898))
2626

2727
### Bug Fixes
28+
- Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction ([#918](https://github.com/opensearch-project/flow-framework/pull/918))
29+
2830
### Infrastructure
2931
### Documentation
3032
- Add knowledge base alert agent into sample templates ([#874](https://github.com/opensearch-project/flow-framework/pull/874))

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

+19-14
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,28 @@ private void executeWorkflowAsync(
270270
ActionListener<WorkflowResponse> listener
271271
) {
272272
try {
273-
threadPool.executor(PROVISION_WORKFLOW_THREAD_POOL).execute(() -> { executeWorkflow(template, workflowSequence, workflowId); });
273+
threadPool.executor(PROVISION_WORKFLOW_THREAD_POOL).execute(() -> {
274+
updateTemplate(template, workflowId);
275+
executeWorkflow(template, workflowSequence, workflowId);
276+
});
274277
} catch (Exception exception) {
275278
listener.onFailure(new FlowFrameworkException("Failed to execute workflow " + workflowId, ExceptionsHelper.status(exception)));
276279
}
277280
}
278281

282+
/**
283+
* Replace template document
284+
* @param template The template to store after reprovisioning completes successfully
285+
* @param workflowId The workflowId associated with the workflow that is executing
286+
*/
287+
private void updateTemplate(Template template, String workflowId) {
288+
flowFrameworkIndicesHandler.updateTemplateInGlobalContext(workflowId, template, ActionListener.wrap(templateResponse -> {
289+
logger.info("Updated template for {}", workflowId);
290+
}, exception -> { logger.error("Failed to update use case template for {}", workflowId, exception); }),
291+
true // ignores NOT_STARTED state if request is to reprovision
292+
);
293+
}
294+
279295
/**
280296
* Executes the given workflow sequence
281297
* @param template The template to store after reprovisioning completes successfully
@@ -289,8 +305,9 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
289305
for (ProcessNode processNode : workflowSequence) {
290306
List<ProcessNode> predecessors = processNode.predecessors();
291307
logger.info(
292-
"Queueing process [{}].{}",
308+
"Queueing Process [{} (type: {})].{}",
293309
processNode.id(),
310+
processNode.workflowStep().getName(),
294311
predecessors.isEmpty()
295312
? " Can start immediately!"
296313
: String.format(
@@ -321,18 +338,6 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
321338

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

324-
// Replace template document
325-
flowFrameworkIndicesHandler.updateTemplateInGlobalContext(
326-
workflowId,
327-
template,
328-
ActionListener.wrap(templateResponse -> {
329-
logger.info("Updated template for {}", workflowId, State.COMPLETED);
330-
}, exception -> {
331-
String errorMessage = "Failed to update use case template for " + workflowId;
332-
logger.error(errorMessage, exception);
333-
}),
334-
true // ignores NOT_STARTED state if request is to reprovision
335-
);
336341
}, exception -> { logger.error("Failed to update workflow state for workflow {}", workflowId, exception); })
337342
);
338343
} catch (Exception ex) {

0 commit comments

Comments
 (0)