Skip to content

Conversation

TimSmithCtx
Copy link
Contributor

It seems to be possible for a description field on an LV snapshot to be converted to a dictionary, which results in attempts to remove it from the MGT volume failing after it is deleted, which in turn results in a subsequent scan failing because an LV which should exist does not.

It is not immediately clear how this ended up as a dictionary as it has been back and forth through XMLRPC a few times, but to solve the immediate issue, defend against such things.

LunfanZhang
LunfanZhang previously approved these changes Jul 31, 2025
return None
if type(obj) == str:
return obj
if type(obj) == dict and len(obj) == 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Following Python best practice, isinstance(obj, dict) is preferred over type(obj), but both are worked.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well tidy this up while we're making changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we don't expect this to be the data type that we receive from xapi I wonder if we should log what we got as it might then allow for determining what went wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're fixing up the old practice here, also might as well remove the check for the type being "str" anyway, as it is redundant.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dangling bits of py2 -> py3 I suspect. It probably had basestring and unicode in there at some point.

It seems to be possible for a description field on an LV snapshot to be
converted to a dictionary, which results in attempts to remove it from
the MGT volume failing after it is deleted, which in turn results in a
subsequent scan failing because an LV which should exist does not.

It is not immediately clear how this ended up as a dictionary as it has
been back and forth through XMLRPC a few times, but to solve the
immediate issue, defend against such things.

Signed-off-by: Tim Smith <[email protected]>
@TimSmithCtx TimSmithCtx merged commit 1e002e8 into xapi-project:master Aug 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants