mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-28 08:33:55 +00:00
Fix alias not found noisy error logs (#24495)
This commit is contained in:
parent
06c7d82101
commit
56e9fb91d1
@ -1,6 +1,7 @@
|
||||
package org.openmetadata.service.search.elasticsearch;
|
||||
|
||||
import es.co.elastic.clients.elasticsearch.ElasticsearchClient;
|
||||
import es.co.elastic.clients.elasticsearch._types.ElasticsearchException;
|
||||
import es.co.elastic.clients.elasticsearch.indices.CreateIndexRequest;
|
||||
import es.co.elastic.clients.elasticsearch.indices.DeleteIndexRequest;
|
||||
import es.co.elastic.clients.elasticsearch.indices.DeleteIndexResponse;
|
||||
@ -276,12 +277,31 @@ public class ElasticSearchIndexManager implements IndexManagementClient {
|
||||
return indices;
|
||||
}
|
||||
try {
|
||||
|
||||
boolean isAliasExist = client.indices().existsAlias(b -> b.name(aliasName)).value();
|
||||
if (!isAliasExist) {
|
||||
LOG.warn("Alias '{}' does not exist. Returning empty index set.", aliasName);
|
||||
return indices;
|
||||
}
|
||||
|
||||
GetAliasRequest request = GetAliasRequest.of(g -> g.name(aliasName));
|
||||
GetAliasResponse response = client.indices().getAlias(request);
|
||||
|
||||
indices.addAll(response.result().keySet());
|
||||
|
||||
LOG.info("Retrieved indices for alias {}: {}", aliasName, indices);
|
||||
} catch (ElasticsearchException esEx) {
|
||||
if (esEx.status() == 404) {
|
||||
LOG.warn("Alias '{}' not found (404). Returning empty set.", aliasName);
|
||||
return indices;
|
||||
}
|
||||
|
||||
// Other errors should not be masked
|
||||
LOG.error(
|
||||
"Unexpected ElasticsearchException while getting alias {}: {}",
|
||||
aliasName,
|
||||
esEx.getMessage(),
|
||||
esEx);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to get indices for alias {} due to", aliasName, e);
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ import org.openmetadata.schema.utils.JsonUtils;
|
||||
import org.openmetadata.search.IndexMapping;
|
||||
import org.openmetadata.service.search.IndexManagementClient;
|
||||
import os.org.opensearch.client.opensearch.OpenSearchClient;
|
||||
import os.org.opensearch.client.opensearch._types.OpenSearchException;
|
||||
import os.org.opensearch.client.opensearch._types.mapping.TypeMapping;
|
||||
import os.org.opensearch.client.opensearch.indices.CreateIndexRequest;
|
||||
import os.org.opensearch.client.opensearch.indices.CreateIndexResponse;
|
||||
@ -400,12 +401,30 @@ public class OpenSearchIndexManager implements IndexManagementClient {
|
||||
return indices;
|
||||
}
|
||||
try {
|
||||
boolean isAliasExist = client.indices().existsAlias(b -> b.name(aliasName)).value();
|
||||
if (!isAliasExist) {
|
||||
LOG.warn("Alias '{}' does not exist. Returning empty index set.", aliasName);
|
||||
return indices;
|
||||
}
|
||||
|
||||
GetAliasRequest request = GetAliasRequest.of(g -> g.name(aliasName));
|
||||
GetAliasResponse response = client.indices().getAlias(request);
|
||||
|
||||
indices.addAll(response.result().keySet());
|
||||
|
||||
LOG.info("Retrieved indices for alias {}: {}", aliasName, indices);
|
||||
} catch (OpenSearchException osEx) {
|
||||
if (osEx.status() == 404) {
|
||||
LOG.warn("Alias '{}' not found (404). Returning empty set.", aliasName);
|
||||
return indices;
|
||||
}
|
||||
|
||||
// Other errors should not be masked
|
||||
LOG.error(
|
||||
"Unexpected OpensearchException while getting alias {}: {}",
|
||||
aliasName,
|
||||
osEx.getMessage(),
|
||||
osEx);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Failed to get indices for alias {} due to", aliasName, e);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user