Skip to content

Commit

Permalink
fix oss key prefix bug in oss_task_handler (#39627)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGao888 authored May 15, 2024
1 parent d529ec8 commit ba13d0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion airflow/providers/alibaba/cloud/log/oss_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def oss_write(self, log, remote_log_location, append=True) -> bool:
"""
oss_remote_log_location = f"{self.base_folder}/{remote_log_location}"
pos = 0
if append and self.oss_log_exists(oss_remote_log_location):
if append and self.oss_log_exists(remote_log_location):
head = self.hook.head_key(self.bucket_name, oss_remote_log_location)
pos = head.content_length
self.log.info("log write pos is: %s", pos)
Expand Down
4 changes: 2 additions & 2 deletions tests/providers/alibaba/cloud/log/test_oss_task_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_oss_write_into_remote_existing_file_via_append(self, mock_service, mock
# Then
assert mock_service.call_count == 2
mock_service.return_value.head_key.assert_called_once_with(MOCK_BUCKET_NAME, "airflow/logs/1.log")
mock_oss_log_exists.assert_called_once_with("airflow/logs/1.log")
mock_oss_log_exists.assert_called_once_with("1.log")
mock_service.return_value.append_string.assert_called_once_with(
MOCK_BUCKET_NAME, MOCK_CONTENT, "airflow/logs/1.log", 1
)
Expand All @@ -115,7 +115,7 @@ def test_oss_write_into_remote_non_existing_file_via_append(self, mock_service,
# Then
assert mock_service.call_count == 1
mock_service.return_value.head_key.assert_not_called()
mock_oss_log_exists.assert_called_once_with("airflow/logs/1.log")
mock_oss_log_exists.assert_called_once_with("1.log")
mock_service.return_value.append_string.assert_called_once_with(
MOCK_BUCKET_NAME, MOCK_CONTENT, "airflow/logs/1.log", 0
)
Expand Down

0 comments on commit ba13d0c

Please sign in to comment.