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

Adding a get status API #148

Merged
merged 7 commits into from
Nov 15, 2023

Conversation

amitgalitz
Copy link
Member

@amitgalitz amitgalitz commented Nov 6, 2023

Description

Currently implemented so when not given _all=true the response is:

{
    {
    "workflow_id": "fJTmz4sBVvQ80zEwbS1x",
    "state": "COMPLETED",
    "resources_created": [
        {
            "workflow_step_name": "create_connector",
            "resource_id": "fZTmz4sBVvQ80zEwkC2z"
        }
    ]
}
}

when: /_plugins/_flow_framework/workflow/yfRsposBMbAFAhZEJ1qE/_status?all=true
then response includes all of state index like this:

{
    "workflow_id": "fJTmz4sBVvQ80zEwbS1x",
    "state": "COMPLETED",
    "provisioning_progress": "DONE",
    "provision_start_time": 1700000075690,
    "provision_end_time": 1700000076398,
    "resources_created": [
        {
            "workflow_step_name": "create_connector",
            "resource_id": "fZTmz4sBVvQ80zEwkC2z"
        }
    ]
}

Currently GC content (template) is not embedded within response, added some of the prerequisites for that but not fully implemented, can be done when GET workflow API is complete.

Additional Issues highlighting further work:#136 -> This PR adds the resources created addition logic to create_connector, following PR will add the work for each step.

#171 -> adding the full template in the status response as well to help with faster frontend fetching

Issues Resolved

Closes #22

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@github-actions github-actions bot added the backport 2.x backport PRs to 2.x branch label Nov 6, 2023
@amitgalitz amitgalitz changed the title Adding a status API Adding a get status API Nov 6, 2023
@amitgalitz amitgalitz marked this pull request as ready for review November 6, 2023 21:10
@amitgalitz amitgalitz force-pushed the status-api-dev branch 3 times, most recently from 10475ff to c5b7d72 Compare November 9, 2023 22:27
Copy link
Member

@joshpalis joshpalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial pass, looks good so far, a couple of comments mostly on naming.

Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial pass. Need tests

@ohltyler
Copy link
Member

Typically params don't have the _ prefix - suggest to change _all -> all

@ohltyler
Copy link
Member

Typically params don't have the _ prefix - suggest to change _all -> all

I see this is covered - thanks!

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Attention: 132 lines in your changes are missing coverage. Please review.

Comparison is base (56ccb1d) 68.39% compared to head (2fa6fd1) 72.11%.
Report is 3 commits behind head on main.

❗ Current head 2fa6fd1 differs from pull request most recent head a6b4dee. Consider uploading reports for the commit a6b4dee to get more accurate results

Files Patch % Lines
...ramework/transport/GetWorkflowTransportAction.java 38.70% 19 Missing ⚠️
...framework/indices/FlowFrameworkIndicesHandler.java 0.00% 18 Missing ⚠️
.../opensearch/flowframework/model/WorkflowState.java 58.97% 13 Missing and 3 partials ⚠️
...rk/transport/ProvisionWorkflowTransportAction.java 23.80% 16 Missing ⚠️
...arch/flowframework/rest/RestGetWorkflowAction.java 53.12% 14 Missing and 1 partial ⚠️
...a/org/opensearch/flowframework/model/Template.java 77.04% 13 Missing and 1 partial ⚠️
...ensearch/flowframework/model/ResourcesCreated.java 73.52% 8 Missing and 1 partial ⚠️
...ch/flowframework/workflow/CreateConnectorStep.java 65.21% 8 Missing ⚠️
...flowframework/workflow/RegisterLocalModelStep.java 91.25% 4 Missing and 3 partials ⚠️
...lowframework/workflow/RegisterRemoteModelStep.java 87.50% 1 Missing and 2 partials ⚠️
... and 5 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #148      +/-   ##
============================================
+ Coverage     68.39%   72.11%   +3.71%     
- Complexity      339      406      +67     
============================================
  Files            45       53       +8     
  Lines          1585     1947     +362     
  Branches        143      164      +21     
============================================
+ Hits           1084     1404     +320     
- Misses          452      472      +20     
- Partials         49       71      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@owaiskazi19 owaiskazi19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another pass

@owaiskazi19
Copy link
Member

@amitgalitz resource created should have the exact entry we have for WorkflowData

