Skip to content

[AIRFLOW-XXX] KubernetesPodOperator: fix _extract_xcom for larger json files#6797

Closed
ddelange wants to merge 17 commits intoapache:v1-10-testfrom
ddelange:fix-k8s-xcom
Closed

[AIRFLOW-XXX] KubernetesPodOperator: fix _extract_xcom for larger json files#6797
ddelange wants to merge 17 commits intoapache:v1-10-testfrom
ddelange:fix-k8s-xcom

Conversation

@ddelange
Copy link
Contributor

@ddelange ddelange commented Dec 12, 2019

When calling update() and peek_stdout() immediately after write_stdin(),
the cat command was sometimes not done yet with writing to stdin. Hence,
an incomplete (and broken) json file was returned.

[2019-12-11 16:16:50,586] {logging_mixin.py:112} INFO - [2019-12-11 16:16:50,586] {pod_launcher.py:217} INFO - Running command... cat /airflow/xcom/return.json
[2019-12-11 16:16:50,630] {logging_mixin.py:112} INFO - [2019-12-11 16:16:50,630] {pod_launcher.py:217} INFO - Running command... kill -s SIGINT 1
[2019-12-11 16:16:57,143] {logging_mixin.py:112} INFO - [2019-12-11 16:16:57,143] {local_task_job.py:124} INFO - Time since last heartbeat(0.01 s) < heartrate(10.0 s), sleeping for 9.99135 s
[2019-12-11 16:17:02,048] {logging_mixin.py:112} INFO - [2019-12-11 16:17:02,047] {pod_launcher.py:132} INFO - <broken json string here>
[2019-12-11 16:17:02,076] {taskinstance.py:1058} ERROR - Unterminated string starting at: line 1 column 31378 (char 31377)
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/airflow/models/taskinstance.py", line 930, in _run_raw_task
    result = task_copy.execute(context=context)
  File "/usr/local/lib/python3.7/site-packages/airflow/contrib/operators/kubernetes_pod_operator.py", line 161, in execute
    get_logs=self.get_logs)
  File "/usr/local/lib/python3.7/site-packages/airflow/contrib/kubernetes/pod_launcher.py", line 117, in run_pod
    return self._monitor_pod(pod, get_logs)
  File "/usr/local/lib/python3.7/site-packages/airflow/contrib/kubernetes/pod_launcher.py", line 133, in _monitor_pod
    result = json.loads(result)
  File "/usr/local/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 31378 (char 31377)
[2019-12-11 16:17:02,080] {taskinstance.py:1089} INFO - Marking task as FAILED.

potiuk and others added 16 commits December 12, 2019 10:24
…nfo (apache#6731)

This case prevents a DAG from being scheduled so should be an error.

(cherry picked from commit fb929eb)
…che#6612)

* [AIRFLOW-6018] Display task instance in table during backfilling

(cherry picked from commit da088b3)
With this change you should be able to simply run `pytest` to run all the tests in the main airflow directory.

This consist of two changes:

* moving pytest.ini to the main airflow directory
* skipping collecting kubernetes tests when ENV != kubernetes

(cherry picked from commit 239d51e)
@codecov-io
Copy link

codecov-io commented Dec 12, 2019

Codecov Report

❗ No coverage uploaded for pull request base (v1-10-test@8ad2f60). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@              Coverage Diff              @@
##             v1-10-test    #6797   +/-   ##
=============================================
  Coverage              ?   81.15%           
=============================================
  Files                 ?      519           
  Lines                 ?    35348           
  Branches              ?        0           
=============================================
  Hits                  ?    28687           
  Misses                ?     6661           
  Partials              ?        0
Impacted Files Coverage Δ
airflow/contrib/kubernetes/pod_launcher.py 92.53% <100%> (ø)
airflow/utils/dag_processing.py 92.19% <100%> (ø)
airflow/jobs/backfill_job.py 92.6% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ad2f60...792ac95. Read the comment docs.

…n files

When calling update() and peek_stdout() immediately after write_stdin(),
the cat command was sometimes not done yet with writing to stdin. Hence,
an incomplete (and broken) json file was returned.
@ddelange ddelange closed this Dec 12, 2019
@ddelange ddelange deleted the fix-k8s-xcom branch December 12, 2019 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants