Bug 1924928
Summary: | ovirt sdk tracebacks while parsing URL | ||
---|---|---|---|
Product: | [oVirt] ovirt-engine-sdk-python | Reporter: | Brendan Shephard <bshephar> |
Component: | General | Assignee: | Ori Liel <oliel> |
Status: | CLOSED NOTABUG | QA Contact: | meital avital <mavital> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 4.4.9 | CC: | bugs, gveitmic, juan.hernandez, mperina |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2021-03-11 10:07:37 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | Infra | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Brendan Shephard
2021-02-03 22:17:32 UTC
Ok, so I made sure I was using the latest ovirtsdk 4.4.9. Still getting the same error, So, I added the decode the the top of the script when we first initialise the variable. That seems to have solved that problem, now the same problem with VM names: 2021-02-04 08:59:13.242 8 ERROR ironic.conductor.manager [req-4f1e7ff9-8f28-44a5-b36b-1f6e937f65d9 c12188ef21664945bf44b7f35423f765 81e8b5c8134447fc9adc3c1025cdfb32 - default default] Failed to get power state for node cc4ea979-2bcf-4591-8603-2455db9d8cbd. Error: VM with name b'compute-1' was not found: ironic_staging_drivers.common.exception.OVirtError: VM with name b'compute-1' was not found So I'll change that one as well. So far: bash-4.4$ diff -u /usr/lib64/python3.6/site-packages/ovirtsdk4/__init__.py-backup /usr/lib64/python3.6/site-packages/ovirtsdk4/__init__.py --- /usr/lib64/python3.6/site-packages/ovirtsdk4/__init__.py-backup 2021-02-04 09:03:27.134089438 +1000 +++ /usr/lib64/python3.6/site-packages/ovirtsdk4/__init__.py 2021-02-04 09:04:05.233743979 +1000 @@ -308,7 +308,7 @@ raise Error('The CA file \'%s\' doesn\'t exist' % ca_file) # Save the URL: - self._url = url + self._url = url.decode('UTF-8') # Save the logger: self._log = log Next issue seems to be on the Ironic side, so we can ignore it for this bug. Messy solution since we're encoding and decoding, but I can probably change ascii to utf-8 there instead. I'll look at that independently of this BZ though. Let's discuss the above change. For completion, I also made this change on the Ironic side - albeit a hack solution that needs revision: bash-4.4$ diff -u /usr/lib/python3.6/site-packages/ironic_staging_drivers/ovirt/ovirt.py-backup /usr/lib/python3.6/site-packages/ironic_staging_drivers/ovirt/ovirt.py --- /usr/lib/python3.6/site-packages/ironic_staging_drivers/ovirt/ovirt.py-backup 2021-02-04 09:11:52.068016965 +1000 +++ /usr/lib/python3.6/site-packages/ironic_staging_drivers/ovirt/ovirt.py 2021-02-04 09:15:45.813164874 +1000 @@ -135,6 +135,7 @@ ca_file = driver_info['ovirt_ca_file'] name = str.encode( driver_info['ovirt_vm_name'], encoding='ascii', errors='ignore') + name = name.decode('UTF-8') url = "https://%s/ovirt-engine/api" % address try: # pycurl.Curl.setopt doesn't support unicode strings, I'm fairly confident all objects passed from Ironic to ovirtsdk are all strings here. So there must be something turning them into byte objects at some point here. I'll need to keep digging. But I'm happy for feedback from the oVirt side if you might know what's going on here. So, I've spent some additional time on this. Basically the URL is being encoded for $reasons here: https://opendev.org/x/ironic-staging-drivers/src/branch/master/ironic_staging_drivers/ovirt/ovirt.py#L143 Presumably to validate that it doesn't contain non-ascii characters. But we probably shouldn't send the ASCII encoded string over to ovirtsdk. I would say it's better to validate the string and then send the URL as a string. I experimented with removing that section: https://opendev.org/x/ironic-staging-drivers/src/branch/master/ironic_staging_drivers/ovirt/ovirt.py#L139-L148 This works, but then Ironic complains that it can't find the byte encoded VM names. So we're doing the same thing for the VM names: https://opendev.org/x/ironic-staging-drivers/src/branch/master/ironic_staging_drivers/ovirt/ovirt.py#L136-L137 So, I'm fairly happy this is an issue on the Ironic side at this stage. Let's close this BZ off and I'll open a new one for Ironic and submit the relevant fixes over there. For reference on this one, before I forget. This is what I'm doing to work around the issue for now: [root@tripleo-director ironic]# podman exec -it -u0 ironic_conductor sed -n 136,153p /usr/lib/python3.6/site-packages/ironic_staging_drivers/ovirt/ovirt.py name = str.encode( driver_info['ovirt_vm_name'], encoding='ascii', errors='ignore') url = "https://%s/ovirt-engine/api" % address try: # pycurl.Curl.setopt doesn't support unicode strings, # attempt to turn `url` into an all-ASCII string; # in Python 3.x setopt accepts bytes as it should. url = str.encode(url, encoding='ascii', errors='strict') except UnicodeEncodeError: LOG.warning("oVirt URL '%(url)s' contains non-ascii characters, " "that might cause pycurl to explode " "momentarily", {'url': url}) try: name = driver_info['ovirt_vm_name'] url = "https://%s/ovirt-engine/api" % address connection = sdk.Connection(url=url, username=username, So after this string encoding is done to validate them, I'm resetting them back to the originals. It works for now, but needs a better solution. Fixed in Ironic staging drivers here: https://review.opendev.org/c/x/ironic-staging-drivers/+/784879 |