Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipping new nodes which do not have the http property present yet. #985

Merged
merged 2 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
## [3.3.0]
### Changed
- Updated API to match the OpenSearch spec from Feb 11, 2025
### Fixed
- Skip nodes that are not ready yet ([#984](https://github.com/opensearch-project/opensearch-js/issues/984))

## [3.2.0]
### Changed
Expand Down
6 changes: 6 additions & 0 deletions lib/pool/BaseConnectionPool.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ class BaseConnectionPool {

for (let i = 0, len = ids.length; i < len; i++) {
const node = nodes[ids[i]];

// New nodes do not have the http property populated yet. Skip this for now.
if (node.http === undefined) {
continue;
}

// If there is no protocol in
// the `publish_address` new URL will throw
// the publish_address can have two forms:
Expand Down
29 changes: 29 additions & 0 deletions test/unit/base-connection-pool.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,5 +628,34 @@ test('API', (t) => {
}
});

t.test('Should skip nodes when the http property is undefined', (t) => {
const pool = new BaseConnectionPool({ Connection });
const nodes = {
a1: {
http: {
publish_address: '127.0.0.1:9200',
},
roles: ['master', 'data', 'ingest'],
},
a2: {
roles: ['master', 'data', 'ingest'],
},
};

t.same(pool.nodesToHost(nodes, 'http:'), [
{
url: new URL('http://127.0.0.1:9200'),
id: 'a1',
roles: {
master: true,
data: true,
ingest: true,
},
},
]);

t.end();
});

t.end();
});
Loading