Skip to content

Commit d2df0e1

Browse files
committed
Improve comments
1 parent c730f21 commit d2df0e1

File tree

1 file changed

+7
-3
lines changed
  • x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session

1 file changed

+7
-3
lines changed

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/session/EsqlCCSUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ static String createIndexExpressionFromAvailableClusters(EsqlExecutionInfo execu
147147
StringBuilder sb = new StringBuilder();
148148
for (String clusterAlias : executionInfo.clusterAliases()) {
149149
EsqlExecutionInfo.Cluster cluster = executionInfo.getCluster(clusterAlias);
150+
// Exclude clusters which are either skipped or have no indices matching wildcard, or filtered out.
150151
if (cluster.getStatus() != Cluster.Status.SKIPPED && cluster.getStatus() != Cluster.Status.SUCCESSFUL) {
151152
if (cluster.getClusterAlias().equals(RemoteClusterAware.LOCAL_CLUSTER_GROUP_KEY)) {
152153
sb.append(executionInfo.getCluster(clusterAlias).getIndexExpression()).append(',');
@@ -209,7 +210,7 @@ static void updateExecutionInfoWithClustersWithNoMatchingIndices(
209210
*/
210211
for (String c : clustersWithNoMatchingIndices) {
211212
if (executionInfo.getCluster(c).getStatus() != Cluster.Status.RUNNING) {
212-
// if cluster was already in the terminal state and not filtered, do not overwrite
213+
// if cluster was already in a terminal state, we don't need to check it again
213214
continue;
214215
}
215216
final String indexExpression = executionInfo.getCluster(c).getIndexExpression();
@@ -224,11 +225,14 @@ static void updateExecutionInfoWithClustersWithNoMatchingIndices(
224225
fatalErrorMessage += "; " + error;
225226
}
226227
if (filter == null) {
228+
// Not very useful since we don't send metadata on errors now, but may be useful in the future
229+
// We check for filter since the filter may be the reason why the index is missing, and then it's ok
227230
markClusterWithFinalStateAndNoShards(executionInfo, c, Cluster.Status.FAILED, new VerificationException(error));
228231
}
229232
} else {
230-
// no matching indices and no concrete index requested - just mark it as done, no error
231233
if (indexResolution.isValid()) {
234+
// no matching indices and no concrete index requested - just mark it as done, no error
235+
// We check for the valid resolution because if we have empty resolution it's still an error.
232236
markClusterWithFinalStateAndNoShards(executionInfo, c, Cluster.Status.SUCCESSFUL, null);
233237
}
234238
}
@@ -238,7 +242,7 @@ static void updateExecutionInfoWithClustersWithNoMatchingIndices(
238242
}
239243
}
240244

241-
// Filter-less version
245+
// Filter-less version, mainly for testing where we don't need filter support
242246
static void updateExecutionInfoWithClustersWithNoMatchingIndices(EsqlExecutionInfo executionInfo, IndexResolution indexResolution) {
243247
updateExecutionInfoWithClustersWithNoMatchingIndices(executionInfo, indexResolution, null);
244248
}

0 commit comments

Comments
 (0)