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

Add flow_framework namespace specs #553

Merged
merged 21 commits into from
Sep 6, 2024

Conversation

junweid62
Copy link
Contributor

@junweid62 junweid62 commented Sep 4, 2024

Description

Part of Adding missing API specs #168

API covered in this PR:
POST /_plugins/_flow_framework/workflow
GET /_plugins/_flow_framework/workflow/{workflow_id}
PUT /_plugins/_flow_framework/workflow/{workflow_id}
DELETE /_plugins/_flow_framework/workflow/{workflow_id}

The rest of API spec will be added in the next PR.

Issues Resolved

Part of #508

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.

Junwei Dai added 9 commits September 4, 2024 14:15
Signed-off-by: Junwei Dai <[email protected]>
Signed-off-by: Junwei Dai <[email protected]>
Signed-off-by: Junwei Dai <[email protected]>
refactor:
1.add epilogues that deletes the workflow if it was created.
2.rewrite all the  'whether'
3. remove empty lines
4. add validation enum

Signed-off-by: Junwei Dai <[email protected]>
add version to flow framework and test

Signed-off-by: Junwei Dai <[email protected]>
add delete path param, add delete test, would also delete the workflow previously created

Signed-off-by: Junwei Dai <[email protected]>
Add schema for 4xx response

Signed-off-by: Junwei Dai <[email protected]>
Add eslint ignore 'reprovision'

Signed-off-by: Junwei Dai <[email protected]>
@junweid62
Copy link
Contributor Author

@dbwiddis I have opened a new pull request and would appreciate it if you could take a moment to review it when you have the time. Thank you!

Junwei Dai added 3 commits September 4, 2024 14:33
remove empty line

Signed-off-by: Junwei Dai <[email protected]>
fix merge conflict error
Signed-off-by: Junwei Dai <[email protected]>

Signed-off-by: Junwei Dai <[email protected]>
fix merge conflict error
Signed-off-by: Junwei Dai <[email protected]>

Signed-off-by: Junwei Dai <[email protected]>
Copy link

github-actions bot commented Sep 4, 2024

Changes Analysis

Commit SHA: 67e89be
Comparing To SHA: 0733e62

API Changes

Summary

├─┬Paths
│ ├──[➕] path (3445:3)
│ └──[➕] path (3472:3)
└─┬Components
  ├──[➕] requestBodies (23900:7)
  ├──[➕] requestBodies (23895:7)
  ├──[➕] responses (25967:7)
  ├──[➕] responses (25963:7)
  ├──[➕] responses (25986:7)
  ├──[➕] responses (25991:7)
  ├──[➕] responses (25948:7)
  ├──[➕] responses (26002:7)
  ├──[➕] responses (25977:7)
  ├──[➕] responses (25982:7)
  ├──[➕] responses (25959:7)
  ├──[➕] responses (25937:7)
  ├──[➕] responses (25972:7)
  ├──[➕] parameters (16916:7)
  ├──[➕] parameters (16910:7)
  ├──[➕] parameters (16897:7)
  ├──[➕] parameters (16890:7)
  ├──[➕] parameters (16882:7)
  ├──[➕] parameters (16868:7)
  ├──[➕] parameters (16903:7)
  ├──[➕] parameters (16922:7)
  ├──[➕] parameters (16875:7)
  ├──[➕] schemas (44660:7)
  ├──[➕] schemas (44541:7)
  ├──[➕] schemas (44588:7)
  ├──[➕] schemas (44498:7)
  ├──[➕] schemas (44568:7)
  ├──[➕] schemas (44610:7)
  ├──[➕] schemas (44620:7)
  ├──[➕] schemas (44670:7)
  ├──[➕] schemas (44650:7)
  ├──[➕] schemas (44600:7)
  ├──[➕] schemas (44524:7)
  ├──[➕] schemas (44479:7)
  ├──[➕] schemas (44556:7)
  ├──[➕] schemas (44630:7)
  ├──[➕] schemas (44640:7)
  └──[➕] schemas (44680:7)

Document Element Total Changes Breaking Changes
paths 2 0
components 38 0
  • Total Changes: 40
  • Additions: 40

Report

The full API changes report is available at: https://github.com/opensearch-project/opensearch-api-specification/actions/runs/10728488330/artifacts/1901913020

API Coverage

Before After Δ
Covered (%) 533 (52.2 %) 537 (52.6 %) 4 (0.4 %)
Uncovered (%) 488 (47.8 %) 484 (47.4 %) -4 (-0.4 %)
Unknown 26 26 0

dblock
dblock previously approved these changes Sep 4, 2024
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

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

This looks great! I only have some nits, up to you if you want to address them.

The validator failed for good reason, check, https://github.com/opensearch-project/opensearch-api-specification/actions/runs/10709911469/job/29695704593?pr=553.

spec/namespaces/flow_framework.yaml Outdated Show resolved Hide resolved
spec/schemas/flow_framework._common.yaml Outdated Show resolved Hide resolved
paths: {}
components:
schemas:
FlowFrameworkException:
Copy link
Member

Choose a reason for hiding this comment

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

Does this one inherit from an OpenSearch error type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes , it inherit from OpenSearchException

FlowFrameworkException extends OpenSearchException

Copy link
Member

Choose a reason for hiding this comment

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

