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 256955f44..97e994a8c 100644 --- a/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt +++ b/alerting/src/main/kotlin/org/opensearch/alerting/transport/TransportGetRemoteIndexesAction.kt @@ -81,7 +81,12 @@ 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 { + client.threadPool().threadContext.putTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, userStr) scope.launch { val clusterIndexesList = mutableListOf() @@ -164,14 +169,9 @@ 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 { - threadPool().threadContext.putTransient(ConfigConstants.OPENSEARCH_SECURITY_USER_INFO_THREAD_CONTEXT, userStr) // TODO hurneyt: return aliases as well - admin().indices().resolveIndex(resolveRequest, it) + client.admin().indices().resolveIndex(resolveRequest, it) } } private suspend fun getHealthStatuses(targetClient: Client, parsedIndexesNames: List): ClusterHealthResponse {