Closed bd233 closed 3 years ago
Thanks for the info.
Can you try to update outlet_id in the print-line above to:
outlet_id.encode(sys.getdefaultencoding())
If not I can add the parameter as suggested and give an error message that suggests changing it when the agent gets the UnicodeEncodeError exception.
Can you try to update outlet_id in the print-line above to:
outlet_id.encode(sys.getdefaultencoding())
I think it should not be updated for outlet_id, it should be alias,alias.encode(sys.getdefaultencoding())
, in these two places
https://github.com/ClusterLabs/fence-agents/blob/ef39c292fda212e2b532b7b93acd8fcdb49dc4b4/lib/fencing.py.py#L961
https://github.com/ClusterLabs/fence-agents/blob/ef39c292fda212e2b532b7b93acd8fcdb49dc4b4/lib/fencing.py.py#L963
I did not test and verify this
If not I can add the parameter as suggested and give an error message that suggests changing it when the agent gets the UnicodeEncodeError exception.
I am unlikely to suggest that Alibaba Cloud users modify fencing.py manually, so giving an error message may be a better way
Yeah. I was suggesting if you test and verify that alias.encode(sys.getdefaultencoding())
we can patch it in the project.
Yeah. I was suggesting if you test and verify that
alias.encode(sys.getdefaultencoding())
we can patch it in the project.
I tried to fix the problem in python2 in the following way:
try: print(outlet_id + options["--separator"] + alias) except UnicodeEncodeError as e: print((outlet_id + options["--separator"] + alias).encode("utf-8"))
This is feasible
Great. I'll make a patch to do that.
I've made a patch based on your suggestion: https://github.com/ClusterLabs/fence-agents/pull/454
Can you test it and also verify that -o list-status works fine as well?
I've made a patch based on your suggestion: #454
Can you test it and also verify that -o list-status works fine as well?
Yes, no problem, I will test and give feedback tomorrow
I've made a patch based on your suggestion: #454
Can you test it and also verify that -o list-status works fine as well?
I tested it under Python3 and 2, and it seems to work very well. python2 python3
@oalbrigt I have another question: In which version will this fix be released, and how do I update to this version.
Great. Thanks for testing.
It'll be in v4.11.0, which will be available in about a weeks time.
You should file a bug against common distros used (since this is Python 2.x issue distro versions needing it probably wont get the updated version, but they can backport the patch easily).
v4.11.0 has now been released: https://github.com/ClusterLabs/fence-agents/releases/tag/v4.11.0
When the user uses the Python2 environment to run the commands
fence_aliyun --region cn-hangzhou -a <ak> -s <sk> --action list-status
, they will get such an error:First of all, this is because the "InstanceName" of the user's instance contains Chinese characters, resulting in
print(outlet_id + options["--separator"] + alias + options["--separator"] + status)
errorSo we are considering whether to replace InstanceName with HostName to support this scenario: https://github.com/ClusterLabs/fence-agents/blob/ef39c292fda212e2b532b7b93acd8fcdb49dc4b4/agents/aliyun/fence_aliyun.py#L70
If this is not a good solution, then we can only recommend that users use Python3 or modify InstanceName.