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

fix default timeouts and ignored requestTimeout #6341

Closed
wants to merge 10 commits into from
2 changes: 1 addition & 1 deletion src/plugins/elasticsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function ({ Plugin }) {
username: string(),
password: string(),
shardTimeout: number().default(0),
requestTimeout: number().default(30000),
requestTimeout: number().default(300000),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we want the default value to be 5 mins. The 30s default seems to be fine for most use cases, and now that the configure value is actually being used, if users need a longer timeout, they can add the elasticsearch.requestTimeout value to their config.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this in so it matched the default value in the kibana.yml config file. Agreed, 5 minutes is probably a bit excessive.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, totally missed that. I think that's a typo in the config file, I think we should fix the value in the yml file and leave this value alone personally. The default in the es client is 30 seconds/30000.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goat

pingTimeout: number().default(30000),
startupTimeout: number().default(5000),
ssl: object({
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/elasticsearch/lib/create_proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ function createProxy(server, method, route, config) {
mapUri: mapUri(server),
passThrough: true,
agent: createAgent(server),
xforward: true
xforward: true,
timeout: server.config().get('elasticsearch.requestTimeout') + 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason for adding another 100ms to the configured timeout value?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had put this in to prevent a race condition and allow the web es client (https://github.com/ich199/kibana/blob/4.x/src/ui/public/es.js) to return/display the correct requestTimeout error before the socket was closed by the Kibana server process. Whether it is actually needed, I'm not sure.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The race condition is a valid concern, but honestly, if the request is timing out, I think we should just let it time out and leave it at that. Added any amount of time padding there, there's still no guarantee we're going to see an error, it could still just timeout.

}
},
};
Expand Down
1 change: 1 addition & 0 deletions src/plugins/testsBundle/testsEntryTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ window.__KBN__ = {
kbnIndex: '.kibana',
esShardTimeout: 1500,
esApiVersion: '2.0',
esRequestTimeout: '300000'
}
};

Expand Down
1 change: 1 addition & 0 deletions src/server/KbnServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ module.exports = class KbnServer {
let { server, config } = this;

await this.ready();
server.listener.timeout = config.get('elasticsearch.requestTimeout') + 100;
await fromNode(cb => server.start(cb));
await require('./pid')(this, server, config);

Expand Down
1 change: 1 addition & 0 deletions src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = async (kbnServer, server, config) => {
defaultInjectedVars.kbnIndex = config.get('kibana.index');
}
if (config.has('elasticsearch')) {
defaultInjectedVars.esRequestTimeout = config.get('elasticsearch.requestTimeout');
defaultInjectedVars.esShardTimeout = config.get('elasticsearch.shardTimeout');
defaultInjectedVars.esApiVersion = config.get('elasticsearch.apiVersion');
}
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ define(function (require) {
var es; // share the client amoungst all apps
require('ui/modules')
.get('kibana', ['elasticsearch', 'kibana/config'])
.service('es', function (esFactory, esUrl, $q, esApiVersion) {
.service('es', function (esFactory, esUrl, $q, esApiVersion, esRequestTimeout) {
if (es) return es;

es = esFactory({
host: esUrl,
log: 'info',
requestTimeout: 0,
requestTimeout: esRequestTimeout,
apiVersion: esApiVersion,
plugins: [function (Client, config) {

Expand Down