Skip to content

Commit

Permalink
Support OpenSearch 1.0.0
Browse files Browse the repository at this point in the history
Add a check to the version lookup for opensearch. If opensearch is
discovered, set version to 7.10.
  • Loading branch information
reyjrar committed Aug 14, 2021
1 parent 8adedd9 commit 40dbb86
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CopyIndexes.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ es-copy-index.pl - Copy an index from one cluster to another

# VERSION

version 7.9.2
version 8.0

# SYNOPSIS

Expand Down
2 changes: 1 addition & 1 deletion Maintenance.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ es-daily-index-maintenance.pl - Run to prune old indexes and optimize existing

# VERSION

version 7.9.2
version 8.0

# SYNOPSIS

Expand Down
2 changes: 1 addition & 1 deletion README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ App::ElasticSearch::Utilities - Utilities for Monitoring ElasticSearch

# VERSION

version 7.9.2
version 8.0

# SYNOPSIS

Expand Down
2 changes: 1 addition & 1 deletion Searching.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ es-search.pl - Provides a CLI for quick searches of data in ElasticSearch daily

# VERSION

version 7.9.2
version 8.0

# SYNOPSIS

Expand Down
13 changes: 11 additions & 2 deletions lib/App/ElasticSearch/Utilities.pm
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,22 @@ sub _get_es_version {
my $conn = es_connect();
my $resp = $conn->ua->get( sprintf "%s://%s:%d", $conn->proto, $conn->host, $conn->port );
if( $resp->is_success ) {
my $ver;
eval {
$CURRENT_VERSION = join('.', (split /\./,$resp->content->{version}{number})[0,1]);
$ver = $resp->content->{version};
};
if( $ver ) {
if( $ver->{distribution} and $ver->{distribution} eq 'opensearch' ) {
$CURRENT_VERSION = '7.10';
}
else {
$CURRENT_VERSION = join('.', (split /\./,$ver->{number})[0,1]);
}
}
};
if( !defined $CURRENT_VERSION || $CURRENT_VERSION <= 0 ) {
output({color=>'red',stderr=>1}, sprintf "[%d] Unable to determine Elasticsearch version, something has gone terribly wrong: aborting.", $resp->code);
output({color=>'red',stderr=>1}, $resp->content) if $resp->content;
output({color=>'red',stderr=>1}, ref $resp->content ? YAML::Dump($resp->content) : $resp->content) if $resp->content;
exit 1;
}
debug({color=>'magenta'}, "FOUND VERISON '$CURRENT_VERSION'");
Expand Down

0 comments on commit 40dbb86

Please sign in to comment.