That makes it an Exception, though. "Error" in exception handling has a specific meaning (the program should be halted).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It's interesting, the rest response includes the word "error" as an "error message" although it's an "exception". I'll defer to @dblock here on what the appropriate spec/api terminology is here.

Copy link
Member

@dblock dblock Sep 5, 2024

Choose a reason for hiding this comment

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

🤷‍♂️ @nhtruong ?

I would map to actual class names in OpenSearch.

Copy link
Collaborator

@nhtruong nhtruong Sep 5, 2024

Choose a reason for hiding this comment

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

We've been calling them errors through out the Spec (e.g ReponseError). The clients also consider non 2XX responses as errors for error handling. As far as Client-Server communication is concerned (i.e. Web API), there's no distinction between Error and Exception, in my opinion. Any non-2XX response tells the user that something has gone wrong, and we usually call it a 500 Error Code etc instead of a 500 exception code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's go with 'Error' instead. I'll go ahead and update the naming from 'Exception' to 'Error'.

tests/default/flow_framework/workflow.yaml Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Sep 4, 2024

Spec Test Coverage Analysis

Total Tested
563 271 (48.13 %)

junweid62 and others added 2 commits September 4, 2024 14:47
Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
Signed-off-by: Junwei Dai <[email protected]>
1.change flow_framework._common to flow_framework._errors
2.change exception to Error for consistency
Signed-off-by: Junwei Dai <[email protected]>

Signed-off-by: Junwei Dai <[email protected]>
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.

Looks great! Just one missing param as mentioned in the earlier review (and I'm about to file a PR adding the missing docs)

- $ref: '#/components/parameters/flow_framework.create::query.provision'
- $ref: '#/components/parameters/flow_framework.create::query.validation'
# eslint-disable-next-line @cspell/spellchecker
- $ref: '#/components/parameters/flow_framework.create::query.reprovision'
Copy link
Member

Choose a reason for hiding this comment

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

paths: {}
components:
schemas:
FlowFrameworkException:
Copy link
Member

Choose a reason for hiding this comment

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

That makes it an Exception, though. "Error" in exception handling has a specific meaning (the program should be halted).

spec/schemas/flow_framework._common.yaml Outdated Show resolved Hide resolved
Signed-off-by: Junwei Dai <[email protected]>

Signed-off-by: Junwei Dai <[email protected]>
@junweid62
Copy link
Contributor Author

junweid62 commented Sep 4, 2024

@dblock Hi, I have addressed all the comments and made the necessary changes. Regarding the suggestion about:

file: 'namespaces/flow_framework.yaml',
location: 'Operation: DELETE /_plugins/_flow_framework/workflow/{workflow_id}',
message: "The 400 response must be a reference object to '#/components/responses/flow_framework.create@400'."

I believe that using the error name directly like this:

          oneOf:
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/BadRequestError'
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/ConflictError'
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/MissingParameterError'
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/ParameterConflictError'
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/MaxWorkflowsLimitError'
            - $ref: '../schemas/flow_framework._errors.yaml#/components/schemas/WorkflowSaveError'

makes the it clearer in this particular case. Please let me know your thoughts on this approach.

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! Good for now, I've suggested some tests you can add, but those can also come in a later PR as you iterate.

tests/default/flow_framework/workflow.yaml Show resolved Hide resolved
response:
status: 201
output:
test_workflow_id: payload.workflow_id
Copy link
Member

Choose a reason for hiding this comment

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

Could add some invalid JSON here that would fail parsing for another test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add in the next pr

Comment on lines +52 to +59
- synopsis: Delete workflow.
id: delete_flow_framework
path: /_plugins/_flow_framework/workflow/{workflow_id}
method: DELETE
parameters:
workflow_id: ${create_flow_framework.test_workflow_id}
response:
status: 200
Copy link
Member

Choose a reason for hiding this comment

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

Can test the wrong ID here as well.

Junwei Dai added 2 commits September 4, 2024 19:50
Signed-off-by: Junwei Dai <[email protected]>

Signed-off-by: Junwei Dai <[email protected]>
Signed-off-by: Junwei Dai <[email protected]>
@dblock
Copy link
Member

dblock commented Sep 5, 2024

Please let me know your thoughts on this approach.

Makes sense to me. I am still figuring the best way to do these things too! @nhtruong might have other ideas.

Iterate until https://github.com/opensearch-project/opensearch-api-specification/actions/runs/10713232032/job/29722019367?pr=553 is green either way?

@junweid62
Copy link
Contributor Author

Please let me know your thoughts on this approach.

Makes sense to me. I am still figuring the best way to do these things too! @nhtruong might have other ideas.

Iterate until https://github.com/opensearch-project/opensearch-api-specification/actions/runs/10713232032/job/29722019367?pr=553 is green either way?

sure, will do

nhtruong
nhtruong previously approved these changes Sep 5, 2024
Copy link
Collaborator

@nhtruong nhtruong left a comment

Choose a reason for hiding this comment

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

LGTM
Feel free to merge unless you want to add more test cases.

Signed-off-by: Junwei Dai <[email protected]>
@junweid62
Copy link
Contributor Author

@dblock Hi, I just fix the lint spec errors, hope everything goes green this time !

@junweid62
Copy link
Contributor Author

@dblock Hi, got all lint spec passed locally, hope everything goes well this time!

@dblock dblock merged commit 9193d58 into opensearch-project:main Sep 6, 2024
17 checks passed
@dblock
Copy link
Member

dblock commented Sep 6, 2024

👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants