Skip to content

Commit

Permalink
fix wasb remote logging when blob already exists (#16280)
Browse files Browse the repository at this point in the history
Co-authored-by: Felipe Lolas <felipe.lolas@bci.cl>
  • Loading branch information
flolas and bci-flolas committed Jun 7, 2021
1 parent 5c7d758 commit 29b7f79
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 1 addition & 5 deletions airflow/providers/microsoft/azure/log/wasb_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ def wasb_write(self, log: str, remote_log_location: str, append: bool = True) ->
log = '\n'.join([old_log, log]) if old_log else log

try:
self.hook.load_string(
log,
self.wasb_container,
remote_log_location,
)
self.hook.load_string(log, self.wasb_container, remote_log_location, overwrite=True)
except AzureHttpError:
self.log.exception('Could not write logs to %s', remote_log_location)
6 changes: 3 additions & 3 deletions tests/providers/microsoft/azure/log/test_wasb_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_write_log(self, mock_log_exists, mock_wasb_read, mock_hook):
mock_wasb_read.return_value = ""
self.wasb_task_handler.wasb_write('text', self.remote_log_location)
mock_hook.return_value.load_string.assert_called_once_with(
"text", self.container_name, self.remote_log_location
"text", self.container_name, self.remote_log_location, overwrite=True
)

@mock.patch("airflow.providers.microsoft.azure.hooks.wasb.WasbHook")
Expand All @@ -145,14 +145,14 @@ def test_write_on_existing_log(self, mock_log_exists, mock_wasb_read, mock_hook)
mock_wasb_read.return_value = "old log"
self.wasb_task_handler.wasb_write('text', self.remote_log_location)
mock_hook.return_value.load_string.assert_called_once_with(
"old log\ntext", self.container_name, self.remote_log_location
"old log\ntext", self.container_name, self.remote_log_location, overwrite=True
)

@mock.patch("airflow.providers.microsoft.azure.hooks.wasb.WasbHook")
def test_write_when_append_is_false(self, mock_hook):
self.wasb_task_handler.wasb_write('text', self.remote_log_location, False)
mock_hook.return_value.load_string.assert_called_once_with(
"text", self.container_name, self.remote_log_location
"text", self.container_name, self.remote_log_location, overwrite=True
)

def test_write_raises(self):
Expand Down

0 comments on commit 29b7f79

Please sign in to comment.