Bug 1850117 - Python error - a bytes-like object is required, not 'str' - seen when trying to set hosted-engine shared config for storage
Summary: Python error - a bytes-like object is required, not 'str' - seen when trying...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: ovirt-hosted-engine-ha
Classification: oVirt
Component: General
Version: 2.4.3
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: ovirt-4.4.1
: ---
Assignee: Evgeny Slutsky
QA Contact: SATHEESARAN
URL:
Whiteboard:
Depends On:
Blocks: 1850118
TreeView+ depends on / blocked
 
Reported: 2020-06-23 15:02 UTC by SATHEESARAN
Modified: 2020-08-17 07:31 UTC (History)
8 users (show)

Fixed In Version: ovirt-hosted-engine-ha-2.4.4
Doc Type: Bug Fix
Doc Text:
Previously, the`hosted-engine --set-shared-config storage` command failed to update the hosted engine storage. With this update, the command works.
Clone Of:
: 1850118 (view as bug list)
Environment:
Last Closed: 2020-08-05 06:24:53 UTC
oVirt Team: Integration
Embargoed:
sasundar: ovirt-4.4?
sasundar: blocker?
pelauter: planning_ack+
sbonazzo: devel_ack+
sasundar: testing_ack+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
oVirt gerrit 109852 0 master MERGED Change StringIO to BytesIO in _add_to_tar function 2021-01-26 14:59:37 UTC
oVirt gerrit 109875 0 master MERGED Change StringIO to BytesIO - add missing BytesIO import 2021-01-26 14:59:38 UTC

Description SATHEESARAN 2020-06-23 15:02:17 UTC
Description of problem:
-----------------------
When trying to set hosted-engine shared config for storage, python error is seen - "a bytes-like object is required, not 'str'"

Version-Release number of selected component (if applicable):
-------------------------------------------------------------
ovirt-hosted-engine-setup-2.4.5-1.el8ev.noarch
ovirt-hosted-engine-ha-2.4.3-1.el8ev.noarch

How reproducible:
------------------
Always

Steps to Reproduce:
-------------------
1. Set the shared storage config - # hosted-engine --set-shared-config storage newhost.example.com

Actual results:
---------------
Error seen

Expected results:
------------------
Successfully modify shared config storage

Comment 2 Evgeny Slutsky 2020-06-24 08:15:02 UTC
this is the root cause exception:
>>> from ovirt_hosted_engine_ha.client import client
>>> ha_cli = client.HAClient()
>>> ha_cli.set_shared_config("storage","192.168.100.1:/opt/shared2","he_shared")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/client/client.py", line 259, in set_shared_config
    self._config.set_config_on_shared_storage(key, value, config_type)
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/env/config.py", line 154, in set_config_on_shared_storage
    final_type.set_and_write(key, value)
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/env/config_shared.py", line 80, in set_and_write
    self._update_content_on_shared_conf(content)
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/env/config_shared.py", line 92, in _update_content_on_shared_conf
    volumepath
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/lib/heconflib.py", line 183, in add_file_to_conf_archive
    content_by_name[envconst.HEConfFiles.HECONFD_VM_CONF]
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/lib/heconflib.py", line 304, in _create_temp_archive
    agentconst.PACKAGE_VERSION,
  File "/usr/lib/python3.6/site-packages/ovirt_hosted_engine_ha/lib/heconflib.py", line 57, in _add_to_tar
    tar.addfile(tarinfo=info, fileobj=value)
  File "/usr/lib64/python3.6/tarfile.py", line 1980, in addfile
    copyfileobj(fileobj, self.fileobj, tarinfo.size, bufsize=bufsize)
  File "/usr/lib64/python3.6/tarfile.py", line 258, in copyfileobj
    dst.write(buf)
TypeError: a bytes-like object is required, not 'str'

Comment 3 SATHEESARAN 2020-06-25 01:49:08 UTC
Hi Evgeny,

When testing with the patch merged, I see problem related to 'BytesIO' not impoted.
[root@ ]# hosted-engine --set-shared-config storage rhsqa-grafton12.lab.eng.blr.redhat.com:/engine --type=he_shared
name 'BytesIO' is not defined


In the heconflib.py, just replaced - "from io import StringIO" with "from io import BytesIO",
then it worked. Can you include that fix as part of this patch ?

Comment 4 Sandro Bonazzola 2020-06-25 07:08:33 UTC
Moving back to assigned as per comment #3

Comment 5 Evgeny Slutsky 2020-06-25 07:32:05 UTC
done, sorry about that, I've verified it only with monkey patching :)

Comment 6 SATHEESARAN 2020-07-09 09:30:21 UTC
Tested with ovirt-hosted-engine-ha-2.4.4-1.el8ev.noarch

When setting the shared config, no errors are seen

[root@ ]# hosted-engine --set-shared-config storage rhsqa-grafton12.lab.eng.blr.redhat.com:/engine --type=he_shared
[root@ ]# echo $?
[root@ ]# 0

Comment 7 Sandro Bonazzola 2020-08-05 06:24:53 UTC
This bugzilla is included in oVirt 4.4.1 release, published on July 8th 2020.

Since the problem described in this bug report should be resolved in oVirt 4.4.1 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.

Comment 9 Evgeny Slutsky 2020-08-17 07:31:39 UTC
looks good


Note You need to log in before you can comment on or make changes to this bug.