[AIRFLOW-1325][WIP]Airflow streaming log backed by ElasticSearch#2469
[AIRFLOW-1325][WIP]Airflow streaming log backed by ElasticSearch#2469allisonwang wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Nit: grammar
"Logging backend URL"
is fine
Would be good to explain a bit more too, e.g. that this is used by the webserver to fetch logs.
|
Need to modify CI to exclude license checking for two static resource files. |
aoen
left a comment
There was a problem hiding this comment.
Make webworkers highlight only newly loaded logs instead of entire HTML tag.
This seems concerning if we have to reprocess the whole tag every time, wouldn't this be very slow for large logs (e.g. 1 gig)? I think it would be good to be able to toggle color via config flag regardless though.
There was a problem hiding this comment.
(read this after reading the comments below) Can we encapsulate this file with a class? It should also have a descriptive top-level comment, since there is that confusion we discussed of what is used to write to logs vs reading them.
There was a problem hiding this comment.
Would be good to make this comment a bit more descriptive, it's not immediately clear what it's used for (e.g. that this is what users specify in the configuration file).
There was a problem hiding this comment.
Ultimately those will be removed and instantiation will be moved into logging configuration as a handler.
There was a problem hiding this comment.
Does this have to be global? Can we cache at the webserver instance level instead?
There was a problem hiding this comment.
won't LOGGING_BACKEND be undefined if it was not previously cached and the logging backend URL is not defined in the configuration? Would be good to make it explicitly return None if this is what is intended in this case. Would also be good to tests for this.
There was a problem hiding this comment.
It seems like this method can be combined with get_logging_backend (i.e. get_logging_backend is called directly instead of cached_logging_backend, and then fetches the cached version if it is available).
There was a problem hiding this comment.
_get_logging_backend is a helper function forcached_logging_backend. It follows the pattern of cached_app in Airflow : https://github.com/apache/incubator-airflow/blob/master/airflow/www/app.py#L158
There was a problem hiding this comment.
s/schema/logging_backend or logging_backend_class
There was a problem hiding this comment.
AirflowException instead of TypeError
There was a problem hiding this comment.
Let's make this configurable.
There was a problem hiding this comment.
will make everything configurable in v2!
There was a problem hiding this comment.
Should be max lines right?
There was a problem hiding this comment.
Can we elaborate on the TODO? Also why critical level? Shouldn't it be debug level (which would actually hide it more aggressively than critical)
There was a problem hiding this comment.
ES's logs will be added to task instance logs and display in Airflow UI.
There was a problem hiding this comment.
Did we check license compatibility with apache for all of the third party files? This one seems to be fine (MIT).
http://apache.org/legal/resolved.html#category-a
There was a problem hiding this comment.
I checked both open source files. Highlight.js is under BSD 3 which should be ok based on the Apache link above.
There was a problem hiding this comment.
Can we pass parameters explicitly here?
There was a problem hiding this comment.
Might be good to keep this consistent with the UI (1-indexed) to avoid confusion. When passing page later you can subtract 1 if necessary.
There was a problem hiding this comment.
Can we pass parameters explicitly?
There was a problem hiding this comment.
The delay seems like it should be configurable since it puts stress on the backend.
|
Folks, can you please explain the relationship with #2464 ? To me this seems to create technical debt upon technical debt. What I would expect is something like:
This PR builds on https://issues.apache.org/jira/browse/AIRFLOW-1332, which it shouldn't. It was deemed not the right approach and only there for transition. This builds upon the technical implementation of the transitional code without a clear path to #2464 . |
There was a problem hiding this comment.
What's the error handling around Elastic search failures (e.g. if the worker didn't actually log the logs the webserver expects in elastic search)?
|
@bolkedebruin Thinking about this specific PR a bit more I think you are right, this amount of tech debt is not acceptable and doesn't really fix any tech debt like the other PR was (adding retries to log path). Having the tech debt from only the Elastic Search logging backend is OK, but if others use the abstraction then it will create considerable amount of work later, and it's hard to justify why Elastic Search should be a special case. We have decided to fork internally and once we finish testing/releasing the fork we will try to iterate on the changes in open source (the logging abstraction first, and this PR second). The issue is Allison only has ~2.5 weeks left and I think it will be very tight if we try to merge the logging abstraction. Let's leave/close this PR for now and hopefully Allison or myself will revisit it and the logging abstraction PR shortly. |
Codecov Report
@@ Coverage Diff @@
## master #2469 +/- ##
==========================================
- Coverage 69.43% 69.14% -0.29%
==========================================
Files 146 150 +4
Lines 11351 11439 +88
==========================================
+ Hits 7881 7909 +28
- Misses 3470 3530 +60
Continue to review full report at Codecov.
|
|
@aoen Gotcha. That makes sense. I don't mind spending time on logging especially with the work @allisonwang has already done, but not before the summer holidays probably. I do think we are pretty close to merging, because although it might not be perfect yet, it will give us the right starting point. Then we can start pushing ppl towards using it. FWIW: I understand what you guys want to accomplish here, but imho you are tying too much of Elasticsearch into Airflow. That includes the try_number. If we would properly track start_dates in a |
|
If I understood your point about try number correctly (i.e. you don't like the idea of adding it to the task_instance table), then I really, really feel try number is critical to Airflow regardless (we were talking about it with Alex/Max internally + having a separate table that stores all task instance tries append-only). Here is the expert from my mailing list email in case you missed it. I don't like start_dates, there aren't really guarantees around them being completely unique (which try_number gives us for free), they are a poor approximation for a unique key. Feel free to reply to the open source thread and we can discuss along with Max/Alex/other committers though. |
|
Hi @aoen my main issue is that this information should not be stored in the So attempt/try_number yes, but not how it is done now. Storing it in the task_instance table doesn't make logically sense. If you want to store the count of attempt/tries it should be named |
|
Ah I see, I think I agree (need to see the complete new schema to be sure), but that's a little bit more involved. We should be able to easily migrate from the current version to this new one, we have still made forward progress (most of Allison's logic will stay). |
There was a problem hiding this comment.
Nit is that for a one line comment you can put the triple quotes on the same line
There was a problem hiding this comment.
may as well use dag_id=None, task_id=None... instead of kwargs
There was a problem hiding this comment.
I didn't do a deep read of this, but it doesn't stack overflow right?
There was a problem hiding this comment.
Ideally, front-end should stop fetch logs from the back-end when tasks complete. But there will be latencies between log get flushed into disk and logs get indexed in ES. We will need a smarter way to tell frontend when to stop fetching logs.
There was a problem hiding this comment.
I'm just curious about whether this page will eventually crash
There was a problem hiding this comment.
Maybe we should move to the APIs
There was a problem hiding this comment.
Make sense! Those endpoints should be moved to API in the future.
There was a problem hiding this comment.
Does this return an error message to the client?
There was a problem hiding this comment.
This probably isn't the right place to put this comment, but we have some type of escaping somewhere, right?
There was a problem hiding this comment.
You mean escaping characters in the returned message, which might cause decode and rendering issues?
There was a problem hiding this comment.
Yeah. Like a <Script>alert</script> shouldnt work
There was a problem hiding this comment.
I think we need some basic tests for these endpoints too
There was a problem hiding this comment.
Indeed, it would be really nice if we have some sort of unit test written for front-end and Flask side.
99dc77a to
4cba481
Compare
Dear Airflow maintainers,
Please accept this PR. I understand that it will not be reviewed until I have checked off all the steps below!
JIRA
Description
Please refer to Airflow-1325 for more details. Highlights of this change include:
This PR will solve the problem of loading big log files that freeze the browser. Instead of loading entire log files when the page renders, webserver will read and render logs by batch.
Note this PR develop on top of changes in #2464.
Tests
Commits