[AIRFLOW-1878] Fix stderr/stdout redirection for tasks#2836
[AIRFLOW-1878] Fix stderr/stdout redirection for tasks#2836bolkedebruin wants to merge 1 commit intoapache:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2836 +/- ##
==========================================
- Coverage 74.05% 73.97% -0.08%
==========================================
Files 160 160
Lines 12139 12153 +14
==========================================
+ Hits 8989 8990 +1
- Misses 3150 3163 +13
Continue to review full report at Codecov.
|
airflow/utils/log/logging_mixin.py
Outdated
There was a problem hiding this comment.
Rather than setting self.stream each time maybe do something like this:
@property
def stream(self):
if self._use_stderr:
return sys.stderr
return sys.stdout(Inspiration from https://github.com/python/cpython/blob/3.6/Lib/logging/__init__.py#L1077-L1095)
There was a problem hiding this comment.
Oh I like that :)
ashb
left a comment
There was a problem hiding this comment.
Possible improvement, looks good otherwise.
e631bbd to
e089c3a
Compare
|
@ashb couldn't make it work. Seems to be Python 3.5/3.6 only. ^^ fixed that |
logging.StreamHandler keeps a reference to the initial stream it has been assigned. This prevents redirection after initalization to a logging facility.
8f64866 to
9fc893d
Compare
|
@bolkedebruin Just ran the local master today, and looks like there is a handler bug introduced by this PR that is preventing scheduler from running the tasks. Specifically, I think: should be |
|
I haven't tested this myself, but
(Taken from https://docs.python.org/2/library/sys.html#sys.__stdin__) |
|
@jgao54 What was the error reported by the scheduler? Or no error, but making the change you suggested make it start actually scheduling tasks? |
|
I tested this locally as well and don’t have any issues? |
|
And no stderr are not the right thing. Are you sure you tested the latest version of the patch? |
|
A previous version missed setting the redirect to ti.log which creates an endless loop and prevents tasks from running. |
|
@ashb @bolkedebruin yeah I'm testing with a fresh copy of the latest master. I'm not exactly sure why it's causing issues, as both |
|
@bolkedebruin, I took another look at the code and looks like this PR itself is fine. But this PR triggered logging redirection (https://github.com/apache/incubator-airflow/blob/master/airflow/jobs.py#L350-L351), which gets into an infinite loop somewhere and logging |
|
I’ll have a look today to see if I can reproduce. |
|
I noticed the same issues as @jgao54 starting with this commit on master. |
|
Ok I have reproduced it. It seems to have creeped in between branching for the PR itself and changes that have been made to master. Will investigate and create a patch. ^^ This PR is probably indeed unrelated as mentioned by @jgao54 |
|
fixed by #2871 |
logging.StreamHandler keeps a reference to the initial stream it has been assigned. This prevents redirection after initalization to a logging facility. Closes apache#2836 from bolkedebruin/AIRFLOW-1878
logging.StreamHandler keeps a reference to the initial stream it has been assigned. This prevents redirection after initalization to a logging facility. Closes apache#2836 from bolkedebruin/AIRFLOW-1878
Make sure you have checked all steps below.
JIRA
Description
logging.StreamHandler keeps a reference to the initial stream
it has been assigned. This prevent redirection after initalization
to a logging facility.
Tests
Will add
Commits
My commits all reference JIRA issues in their subject lines, and I have squashed multiple commits if they address the same issue. In addition, my commits follow the guidelines from "How to write a good git commit message":
Passes
git diff upstream/master -u -- "*.py" | flake8 --diffcc: @Fokko @ashb @jgao54