Bug 1850117

Summary: Python error - a bytes-like object is required, not 'str' - seen when trying to set hosted-engine shared config for storage
Product: [oVirt] ovirt-hosted-engine-ha Reporter: SATHEESARAN <sasundar>
Component: GeneralAssignee: Evgeny Slutsky <eslutsky>
Status: CLOSED CURRENTRELEASE QA Contact: SATHEESARAN <sasundar>
Severity: high Docs Contact:
Priority: urgent    
Version: 2.4.3CC: arachman, bugs, eslutsky, godas, michal.skrivanek, pelauter, rdlugyhe, sandro.bonazzola
Target Milestone: ovirt-4.4.1Keywords: Regression
Target Release: ---Flags: sasundar: ovirt-4.4?
sasundar: blocker?
pelauter: planning_ack+
sbonazzo: devel_ack+
sasundar: testing_ack+
Hardware: x86_64   
OS: Linux   
Whiteboard:
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.
Story Points: ---
Clone Of:
: 1850118 (view as bug list) Environment:
Last Closed: 2020-08-05 06:24:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Integration RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1850118    

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