Skip to content

Commit

Permalink
Add support for OpenSearch 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurav-05 committed Oct 12, 2022
1 parent 0161dbc commit 22bf0a9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci-opensearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ jobs:
- major: 1.x
image: 1.0.0
distribution: opensearch
- major: 2.x
image: 2.3.0
distribution: opensearch
name: ${{ matrix.version.distribution }} ${{ matrix.version.major }}
steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion pkg/es/client/cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (c *ClusterClient) Version() (uint, error) {
if err != nil {
return 0, fmt.Errorf("invalid version format: %s", version[0])
}
if strings.Contains(info.TagLine, "OpenSearch") && major == 1 {
if strings.Contains(info.TagLine, "OpenSearch") && (major == 1 || major == 2) {
return 7, nil
}
return uint(major), nil
Expand Down
4 changes: 4 additions & 0 deletions pkg/es/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ func (c *Configuration) NewClient(logger *zap.Logger, metricsFactory metrics.Fac
logger.Info("OpenSearch 1.x detected, using ES 7.x index mappings")
esVersion = 7
}
if pingResult.Version.Number[0] == '2' {
logger.Info("OpenSearch 2.x detected, using ES 7.x index mappings")
esVersion = 7
}
}
logger.Info("Elasticsearch detected", zap.Int("version", esVersion))
c.Version = uint(esVersion)
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/integration/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *ESStorageIntegration) getVersion() (uint, error) {
}
// OpenSearch is based on ES 7.x
if strings.Contains(pingResult.TagLine, "OpenSearch") {
if pingResult.Version.Number[0] == '1' {
if pingResult.Version.Number[0] == '1' || pingResult.Version.Number[0] == '2' {
esVersion = 7
}
}
Expand Down

0 comments on commit 22bf0a9

Please sign in to comment.