Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check_idmap_xml_filesystem_device failure #3995

Conversation

chunfuwen
Copy link
Contributor

Previously use name in line to get user id and group id. In some cases, if there is one more name with same prefix in,it can get wrong user information

@chunfuwen
Copy link
Contributor Author

previously it failed with below message:

2024-09-04 10:35:31,794 process L0658 INFO | Running 'cat /etc/subuid' 2024-09-04 10:35:31,802 process L0470 DEBUG| [stdout] jenkins:100000:65536 2024-09-04 10:35:31,803 process L0739 INFO | Command 'cat /etc/subuid' finished with 0 after 0.001282615s 2024-09-04 10:35:31,803 process L0470 DEBUG| [stdout] uri_test:165536:65536 2024-09-04 10:35:31,803 process L0470 DEBUG| [stdout] testacl:231072:65536 2024-09-04 10:35:31,803 process L0470 DEBUG| [stdout] test:296608:65536 2024-09-04 10:35:31,805 process L0658 INFO | Running 'cat /etc/subgid' 2024-09-04 10:35:31,811 process L0470 DEBUG| [stdout] jenkins:100000:65536 2024-09-04 10:35:31,811 process L0470 DEBUG| [stdout] uri_test:165536:65536 2024-09-04 10:35:31,811 process L0470 DEBUG| [stdout] testacl:231072:65536 2024-09-04 10:35:31,811 process L0470 DEBUG| [stdout] test:296608:65536

...
2024-09-04 10:35:34,749 stacktrace L0039 ERROR|
2024-09-04 10:35:34,749 stacktrace L0041 ERROR| Reproduced traceback from: /var/ci/libvirt-ci/runtest/avocado-vt/avocado-vt/avocado_vt/test.py:292
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| Traceback (most recent call last):
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| File "/var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt/libvirt/tests/src/virtual_device/filesystem_device_unprivileged.py", line 389, in run
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| check_virtiofs_idmap()
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| File "/var/lib/avocado/data/avocado-vt/virttest/test-providers.d/downloads/io-github-autotest-libvirt/libvirt/tests/src/virtual_device/filesystem_device_unprivileged.py", line 241, in check_virtiofs_idmap
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| check_idmap_xml_filesystem_device(user_info, fs)
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| File "/var/ci/libvirt-ci/runtest/avocado-vt/avocado-vt/virttest/utils_libvirt/libvirt_filesystem.py", line 41, in check_idmap_xml_filesystem_device
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| raise TestError(
2024-09-04 10:35:34,750 stacktrace L0045 ERROR| avocado.core.exceptions.TestError: The XML didn't match the expected user ids. Expected: {'user': 'test', 'group': 'test', 'uid': 1003, 'gid': 1003, 'subuid': 165536, 'subuid_count': 65536, 'subgid': 165536, 'subgid_count': 65536}. Got: {'uid': 1003, 'subuid': 296608, 'subuid_count': 65536, 'gid': 1003, 'subgid': 296608, 'subgid_count': 65536}.
2024-09-04 10:35:34,750 stacktrace L0046 ERROR|

@chunfuwen
Copy link
Contributor Author

cleaning libvirtd logs...
DATA (filename=output.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stdout.expected) => NOT FOUND (data sources: variant, test, file)
DATA (filename=stderr.expected) => NOT FOUND (data sources: variant, test, file)
PASS 1-type_specific.io-github-autotest-libvirt.virtual_devices.filesystem_device_unprivileged.one_fs.with_memfd.two_guests.coldplug

@chunfuwen
Copy link
Contributor Author

@smitterl ,please help have a look

@@ -61,7 +61,14 @@ def _get_subid(id_filepath, name, info):
if not entry:
raise TestError("No entry for %s found in %s" % (name, id_filepath))

entry = entry[0].split(":")
matched_entry = None
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you @chunfuwen I wonder if we could have a shorter solution like the following:

entry = [l for l in result.stdout_text.split("\n") if name in l and name == l.split(":")[0]]

(I think name in l is still necessary to avoid an issue if there were empty or malformed lines.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@chunfuwen chunfuwen force-pushed the fix_filesystem_username_match_issue branch from c9d1669 to baf4aff Compare September 6, 2024 01:39
Previously use name in line to get user id and group id.
In some cases, if there is one more name with same prefix in,it can get
wrong user information

Signed-off-by: chunfuwen <[email protected]>
@chunfuwen chunfuwen force-pushed the fix_filesystem_username_match_issue branch from baf4aff to 50efc5c Compare September 6, 2024 02:46
Copy link
Contributor

@smitterl smitterl left a comment

Choose a reason for hiding this comment

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

Thank you!

@Yingshun Yingshun merged commit ec69b5f into avocado-framework:master Sep 9, 2024
50 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