Skip to content

Commit

Permalink
Add support for OpenSearch to server detection
Browse files Browse the repository at this point in the history
  • Loading branch information
eht16 committed Jan 14, 2023
1 parent 1b1030a commit 8be85a7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lstail/util/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def _log_error(exc):
else:
try:
exact_version = cluster_state['version']['number']
if exact_version.startswith('2.'):

# OpenSearch
if cluster_state['version'].get('distribution') == "opensearch":
es_major_version = ELASTICSEARCH_MAJOR_VERSION_7
# ElasticSearch
elif exact_version.startswith('2.'):
es_major_version = ELASTICSEARCH_MAJOR_VERSION_2
elif exact_version.startswith('5.') or exact_version.startswith('6.'):
es_major_version = ELASTICSEARCH_MAJOR_VERSION_6
Expand Down
17 changes: 17 additions & 0 deletions tests/test_data/opensearch_cluster_state_es1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name" : "test-cluster-os2-n1",
"cluster_name" : "test-cluster-os2",
"cluster_uuid" : "d6af0bf5-3be4-4e98-aff1-812a5b6bcdfe",
"version" : {
"distribution" : "opensearch",
"number" : "1.2.0",
"build_type" : "tar",
"build_hash" : "c459282fd67ddb17dcc545ec9bcdc805880bcbec",
"build_date" : "2021-11-22T16:57:18.360386Z",
"build_snapshot" : false,
"lucene_version" : "8.10.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "The OpenSearch Project: https://opensearch.org/"
}
17 changes: 17 additions & 0 deletions tests/test_data/opensearch_cluster_state_es2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name" : "test-cluster-os2-n1",
"cluster_name" : "test-cluster-os2",
"cluster_uuid" : "d6af0bf5-3be4-4e98-aff1-812a5b6bcdfe",
"version" : {
"distribution" : "opensearch",
"number" : "2.4.0",
"build_type" : "tar",
"build_hash" : "744ca260b892d119be8164f48d92b8810bd7801c",
"build_date" : "2022-11-15T04:42:29.671309257Z",
"build_snapshot" : false,
"lucene_version" : "9.4.1",
"minimum_wire_compatibility_version" : "7.10.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "The OpenSearch Project: https://opensearch.org/"
}
2 changes: 2 additions & 0 deletions tests/unit/util_http_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
(ELASTICSEARCH_MAJOR_VERSION_7, 'elasticsearch_cluster_state_es7'),
(ELASTICSEARCH_MAJOR_VERSION_6, 'elasticsearch_cluster_state_es6'),
(ELASTICSEARCH_MAJOR_VERSION_2, 'elasticsearch_cluster_state_es2'),
(ELASTICSEARCH_MAJOR_VERSION_7, 'opensearch_cluster_state_es1'),
(ELASTICSEARCH_MAJOR_VERSION_7, 'opensearch_cluster_state_es2'),
)


Expand Down

0 comments on commit 8be85a7

Please sign in to comment.