-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing issue with UTF-8 conversion in Python3 for GCS uploads #268
Fixing issue with UTF-8 conversion in Python3 for GCS uploads #268
Conversation
Additionally, according to this Google Cloud doc, by using curl's
It'd seem that this change introduces consistent behavior. |
I think I spent two hours until finding this. Good old Ansible. |
I've since given up here, doesn't seem to me that Google Cloud is investing much in their Ansible module collection. If anyone else runs across this issue, I recommend interacting with Google's Cloud APIs as much as possible simply using Ansible's Simple play set example for GCE instance uploading to GCS bucket:
|
Hello! When will this be merged? |
Maybe there is some alternative to google.cloud collection? |
@levonet there is... but it's a shame they do not fix this and abandon it. |
@dperezro |
Google's Cloud APIs, using gcloud commands (although it's interactive so you need to run gcloud login first) or make this correction locally (the PR change) :-\ |
Still facing the same issue. Hope someone fixes this asap D: |
hail marry attempt for merge - @rambleraptor |
I finally realized it was a conspiracy between google and ansible. The purpose of the conspiracy is to migrate everyone to k8s, helm, and terraform. It happened to me :/ |
@rambleraptor mentioning you since you seem to be main contributor. Any chance this can be merged? Pretty please? |
I find GCP's lack of interest in merging simple, badly needed fixes...disturbing. @rmoriar1 |
Thanks for merging that, I noticed that the last release for this collection was on February 2020. I spent all day doing a manual fix to get this specific commit as a requirement in AWX, turns out that AWX with Ansible 2.9 can't use |
Should help someone
|
SUMMARY
Fixing issue with UTF-8 conversion in Python3 for GCS uploads (#266)
ISSUE TYPE
COMPONENT NAME
gcp_storage_object
ADDITIONAL INFORMATION
This bug can be resolved by simply changing gcp_storage_object.py#L254 from ...
with open(src, "r") as file_obj:
towith open(src, "rb") as file_obj:
Hence, this PR. This small change ensures there's no decoding attempt (or subsequent error) by forcing the file to be read as binary via the
open
func.This approach appears similar to
download_file
's use of the open func at gcp_storage_object.py#L243, where it specifically is configured with the b (binary) mode specifier. Not only does this resolve the issue with uploading binary files, but the change doesn't appear to harm text uploads. Unsure though if this is a safe strategy overall and should be probably be reviewed carefully by Google Ansible module maintainers.