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

Handle warnings from task manager without stack traces. #30692

Merged

Conversation

njd5475
Copy link
Contributor

@njd5475 njd5475 commented Feb 11, 2019

Summary

This PR adds catches to for the initialization errors that are thrown by the Task Manager. So that the logs are not plagued with stack traces.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@elasticmachine
Copy link
Contributor

💔 Build Failed

@njd5475 njd5475 added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Feb 11, 2019
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform

@njd5475
Copy link
Contributor Author

njd5475 commented Feb 11, 2019

retest

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@njd5475 njd5475 requested a review from tsullivan February 12, 2019 14:33
Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

LGTM

@njd5475 njd5475 merged commit 057815f into elastic:master Feb 12, 2019
njd5475 added a commit to njd5475/kibana that referenced this pull request Feb 12, 2019
* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
njd5475 added a commit to njd5475/kibana that referenced this pull request Feb 12, 2019
* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
njd5475 added a commit to njd5475/kibana that referenced this pull request Feb 12, 2019
* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
state: { stats: {}, runs: 0 },
});
}catch(e) {
server.log(['warning', 'maps'], `Error scheduling telemetry task, received ${e.message}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Couple things:

  1. This is using the tag maps, and I assume it should be using a tag relevant to task manager.
  2. I don't think swallowing all possible exceptions and treating them as warnings is the right approach here, or pretty much ever. There are specific errors we'd expect to see in the course of normal operation (like Elasticsearch not being available or authentication being rejected), but if something truly exceptional occurs, we'll want it to be treated properly as an error.

Copy link
Member

Choose a reason for hiding this comment

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

  1. this is the maps collector, so that part is right
  2. I agree this shouldn't be swallowed, but on the other hand, I hope the timing errors or connection handling can be handled more by Task Manager

Copy link
Contributor Author

@njd5475 njd5475 Feb 12, 2019

Choose a reason for hiding this comment

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

The timing errors should be avoidable, by reworking the way the task manager gets initialized. So that we completely avoid the chicken or the egg problem. But I agree that it would be nice to handle these inside the task manager rather than put this on the consumers of the task manager service.

@@ -99,7 +99,7 @@ export class TaskManager {
})
.catch((err: Error) => {
// FIXME: check the type of error to make sure it's actually an ES error
logger.warning(err.message);
logger.warning(`PollError ${err.message}`);
Copy link
Contributor

Choose a reason for hiding this comment

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

This sort of thing should be handled by a logger tag rather than string concatenation. This ensures folks can reliably filter/drill-down alerts based on type.

@epixa
Copy link
Contributor

epixa commented Feb 12, 2019

@njd5475 I know this is already merged, but please address the feedback I just posted in a followup PR. /cc @tsullivan

@epixa epixa added non-issue Indicates to automation that a pull request should not appear in the release notes and removed v6.7.1 labels Feb 12, 2019
@epixa
Copy link
Contributor

epixa commented Feb 12, 2019

Also, please add some tests for this behavior

njd5475 added a commit that referenced this pull request Feb 13, 2019
)

* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
njd5475 added a commit that referenced this pull request Feb 13, 2019
)

* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
njd5475 added a commit that referenced this pull request Feb 13, 2019
)

* Handle warnings from task manager without stack traces.

* Fix typescript errors.

* Catch no living connection errors.

Swallow stack traces and do not throw errors.

* Should use string substitution instead of concatenation.
@tsullivan
Copy link
Member

tsullivan commented Mar 5, 2019

Coming back to this after testing a 6.7.0 build.

I start Kibana and Elasticsearch at the same time, and it takes Elasticsearch awhile to start all of the shards.

There are 2 plugins that try to schedule their own tasks, and they hit a problem that gets somewhat obscured by this change:

�[36mkibana_1         |�[0m {"type":"log","@timestamp":"2019-03-05T17:02:58Z","tags":["warning","maps"],"pid":1,"message":"Error scheduling telemetry task, received NotInitialized: Tasks cannot be scheduled until after task manager is initialized!"}

�[36mkibana_1         |�[0m {"type":"log","@timestamp":"2019-03-05T17:02:58Z","tags":["warning","telemetry"],"pid":1,"message":"Error scheduling task, received NotInitialized: Tasks cannot be scheduled until after task manager is initialized!"}

How plugins can schedule their own built-in tasks unfortunately seems to be a mystery. Ideally, waiting for the kbnServer.afterPluginsInit event can work (1), but it's not reliable since there could still be no connection to ES. All the plugins can init before Elasticsearch has any shards ready. When the plugins try to schedule their tasks, Task Manager just throws them away and logs this error.

Question for Platform: Should plugins wait on some other event before scheduling built-in tasks? Should they keep retrying on their own? All task scheduling goes through taskManager.schedule, so it would be great for the consumer if Task Manager "managed" the retrying. (2)

(1) and helps the Task Manager know that it has all task types registered by this point. An unrecognized task type is a bug, not a race condition
(2) also, the Task Manager handles retrying when task execution throws an error - so retries seem to be in the Task Manager domain.

cc @alexfrancoeur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-issue Indicates to automation that a pull request should not appear in the release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.7.0 v7.0.0 v7.2.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants