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 4ce6025bd..918c64e74 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 { + if (userStr.isNotEmpty()) client.threadPool().threadContext.putTransient(ConfigConstants.INJECTED_USER, userStr) scope.launch { val clusterIndexesList = mutableListOf() @@ -164,12 +169,7 @@ 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 admin().indices().resolveIndex(resolveRequest, it) }