[AIRFLOW-620] Add log refresh button to TI's log view page#1875
[AIRFLOW-620] Add log refresh button to TI's log view page#1875msumit wants to merge 1 commit intoapache:masterfrom
Conversation
Current coverage is 66.20% (diff: 100%)@@ master #1875 diff @@
==========================================
Files 128 129 +1
Lines 9840 9952 +112
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 6513 6589 +76
- Misses 3327 3363 +36
Partials 0 0
|
|
I like the idea but for long logs the user needs to scroll all the way up to refresh, and all the way down to see new data. I would prefer to put the refresh button underneath the log data. |
There was a problem hiding this comment.
Move the refresh button here so users can refresh when viewing the log tail
|
👍 |
There was a problem hiding this comment.
Could you please also add window.scrollTo(0,document.body.scrollHeight); below this line? The refresh sometimes pushes the scrolling back to the top of the page.
There was a problem hiding this comment.
I suspect that @dgies's comment is the implementation of what I am about to ask for, but essentially, I'd like a scrolling tailed log that is refreshed by this button and also automatically at a fixed cadence (e.g. every 2-3 seconds with some sort of back off if there is no new data).
There was a problem hiding this comment.
I considered that but you'd want to make sure to only refresh when the task is running, which requires polling the task state as well, and probably some special handling around retries. Auto refresh could be a performance problem if the log becomes very long.
There was a problem hiding this comment.
yeah, I started keeping that in mind only, but thought of keeping it manual for now. If we do auto refresh then we've to provide a option (checkbox) to disable that as well.
|
+1 |
|
I thought I commented on this, but looks like I didn't. I'd really like a "tail N lines" feature in the log view -- essentially, automatically refreshing the log every S seconds and showing the last N lines (both configurable) to the view port. I +1 @dgies comment about moving the refresh button to the bottom of the screen. Manually refreshing is okay, but automatically refreshing feels like the right solution. |
|
@r39132 in that case we should do something like this: If a TI is running, server will send the log text along with the pointer (no of bytes) upto which log has been read. In next call, UI will pass that pointer in ajax call and server will send only the new logs after that pointer along with the new pointer. On UI rather than replacing the dom content, it'll just append to it. This process will continue until the TI finishes. On full page refresh UI will send no pointer and server will respond to full logs. |
|
I propose we do not let the perfect become the enemy of the good and merge this as-is (after squashing). Automatic refreshes are trickier to get right and can be added in a new PR without invalidating what's been done already. |
|
Yeah, that was my idea as well.. instead of doing all magic in once, do it incrementally.. |
airflow/www/views.py
Outdated
There was a problem hiding this comment.
I don't like relying on is_xhr to do this... it basically uses a non-standard header X-Requested-With (http://flask.pocoo.org/docs/0.11/api/#flask.Request.is_xhr) and will for eg break mysteriously if we move away from $.get
I think alternatives (from best to worst IMO) are
- Using a separate (maybe behind our API) endpoint
- Use a new query param
- Set
Accept: text/plainheader
There was a problem hiding this comment.
im not completely agree to the concern that it'll break if we move away from $.get.. as in case if we do that, we'll take care of backend as well.. its not like someone just gonna change to UI code without altering the backend code as well..
the new api and extra params are overkill for something very simple like that..
There was a problem hiding this comment.
but what's the advantage of using nonstandard features like is_xhr?
There was a problem hiding this comment.
@zodiac is_xhr may not be the best way, but good enough for this small feature. We of course need it to evolve in to auto-refresh/auto-tailing thing, at that time we can invest on full fledged new api.
There was a problem hiding this comment.
ok. this code is still a bit weird so I suggest adding comments pointing out
log.html(the page this view renders) sometimes does an XHR request to itself, and we handle it here- link to http://flask.pocoo.org/docs/0.11/api/#flask.Request.is_xhr since this is a nonstandard feature
LGTM otherwise
There was a problem hiding this comment.
move to previous line "click", function () { to reduce indentation
There was a problem hiding this comment.
indentation of ( and ) don't match. should use same format as .fail callback for consistency
|
@msumit shall we rebase, squash and merge this? |
|
@zodiac sure, will rebase it this weekend.. |
This will add log refresh button to TI's log view page, thus eliminating the need of whole page reload to get the latest logs of that TI.
|
@zodiac can u do a final review and merge it? |
|
@msumit What do you want to do with this PR? Close and re-open a fresh one or rebase and ask for a review. If I don't hear back in a few days, I'll close this. |
|
closing for now.. reopen to update and rebase. |

Dear Airflow Maintainers,
Please accept this PR that addresses the following issues:
Testing Done:
This will add log refresh button to TI's log view page, thus eliminating the need of whole page reload to get the latest logs of that TI.