-
Notifications
You must be signed in to change notification settings - Fork 59
Onboards flow-framework plugin to resource-sharing and access control framework #1251
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
Onboards flow-framework plugin to resource-sharing and access control framework #1251
Conversation
|
CI will resolve once: opensearch-project/security#5677 is merged. |
dace39b to
69009e6
Compare
|
CI blocked by #1252 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1st iteration
src/main/java/org/opensearch/flowframework/util/ParseUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/transport/PluginClient.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/transport/PluginClient.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/transport/PluginClient.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/util/ResourceSharingClientAccessor.java
Outdated
Show resolved
Hide resolved
owaiskazi19
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd iteration
src/main/java/org/opensearch/flowframework/util/PluginClient.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/util/ResourceSharingClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/util/ResourceSharingClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/util/ResourceSharingClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/flowframework/util/ResourceSharingClientAccessor.java
Outdated
Show resolved
Hide resolved
61b0a77 to
20fa46b
Compare
2954350 to
d421090
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1251 +/- ##
============================================
- Coverage 77.84% 77.46% -0.39%
- Complexity 1223 1260 +37
============================================
Files 103 106 +3
Lines 5778 5902 +124
Branches 599 612 +13
============================================
+ Hits 4498 4572 +74
- Misses 992 1034 +42
- Partials 288 296 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
811a01f to
3f61633
Compare
src/test/java/org/opensearch/flowframework/rest/FlowFrameworkResourceSharingRestApiIT.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DarshitChanpura I've tried to fix most issues I've found but don't understand this one.
The FlowFrameworkSecureRestAPI test is failing to find a not found exception after deleting a workflow (line 404)
// Invoke delete API
response = deleteWorkflow(aliceClient, workflowId);
assertEquals(RestStatus.OK, TestHelpers.restStatus(response));
// Invoke status API with failure
ResponseException exception = expectThrows(ResponseException.class, () -> getWorkflowStatus(aliceClient, workflowId, false));
assertEquals(RestStatus.NOT_FOUND.getStatus(), exception.getResponse().getStatusLine().getStatusCode());It may be something in your resource sharing is preventing the deletion (but still returning OK for the delete call?).
Please investigate.
If it helps, Q tells me:
I found the issue! Looking at the DeleteWorkflowTransportAction, I can see that the delete operation is using the sdkClient.deleteDataObjectAsync() method to delete from the global context index, but there's a problem with how the resource authorization is being handled.
The issue is in the verifyResourceAccessAndProcessRequest call. When resource authorization is enabled (which happens when the FlowFrameworkResourceSharingExtension is active), it calls the first lambda () -> executeDeleteRequest(request, tenantId, listener, context) directly without going through the user permission checks.
However, the problem is that when resource authorization is enabled, the workflow might still be accessible through the resource sharing system even after it's deleted from the main index. The getWorkflowStatus call in the test is likely going through the resource sharing system, which might still have a reference to the workflow.
The issue is that the delete operation doesn't properly clean up the workflow from the resource sharing system. When verifyResourceAccessAndProcessRequest is called with resource authorization enabled, it should ensure that the workflow is also removed from the resource sharing system.
Looking at the code, the delete operation only deletes from the GLOBAL_CONTEXT_INDEX using the sdkClient, but it doesn't explicitly remove the workflow from the resource sharing authorization system.
The fix would be to ensure that when a workflow is deleted and resource authorization is enabled, the workflow is also removed from the resource sharing system's authorization records. This might require calling additional cleanup methods on the resource sharing client to remove the workflow's authorization entries.
The specific issue is that the resource sharing system maintains its own records of which resources exist and who has access to them, and these records aren't being cleaned up when the workflow is deleted from the main index.
|
@dbwiddis I was able to reproduce the failure and root-caused it to early response return without waiting for async steps to complete: i have consistently been able to see success for the test run after addressing the fix. |
Nice... unit tests failing on a class cast. Check the argument index if you've added parameters to a method, fixed a few previous tests where action listener was arg 1 and moved to 3... |
4e8882a to
4a9ef42
Compare
I can help here if needed. There's a bit of a timing issue updating the branch protection rules. I suggest asking an admin to override and merge and then update the branch protection rules post-merge. |
Done! |
Ah, now I remember. Deleting the state is asynchronous and occurs AFTER the workflow is deleted. Lines 148 to 176 in 60c3da9
We've handled this in other ITs using a retry-until-it-passes approach: flow-framework/src/test/java/org/opensearch/flowframework/rest/FlowFrameworkRestApiIT.java Lines 408 to 412 in 60c3da9
|
… framework Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
…e-sharing tests Signed-off-by: Darshit Chanpura <[email protected]> # Conflicts: # .github/workflows/test_security.yml
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Co-authored-by: Owais Kazi <[email protected]> Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
…t action-requests as DocRequests Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
…w state reset call Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
… sharing is enab;ed Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Daniel Widdis <[email protected]>
a389f76 to
f65076d
Compare
Description
Implements resource-access-control for workflow and workflow_state.
Related Issues
Check List
--signoff.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.