-
Notifications
You must be signed in to change notification settings - Fork 125
feat(alerting): Block non-PPL monitor CRUD on pluggable dataformat domains #2141
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ import org.opensearch.cluster.service.ClusterService | |
| import org.opensearch.common.inject.Inject | ||
| import org.opensearch.common.settings.Settings | ||
| import org.opensearch.common.unit.TimeValue | ||
| import org.opensearch.common.util.FeatureFlags | ||
| import org.opensearch.common.xcontent.LoggingDeprecationHandler | ||
| import org.opensearch.common.xcontent.XContentFactory | ||
| import org.opensearch.common.xcontent.XContentHelper | ||
|
|
@@ -85,6 +86,7 @@ import org.opensearch.commons.alerting.model.remote.monitors.RemoteDocLevelMonit | |
| import org.opensearch.commons.alerting.model.userErrorMessage | ||
| import org.opensearch.commons.alerting.util.AlertingException | ||
| import org.opensearch.commons.alerting.util.isMonitorOfStandardType | ||
| import org.opensearch.commons.alerting.util.isPPLMonitor | ||
| import org.opensearch.commons.authuser.User | ||
| import org.opensearch.commons.utils.TenantContext | ||
| import org.opensearch.commons.utils.recreateObject | ||
|
|
@@ -213,6 +215,22 @@ class TransportIndexMonitorAction @Inject constructor( | |
| return | ||
| } | ||
|
|
||
| // Block non-PPL monitors on pluggable dataformat domains | ||
| if (FeatureFlags.isEnabled(FeatureFlags.PLUGGABLE_DATAFORMAT_EXPERIMENTAL_FLAG) && | ||
| !transformedRequest.monitor.isPPLMonitor() | ||
| ) { | ||
| actionListener.onFailure( | ||
| AlertingException.wrap( | ||
| OpenSearchStatusException( | ||
| "Only PPL monitors are supported on this domain." + | ||
| " ${transformedRequest.monitor.monitorType} monitors are not allowed.", | ||
| RestStatus.FORBIDDEN | ||
| ) | ||
| ) | ||
| ) | ||
| return | ||
| } | ||
|
Comment on lines
+219
to
+232
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Code repetition. Can we pull this out into a utility method? |
||
|
|
||
| val user = readUserFromThreadContext(client) | ||
|
|
||
| if (!validateUserBackendRoles(user, actionListener)) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ import org.opensearch.alerting.workflow.CompositeWorkflowRunner | |
| import org.opensearch.cluster.service.ClusterService | ||
| import org.opensearch.common.inject.Inject | ||
| import org.opensearch.common.settings.Settings | ||
| import org.opensearch.common.util.FeatureFlags | ||
| import org.opensearch.common.xcontent.LoggingDeprecationHandler | ||
| import org.opensearch.common.xcontent.XContentFactory.jsonBuilder | ||
| import org.opensearch.common.xcontent.XContentHelper | ||
|
|
@@ -150,6 +151,22 @@ class TransportIndexWorkflowAction @Inject constructor( | |
| return | ||
| } | ||
|
|
||
| // Block workflow creation on pluggable dataformat domains | ||
| if (FeatureFlags.isEnabled( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shouldn't we be blocking get workflow alerts, acknowledge workflow alerts, chained alerts etc.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be taken up on followup pr
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree since workflows can not be created on pluggable dataformat domains, those API would never have data to operate on, but adding explicit blocks for completeness makes sense and can take that as a follow up PR. |
||
| FeatureFlags.PLUGGABLE_DATAFORMAT_EXPERIMENTAL_FLAG | ||
| ) | ||
| ) { | ||
| actionListener.onFailure( | ||
| AlertingException.wrap( | ||
| OpenSearchStatusException( | ||
| "Workflow operations are not supported on this domain.", | ||
| RestStatus.FORBIDDEN | ||
| ) | ||
| ) | ||
| ) | ||
| return | ||
| } | ||
|
|
||
| val transformedRequest = request as? IndexWorkflowRequest | ||
| ?: recreateObject(request, namedWriteableRegistry) { | ||
| IndexWorkflowRequest(it) | ||
|
|
||
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.
how will this task run in our github CIs
can you edit github workflow.yml and add this too
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.
In build.gradle added integTest.finalizedBy which automatically runs integTestPluggableDataFormat task after integTest task , they're included in the CIs. Adding it to workflows could be taken in follow up PR to double guard this .