Skip to content

Commit

Permalink
Fix handling of subprocess error handling in s3_file_transform and gcs (
Browse files Browse the repository at this point in the history
#9106)

As outlined in Issue 9104 the python subprocess return code can be less than 0.
The previous version only captures errors of the subprocess itself, not the negative error codes, as cause by host SIGKILL, SIGHUP, ... see https://docs.python.org/3/library/subprocess.html#subprocess.
CompletedProcess.returncode

We now treat all non-zero returncodes as a script failure.
  • Loading branch information
blackw1ng committed Jun 2, 2020
1 parent 9e0ccde commit 17adcea
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -154,7 +154,7 @@ def execute(self, context):

process.wait()

if process.returncode > 0:
if process.returncode:
raise AirflowException(
"Transform script failed: {0}".format(process.returncode)
)
Expand Down
2 changes: 1 addition & 1 deletion airflow/providers/google/cloud/operators/gcs.py
Expand Up @@ -609,7 +609,7 @@ def execute(self, context: Dict):
self.log.info(line.decode(self.output_encoding).rstrip())

process.wait()
if process.returncode > 0:
if process.returncode:
raise AirflowException(
"Transform script failed: {0}".format(process.returncode)
)
Expand Down

0 comments on commit 17adcea

Please sign in to comment.