From 883afe6276dc907290ddd97a4624439321c0bce3 Mon Sep 17 00:00:00 2001 From: AWSHurneyt Date: Thu, 25 Jan 2024 17:31:16 -0800 Subject: [PATCH] Troubleshooting user injection. Signed-off-by: AWSHurneyt --- .../transport/TransportGetRemoteIndexesAction.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt index 86ec5e8ec..4ce6025bd 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt @@ -81,13 +81,7 @@ class TransportGetRemoteIndexesAction @Inject constructor( return } - val userStr = client.threadPool().threadContext - .getTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT) - log.info("hurneyt TransportGetRemoteIndexesAction::userStr = {}", userStr) - client.threadPool().threadContext.stashContext().use { - if (userStr.isNotEmpty()) client.threadPool().threadContext.putTransient(ConfigConstants.INJECTED_USER, userStr) - scope.launch { val clusterIndexesList = mutableListOf() @@ -170,9 +164,14 @@ class TransportGetRemoteIndexesAction @Inject constructor( ResolveIndexAction.Request.DEFAULT_INDICES_OPTIONS ) + val userStr = client.threadPool().threadContext + .getTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT) + log.info("hurneyt TransportGetRemoteIndexesAction::userStr = {}", userStr) + return client.suspendUntil { + if (userStr.isNotEmpty()) threadPool().threadContext.putTransient(ConfigConstants.INJECTED_USER, userStr) // TODO hurneyt: return aliases as well - client.admin().indices().resolveIndex(resolveRequest, it) + admin().indices().resolveIndex(resolveRequest, it) } } private suspend fun getHealthStatuses(targetClient: Client, parsedIndexesNames: List): ClusterHealthResponse {