未验证 提交 c4b8c661 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Only report `bug warning` in precise conditions. (#7772)

* Only report `bug warning` in precise conditions.

* Add a test check for template existing.
上级 80b0fed8
......@@ -99,6 +99,8 @@ public class ITElasticSearchTest {
assertThat(templateClient.createOrUpdate(name, ImmutableMap.of(), mappings, 0))
.isTrue();
assertThat(templateClient.exists(name)).isTrue();
assertThat(templateClient.get(name))
.isPresent()
.map(IndexTemplate::getMappings)
......
......@@ -70,14 +70,17 @@ public class StorageEsInstaller extends ModelInstaller {
if (!model.isTimeSeries()) {
return esClient.isExistsIndex(tableName);
}
boolean exist = esClient.isExistsTemplate(tableName)
&& esClient.isExistsIndex(TimeSeriesUtils.latestWriteIndexName(model));
boolean templateExists = esClient.isExistsTemplate(tableName);
final Optional<IndexTemplate> template = esClient.getTemplate(tableName);
boolean lastIndexExists = esClient.isExistsIndex(TimeSeriesUtils.latestWriteIndexName(model));
if ((exist && !template.isPresent()) || (!exist && template.isPresent())) {
throw new Error("[Bug warning]ElasticSearch client query template result is not consistent. Please file an issue to Apache SkyWalking.(https://github.com/apache/skywalking/issues)");
if ((templateExists && !template.isPresent()) || (!templateExists && template.isPresent())) {
throw new Error("[Bug warning] ElasticSearch client query template result is not consistent. " +
"Please file an issue to Apache SkyWalking.(https://github.com/apache/skywalking/issues)");
}
boolean exist = templateExists && lastIndexExists;
if (exist && IndexController.INSTANCE.isMetricModel(model)) {
structures.putStructure(
tableName, template.get().getMappings()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册