airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vitor Baptista (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AIRFLOW-990) DockerOperator fails when logging unicode string
Date Wed, 15 Mar 2017 22:17:42 GMT

     [ https://issues.apache.org/jira/browse/AIRFLOW-990?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vitor Baptista updated AIRFLOW-990:
-----------------------------------
    Description: 
On line https://github.com/apache/incubator-airflow/blob/1.7.1.3/airflow/operators/docker_operator.py#L164,
we're calling:

{code:title=airflow/operators/docker_operator.py}
for line in self.cli.logs(container=self.container['Id'], stream=True):
    logging.info("{}".format(line.strip()))
{code}

If `self.cli.logs()` return a string with a unicode character, this raises the UnicodeDecodeError:
{noformat}
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 476, in format
    raise e
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in range(128)
Logged from file docker_operator.py, line 165
{noformat}

A possible fix is to change that line to:
{code:title=airflow/operators/docker_operator.py}
for line in self.cli.logs(container=self.container['Id'], stream=True):
    logging.info(line.decode('utf-8').strip())
{code}.

This error doesn't happen on Python3. I haven't tested, but reading the code it seems the
same error exists on `master` as well.

  was:
On line https://github.com/apache/incubator-airflow/blob/1.7.1.3/airflow/operators/docker_operator.py#L164,
we're calling:

{code:title=airflow/operators/docker_operator.py}
for line in self.cli.logs(container=self.container['Id'], stream=True):
    logging.info("{}".format(line.strip()))
{code}

If `self.cli.logs()` return a string with a unicode character, this raises the UnicodeDecodeError:
{noformat}
Traceback (most recent call last):
  File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
    msg = self.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
    return fmt.format(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 476, in format
    raise e
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in range(128)
Logged from file docker_operator.py, line 165
{noformat}

A possible fix is to change that line to:
{code:python}
for line in self.cli.logs(container=self.container['Id'], stream=True):
    logging.info(line.decode('utf-8').strip())
{code}.

This error doesn't happen on Python3. I haven't tested, but reading the code it seems the
same error exists on `master` as well.


> DockerOperator fails when logging unicode string
> ------------------------------------------------
>
>                 Key: AIRFLOW-990
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-990
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: docker
>    Affects Versions: Airflow 1.7.1
>         Environment: Python 2.7
>            Reporter: Vitor Baptista
>
> On line https://github.com/apache/incubator-airflow/blob/1.7.1.3/airflow/operators/docker_operator.py#L164,
we're calling:
> {code:title=airflow/operators/docker_operator.py}
> for line in self.cli.logs(container=self.container['Id'], stream=True):
>     logging.info("{}".format(line.strip()))
> {code}
> If `self.cli.logs()` return a string with a unicode character, this raises the UnicodeDecodeError:
> {noformat}
> Traceback (most recent call last):
>   File "/usr/lib/python2.7/logging/__init__.py", line 861, in emit
>     msg = self.format(record)
>   File "/usr/lib/python2.7/logging/__init__.py", line 734, in format
>     return fmt.format(record)
>   File "/usr/lib/python2.7/logging/__init__.py", line 476, in format
>     raise e
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xf0 in position 0: ordinal not in
range(128)
> Logged from file docker_operator.py, line 165
> {noformat}
> A possible fix is to change that line to:
> {code:title=airflow/operators/docker_operator.py}
> for line in self.cli.logs(container=self.container['Id'], stream=True):
>     logging.info(line.decode('utf-8').strip())
> {code}.
> This error doesn't happen on Python3. I haven't tested, but reading the code it seems
the same error exists on `master` as well.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message