-
Notifications
You must be signed in to change notification settings - Fork 114
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
Adds snapshot management notification implementation #387
Conversation
Codecov Report
@@ Coverage Diff @@
## sm-dev #387 +/- ##
============================================
- Coverage 75.31% 75.28% -0.04%
- Complexity 2345 2444 +99
============================================
Files 298 312 +14
Lines 13517 14478 +961
Branches 2072 2232 +160
============================================
+ Hits 10181 10900 +719
- Misses 2190 2353 +163
- Partials 1146 1225 +79
Continue to review full report at Codecov.
|
865ff45
to
d3dd136
Compare
Signed-off-by: Clay Downs <[email protected]>
d3dd136
to
2b65ea9
Compare
...pensearch/indexmanagement/snapshotmanagement/engine/states/creation/CreationFinishedState.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/model/NotificationConfig.kt
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/model/NotificationConfig.kt
Outdated
Show resolved
Hide resolved
val roles = user.roles.joinToString(",") | ||
val requestedTenant = user.requestedTenant | ||
val userName = user.name | ||
return "$userName|$backendRoles|$roles|$requestedTenant" |
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'm assuming User.toString()
wasn't following this format which is why a utility method was added for it here. Should we instead add a formattedString() method option to common-utils
's User
method so that it can roundtrip between String and parse in a self-contained way?
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.
Good point, yes I believe this would be useful to expose for everyone in common-utils
@@ -22,6 +22,7 @@ import java.time.temporal.ChronoUnit | |||
|
|||
@Suppress("UNCHECKED_CAST") | |||
class RestExplainSnapshotManagementIT : SnapshotManagementRestTestCase() { |
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.
This is more of a general comment but if you haven't already, you can try adding an integration test like this which uses a custom webhook Notification channel which indexes locally to test the Notification integration functionality.
It looks like that test linked above needs to be looked over before it's usable again though so I don't see it as a blocker for approval, more of a nice-to-have.
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 was planning on adding unit and integration tests but wanted to get this in as soon as possible to make it available for pentesters. That test broke when we switched to the notification plugin, I'll try to fix it and will sync up with you if I get blocked.
@@ -51,6 +52,8 @@ abstract class BaseTransportAction<Request : ActionRequest, Response : ActionRes | |||
client.threadPool().threadContext.stashContext().use { threadContext -> | |||
listener.onResponse(executeRequest(request, user, threadContext)) | |||
} | |||
} catch (ex: IndexManagementException) { |
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 what is this for?
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.
That is the exception thrown by the security utils, catching and rethrowing it so security exceptions aren't logged as "uncaught exception"
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/engine/SMStateMachine.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/engine/SMStateMachine.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/opensearch/indexmanagement/snapshotmanagement/model/NotificationConfig.kt
Outdated
Show resolved
Hide resolved
Signed-off-by: Clay Downs <[email protected]>
* Adds notification integration for snapshot management Signed-off-by: Clay Downs <[email protected]> * Changes based on PR comments Signed-off-by: Clay Downs <[email protected]> (cherry picked from commit a46f118)
* Adds notification integration for snapshot management Signed-off-by: Clay Downs <[email protected]> * Changes based on PR comments Signed-off-by: Clay Downs <[email protected]> (cherry picked from commit a46f118) Co-authored-by: Clay Downs <[email protected]>
…ect#387) (opensearch-project#391) * Adds notification integration for snapshot management Signed-off-by: Clay Downs <[email protected]> * Changes based on PR comments Signed-off-by: Clay Downs <[email protected]> (cherry picked from commit a46f118) Co-authored-by: Clay Downs <[email protected]> Signed-off-by: Ronnak Saxena <[email protected]>
…ect#387) (opensearch-project#391) * Adds notification integration for snapshot management Signed-off-by: Clay Downs <[email protected]> * Changes based on PR comments Signed-off-by: Clay Downs <[email protected]> (cherry picked from commit a46f118) Co-authored-by: Clay Downs <[email protected]>
Signed-off-by: Clay Downs [email protected]
Issue #, if available:
Description of changes:
The hooks configure the following:
Creation: when enabled, a notification will be published to the configured channel noting the creation of a snapshot. The message sent will be ""Snapshot <snapshot_name> was created successfully"
Deletion: when enabled, a notification will be published to the configured channel noting the deletion of a snapshot.
"Snapshot(s) <deleted_snapshots> deletion has finished."
Failure: when enabled, a notification will be published to the configured channel noting that a failure occurred while creating or deleting a snapshot.
Either a specific message related to the failure will be sent, or if an uncaught exception is thrown, the message sent will be "There was an exception while executing Snapshot Management policy ${job.policyName}, skipping execution."
Time limit exceeded: when enabled, a notification will be published to the configured channel noting that the configured time limit was exceeded. When this occurs, we simply skip the current creation or deletion, so it isn't explicitly a failure.
"Time limit $timeLimit exceeded during snapshot $workflow step"
CheckList:
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.