amaterasu-coder opened a new issue #18267:
URL: https://github.com/apache/airflow/issues/18267
### Apache Airflow version
2.1.3 (latest released)
### Operating System
Debian 10
### Versions of Apache Airflow Providers
_No response_
### Deployment
Composer
### Deployment details
_No response_
### What happened
The operator
airflow.providers.amazon.aws.transfers.gcs_to_s3.GCSToS3Operator is buggy
because if the argument replace=False and the task is retried then the task
will always fail :
```
Traceback (most recent call last):
File "/usr/local/lib/airflow/airflow/models/taskinstance.py", line 985, in
_run_raw_task
result = task_copy.execute(context=context)
File "/home/airflow/gcs/plugins/birdz/operators/gcs_to_s3_operator.py",
line 159, in execute
cast(bytes, file_bytes), key=dest_key, replace=self.replace,
acl_policy=self.s3_acl_policy
File "/usr/local/lib/airflow/airflow/providers/amazon/aws/hooks/s3.py",
line 61, in wrapper
return func(*bound_args.args, **bound_args.kwargs)
File "/usr/local/lib/airflow/airflow/providers/amazon/aws/hooks/s3.py",
line 90, in wrapper
return func(*bound_args.args, **bound_args.kwargs)
File "/usr/local/lib/airflow/airflow/providers/amazon/aws/hooks/s3.py",
line 608, in load_bytes
self._upload_file_obj(file_obj, key, bucket_name, replace, encrypt,
acl_policy)
File "/usr/local/lib/airflow/airflow/providers/amazon/aws/hooks/s3.py",
line 653, in _upload_file_obj
raise ValueError(f"The key {key} already exists.")
```
Furthermore I noted that the argument "prefix" that correspond to the GCS
prefix to search in the bucket is keeped in the destination S3
### What you expected to happen
I expect the operator to print "In sync, no files needed to be uploaded to
S3" if a retry is done in case of replace=false
And I expect to keep or not the GCS prefix to the destination S3 key. It's
already handled by other transfer operator like
'airflow.providers.google.cloud.transfers.gcs_to_sftp.GCSToSFTPOperator' which
implement a keep_directory_structure argument to keep the folder structure
between source and destination
### How to reproduce
Retry the operator with replace=False
### Anything else
_No response_
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]