From 12c0df3a5cd5aa14c2a30d067db7dc1aabd9f529 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Wed, 4 Oct 2023 18:48:28 -0500 Subject: [PATCH] review comments --- .../elasticsearch/xpack/security/authc/TokenService.java | 8 ++++---- .../xpack/security/authc/esnative/NativeUsersStore.java | 4 ++-- .../xpack/security/support/SecurityIndexManager.java | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index 0b05715940e6c..794bcd96a66c3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -1791,8 +1791,8 @@ private void sourceIndicesWithTokensAndRun(ActionListener> listener final SecurityIndexManager frozenTokensIndex = securityTokensIndex.defensiveCopy(); if (frozenTokensIndex.indexExists()) { // an existing tokens index always contains tokens (if available and version allows) - if (false == frozenTokensIndex.isAvailable(PRIMARY_SHARDS)) { - listener.onFailure(frozenTokensIndex.getUnavailableReason(PRIMARY_SHARDS)); + if (false == frozenTokensIndex.isAvailable(SEARCH_SHARDS)) { + listener.onFailure(frozenTokensIndex.getUnavailableReason(SEARCH_SHARDS)); return; } if (false == frozenTokensIndex.isIndexUpToDate()) { @@ -1814,8 +1814,8 @@ private void sourceIndicesWithTokensAndRun(ActionListener> listener if (false == frozenTokensIndex.indexExists() || frozenTokensIndex.getCreationTime() .isAfter(clock.instant().minus(ExpiredTokenRemover.MAXIMUM_TOKEN_LIFETIME_HOURS, ChronoUnit.HOURS))) { - if (false == frozenMainIndex.isAvailable(PRIMARY_SHARDS)) { - listener.onFailure(frozenMainIndex.getUnavailableReason(PRIMARY_SHARDS)); + if (false == frozenMainIndex.isAvailable(SEARCH_SHARDS)) { + listener.onFailure(frozenMainIndex.getUnavailableReason(SEARCH_SHARDS)); return; } if (false == frozenMainIndex.isIndexUpToDate()) { diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java index d202fbfb3400d..36f78682b6bd1 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java @@ -123,8 +123,8 @@ public void getUsers(String[] userNames, final ActionListener> final SecurityIndexManager frozenSecurityIndex = this.securityIndex.defensiveCopy(); if (frozenSecurityIndex.indexExists() == false) { listener.onResponse(Collections.emptyList()); - } else if (frozenSecurityIndex.isAvailable(SEARCH_SHARDS) == false) { - listener.onFailure(frozenSecurityIndex.getUnavailableReason(SEARCH_SHARDS)); + } else if (frozenSecurityIndex.isAvailable(PRIMARY_SHARDS) == false) { + listener.onFailure(frozenSecurityIndex.getUnavailableReason(PRIMARY_SHARDS)); } else if (userNames.length == 1) { // optimization for single user lookup final String username = userNames[0]; getUserAndPassword( diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java index bbaa8f4db4985..62bb20322f185 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecurityIndexManager.java @@ -308,7 +308,7 @@ private Tuple checkIndexAvailable(ClusterState state) { } if (allPrimaryShards == false || searchShards == false) { logger.debug( - "Index [{}] is not fully available." + " all primary shards available [{}], search shards available, [{}]", + "Index [{}] is not fully available. all primary shards available [{}], search shards available, [{}]", aliasName, allPrimaryShards, searchShards