Fix issue-32019: [Python 3] znode fails to create node (It uses string value instead of bytes value) #36999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
DESCRIPTION
The module znode doens't work for python 3 when trying to publish some value to zookeeper, It is because of KazooClient.create and KazooClient.set require a byte string in python 3 like
b'value'
instead of'value'
. This PR changesansible/modules/clustering/znode.py
to consume the proper message either for python2 or 3 by usingfrom ansible.module_utils._text import to_bytes
.This PR is based on #32030, but also fixed set functional call, which was missing from the original PR.
ISSUE TYPE
COMPONENT NAME
znode
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
"N/A"
SUMMARY
In python 3, kazoo client requires bytes and not string, in order to solve the issue:
1.- include in znode.py:
2.- Replace znode.py line 235:
3.- Replace znode.py line 241:
This solve the issue and is backward compatible (I already tested and will create the proper PR if I have time, I'm actually working on other future PRs).
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS