Skip to content

Commit 528dcab

Browse files
authored
Add user to stashed context when sending alert notification messages. (opensearch-project#2027)
Signed-off-by: Thomas Hurney <hurneyt@amazon.com>
1 parent 0cabf8d commit 528dcab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

alerting/src/main/kotlin/org/opensearch/alerting/MonitorRunner.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.opensearch.alerting.util.destinationmigration.sendNotification
2323
import org.opensearch.alerting.util.isAllowed
2424
import org.opensearch.alerting.util.isTestAction
2525
import org.opensearch.alerting.util.use
26+
import org.opensearch.commons.ConfigConstants
2627
import org.opensearch.commons.alerting.model.ActionRunResult
2728
import org.opensearch.commons.alerting.model.Monitor
2829
import org.opensearch.commons.alerting.model.MonitorRunResult
@@ -69,7 +70,10 @@ abstract class MonitorRunner {
6970
}
7071
if (!dryrun) {
7172
val client = monitorCtx.client
72-
client!!.threadPool().threadContext.stashContext().use {
73+
val userStr = client!!.threadPool().threadContext
74+
.getTransient<String>(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT)
75+
client.threadPool().threadContext.stashContext().use {
76+
client.threadPool().threadContext.putTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, userStr)
7377
withClosableContext(
7478
InjectorContextElement(
7579
monitor.id,

0 commit comments

Comments
 (0)