-
Notifications
You must be signed in to change notification settings - Fork 93
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 replication (CCR) plugin interface and classes to common-utils #667
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: aggarwalShivani <shivani.aggarwal@nokia.com>
src/main/kotlin/org/opensearch/commons/replication/action/ReplicationActions.kt
Show resolved
Hide resolved
Signed-off-by: aggarwalShivani <shivani.aggarwal@nokia.com>
Signed-off-by: aggarwalShivani <shivani.aggarwal@nokia.com>
* replication. | ||
*/ | ||
const val STOP_REPLICATION_ACTION_NAME = "indices:admin/plugins/replication/index/stop" | ||
const val UNFOLLOW_REPLICATION_ACTION_NAME = "indices:admin/plugins/replication/index/unfollow" |
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.
We probably can use some better name here, I'm thinking
indices:admin/plugins/replication/index/stop_from_ism
😅
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.
Yeah I agreee 😅
But I was wondering if stop_from_ism would limit it to being only from ism? and what if some other plugin in future intends to invoke stop-replication using these libs. 🤔
Would something like stop_from_transport / transport_stop / stop_from_plugin work?
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.
yeah, better to be intuitive for our user.
Looking at all the existing ones, I am thinking indices:transport/plugins/replication/index/stop
Hopefully transport is a common word for OpenSearch user.
# Index Level Permissions
indices:admin/close
indices:admin/close[s]
indices:admin/create
indices:admin/mapping/put
indices:admin/open
indices:admin/plugins/replication/index/start
indices:admin/plugins/replication/index/stop
indices:data/read/plugins/replication/file_metadata
indices:data/write/index
indices:data/write/plugins/replication/changes
indices:data/write/replication
indices:monitor/stats
@cwperks to give some suggestion about the naming of the new transport action
This new transport action being added here is only supposed to be called from ISM plugin, and doesn't have any REST API associated with it. ISM user will need this permission to do the stop replication action using ISM.
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.
@bowenlan-amzn indices:transport
is not one of the valid action prefixes tracked in core. You can introduce a new action prefix by opening a PR in core to add to that list.
I see there is indices:internal
in the list of prefixes. Is that prefix reserved for actions defined in OpenSearch core, or is it possible for a plugin to use that prefix as well?
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.
Thanks!
indices:internal
makes sense here
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.
I will try with indices:internal/plugins/replication/index/stop then 🙂
Thank you @cwperks and @bowenlan-amzn for these inputs.
* the response object. | ||
*/ | ||
@Suppress("UNCHECKED_CAST") | ||
private fun <Response : AcknowledgedResponse> wrapActionListener( |
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.
From the existing code in AlertingPluginInterface, I see we are doing <Response: BaseResponse>, does that have problem here? can we also use BaseResponse, instead of AcknowledgedResponse.
}.whenever(client).execute(Mockito.any(ActionType::class.java), Mockito.any(), Mockito.any()) | ||
|
||
ReplicationPluginInterface.stopReplication(client, request, listener) | ||
Mockito.verify(listener, Mockito.times(1)).onResponse(ArgumentMatchers.eq(response)) |
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.
not sure about what this test is checking, would you explain a bit
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.
Sure. I've written this test on similar lines as done in NotificationsPluginInterfaceTests.kt and AlertingPluginInterfaceTests.kt
- An AcknowledgedResponse response object is created with a value of true (expected response).
- Have mocked the client object such that, when stopReplication() invokes client.execute(), it would trigger the onResponse method of the ActionListener with the successful response object created earlier.
- The test runs stopReplication() and verifies that the onResponse() method of the listener was called exactly once with the provided response object as an argument.
- This is to simulate a successful execution and verifies that the stopReplication method correctly handles the response.
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.
Thanks for the explain
What I feel weird is we mock the client.execute to do listener.onResponse
Then we call stopReplication which just does client.execute, and verify listener.onResponse called once
In the end, it seems just testing stopReplication does client.execute exactly once 🤔
but it's fine, just curious what it actually test...
Description
Background:
Proposed Solution:
(FYI - This is an alternative approach for this feature. I had also raised a draft PR with a different approach, but we didnt go ahead with it as it required changes in opensearch-core as well.)
Change description:
Code for StopIndexReplicationRequest and StopIndexReplicationAction are moved to common-utils. Added UTs for both the new classes added.
This PR caters to point 1 of the proposed solution.
Issues Resolved
Related Issues
unfollow-action #726
Check List
[ ] New functionality has been documented.[ ] New functionality has javadoc addedBy 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.