createConnectorFuture.complete(
                    new WorkflowData(Map.ofEntries(Map.entry("connector_id", mlCreateConnectorResponse.getConnectorId())))
                );
 "resources_created": [
        {
            "workflow_step_name": "create_connector",
            "resource_id": "fZTmz4sBVvQ80zEwkC2z",
            "connector_id": "XYZ"
        }
    ]

@amitgalitz
Copy link
Member Author

@amitgalitz resource created should have the exact entry we have for WorkflowData

createConnectorFuture.complete(
                    new WorkflowData(Map.ofEntries(Map.entry("connector_id", mlCreateConnectorResponse.getConnectorId())))
                );
 "resources_created": [
        {
            "workflow_step_name": "create_connector",
            "resource_id": "fZTmz4sBVvQ80zEwkC2z",
            "connector_id": "XYZ"
        }
    ]

resource_id and connector_id are the same here

@owaiskazi19
Copy link
Member

resource_id and connector_id are the same here

then let's call it connector_id

@amitgalitz
Copy link
Member Author

resource_id and connector_id are the same here

then let's call it connector_id

I want it to be static field though so its cleaner on searching and mapping, the keys of resource_id and workflow_step_name wont change between resources. If you still think otherwise thats fair, more info here: #136. This also might have some small changes as Dan implements the delete api.

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally looks good, but need to understand more about how the id String tells me what sort of resource I will need to remove later.

Are we assuming a one-to-one correspondence between workflow step and resource? I'm not sure how certain that assumption is.

Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with pending TODO handled in another PR

Copy link
Member

@ohltyler ohltyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read latest updates and comments, no concerns. Giving a soft approval :)

@amitgalitz amitgalitz merged commit e3bbfcb into opensearch-project:main Nov 15, 2023
19 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 15, 2023
* adding workflow state and create connector resources created

Signed-off-by: Amit Galitzky <[email protected]>

* add plugin enabled setting check for get status api

Signed-off-by: Amit Galitzky <[email protected]>

* addressing comments

Signed-off-by: Amit Galitzky <[email protected]>

* addressing additional conflicts

Signed-off-by: Amit Galitzky <[email protected]>

* addressed comments and added more tests

Signed-off-by: Amit Galitzky <[email protected]>

* removed additional listener in provision action

Signed-off-by: Amit Galitzky <[email protected]>

* changed resourcescreated to resourceCreated and other minor comment changes

Signed-off-by: Amit Galitzky <[email protected]>

---------

Signed-off-by: Amit Galitzky <[email protected]>
(cherry picked from commit e3bbfcb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
joshpalis pushed a commit that referenced this pull request Nov 15, 2023
Adding a get status API (#148)

* adding workflow state and create connector resources created



* add plugin enabled setting check for get status api



* addressing comments



* addressing additional conflicts



* addressed comments and added more tests



* removed additional listener in provision action



* changed resourcescreated to resourceCreated and other minor comment changes



---------


(cherry picked from commit e3bbfcb)

Signed-off-by: Amit Galitzky <[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>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Nov 27, 2023
* adding workflow state and create connector resources created

Signed-off-by: Amit Galitzky <[email protected]>

* add plugin enabled setting check for get status api

Signed-off-by: Amit Galitzky <[email protected]>

* addressing comments

Signed-off-by: Amit Galitzky <[email protected]>

* addressing additional conflicts

Signed-off-by: Amit Galitzky <[email protected]>

* addressed comments and added more tests

Signed-off-by: Amit Galitzky <[email protected]>

* removed additional listener in provision action

Signed-off-by: Amit Galitzky <[email protected]>

* changed resourcescreated to resourceCreated and other minor comment changes

Signed-off-by: Amit Galitzky <[email protected]>

---------

Signed-off-by: Amit Galitzky <[email protected]>
(cherry picked from commit e3bbfcb)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
joshpalis added a commit that referenced this pull request Nov 27, 2023
Adding a get status API (#148)

* adding workflow state and create connector resources created



* add plugin enabled setting check for get status api



* addressing comments



* addressing additional conflicts



* addressed comments and added more tests



* removed additional listener in provision action



* changed resourcescreated to resourceCreated and other minor comment changes



---------


(cherry picked from commit e3bbfcb)

Signed-off-by: Amit Galitzky <[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>
Co-authored-by: Joshua Palis <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Create Status API
5 participants