Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction #918

Merged
merged 7 commits into from
Oct 22, 2024
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
### Features
### Enhancements
### Bug Fixes
- Fixed Template Update Location and Improved Logger Statements in ReprovisionWorkflowTransportAction ([#918](https://github.com/opensearch-project/flow-framework/pull/918))
saimedhi marked this conversation as resolved.
Show resolved Hide resolved
### Infrastructure
- Set Java target compatibility to JDK 21 ([#730](https://github.com/opensearch-project/flow-framework/pull/730))
- Add knowledge base alert agent into sample templates ([#874](https://github.com/opensearch-project/flow-framework/pull/874))

saimedhi marked this conversation as resolved.
Show resolved Hide resolved
### Documentation
- Add alert summary agent template ([#873](https://github.com/opensearch-project/flow-framework/pull/873))

Expand All @@ -25,6 +25,7 @@ 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
saimedhi marked this conversation as resolved.
Show resolved Hide resolved
### Documentation
- Add query assist data summary agent into sample templates ([#875](https://github.com/opensearch-project/flow-framework/pull/875))
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);
saimedhi marked this conversation as resolved.
Show resolved Hide resolved
executeWorkflow(template, workflowSequence, workflowId);
});
} 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); }),
true // ignores NOT_STARTED state if request is to reprovision
);
}

/**
* Executes the given workflow sequence
* @param template The template to store after reprovisioning completes successfully
Expand All @@ -290,7 +306,7 @@ private void executeWorkflow(Template template, List<ProcessNode> workflowSequen
List<ProcessNode> predecessors = processNode.predecessors();
logger.info(
"Queueing process [{}].{}",
processNode.id(),
String.format("%s (type: %s)", processNode.id(), processNode.workflowStep().getName()),
dbwiddis marked this conversation as resolved.
Show resolved Hide resolved
predecessors.isEmpty()
? " Can start immediately!"
: String.format(
Expand Down Expand Up @@ -321,18 +337,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
Loading