Reverting to legacy ES client behavior where maxSockets = Infinity (#113644) (#114211)

* Reverting to legacy ES client behavior where maxSockets = Infinity

* Removing unnused type

* Specifying keepAlive: true by default

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Brandon Kobel <brandon.kobel@elastic.co>
This commit is contained in:
Kibana Machine 2021-10-07 15:09:21 -04:00 committed by GitHub
parent a3e390f924
commit b05ee6ddca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 10 deletions

View file

@ -37,6 +37,19 @@ describe('parseClientOptions', () => {
);
});
it('specifies `headers.maxSockets` Infinity and `keepAlive` true by default', () => {
const config = createConfig({});
expect(parseClientOptions(config, false)).toEqual(
expect.objectContaining({
agent: {
keepAlive: true,
maxSockets: Infinity,
},
})
);
});
describe('basic options', () => {
it('`customHeaders` option', () => {
const config = createConfig({
@ -76,11 +89,21 @@ describe('parseClientOptions', () => {
);
});
it('`keepAlive` option', () => {
expect(parseClientOptions(createConfig({ keepAlive: true }), false)).toEqual(
expect.objectContaining({ agent: { keepAlive: true } })
);
expect(parseClientOptions(createConfig({ keepAlive: false }), false).agent).toBeUndefined();
describe('`keepAlive option`', () => {
it('`keepAlive` is true', () => {
const options = parseClientOptions(createConfig({ keepAlive: true }), false);
expect(options.agent).toHaveProperty('keepAlive', true);
});
it('`keepAlive` is false', () => {
const options = parseClientOptions(createConfig({ keepAlive: false }), false);
expect(options.agent).toHaveProperty('keepAlive', false);
});
it('`keepAlive` is undefined', () => {
const options = parseClientOptions(createConfig({}), false);
expect(options.agent).toHaveProperty('keepAlive', true);
});
});
it('`sniffOnStart` options', () => {

View file

@ -59,6 +59,10 @@ export function parseClientOptions(
// do not make assumption on user-supplied data content
// fixes https://github.com/elastic/kibana/issues/101944
disablePrototypePoisoningProtection: true,
agent: {
maxSockets: Infinity,
keepAlive: config.keepAlive ?? true,
},
};
if (config.pingTimeout != null) {
@ -73,11 +77,6 @@ export function parseClientOptions(
? config.sniffInterval
: getDurationAsMs(config.sniffInterval);
}
if (config.keepAlive) {
clientOptions.agent = {
keepAlive: config.keepAlive,
};
}
if (!scoped) {
if (config.username && config.password) {