Bug 1961748
| Summary: | Expose sanlock_inquire() in python bindings | |||
|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 8 | Reporter: | Nir Soffer <nsoffer> | |
| Component: | sanlock | Assignee: | David Teigland <teigland> | |
| Status: | CLOSED ERRATA | QA Contact: | cluster-qe <cluster-qe> | |
| Severity: | high | Docs Contact: | ||
| Priority: | high | |||
| Version: | 8.4 | CC: | aefrat, agk, cluster-maint, cmarthal, jbrassow, teigland | |
| Target Milestone: | beta | Keywords: | Triaged, ZStream | |
| Target Release: | --- | Flags: | pm-rhel:
mirror+
|
|
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | sanlock-3.8.4-1.el8 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1965483 (view as bug list) | Environment: | ||
| Last Closed: | 2021-11-09 19:44:19 UTC | Type: | Bug | |
| Regression: | --- | Mount Type: | --- | |
| Documentation: | --- | CRM: | ||
| Verified Versions: | Category: | --- | ||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
| Cloudforms Team: | --- | Target Upstream Version: | ||
| Embargoed: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 1961752, 1965483 | |||
|
Description
Nir Soffer
2021-05-18 15:48:48 UTC
How to test this change: 1. Connect to ovirt SPM host, and find vdsm pid # pgrep '^vdsmd$' 1956 2. Start python shell and import sanlock # python3 Python 3.6.8 (default, Mar 18 2021, 08:58:41) [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sanlock 3. Testing online help >>> help(sanlock.inquire) Help on built-in function inquire in module sanlock: inquire(...) inquire(slkfd=fd, pid=owner) Return list of resources held by current process (using the slkfd argument to specify the sanlock file descriptor) or for another process (using the pid argument). Does not access storage. To learn about resource state on storage, use sanlock.read_resource() and sanlock.read_resource_owners(). Arguments slkfd (int): The file descriptor returned from sanlock.register(). pid (int): The program pid to query. Returns List of resource dicts with the following keys: lockspace (bytes): lockspace name resource (bytes): resource name flags (int): resource flags (sanlock.RES_*) version (int): resource version disks (list): list of disk tuples (path, offset) 4. Registering with sanlock >>> fd = sanlock.register() >>> fd 3 5. Querying resources owned by this process via slkfd: >>> sanlock.inquire(slkfd=fd) [] We don't own any resource, so empty list is expected. 6. Querying resources owned by this process via pid >>> import os >>> sanlock.inquire(pid=os.getpid()) [] 7. Querying resources held by vdsm >>> import pprint >>> pprint.pprint(sanlock.inquire(pid=1956)) [{'disks': [('/dev/8ef0cc64-77c5-49e0-a0f5-03cee9bbee20/leases', 1048576)], 'flags': 1, 'lockspace': b'8ef0cc64-77c5-49e0-a0f5-03cee9bbee20', 'resource': b'SDM', 'version': 30}] 8. Querying resources while vdsm is running storage job Start long operation like copy large disk between storage domains. Run sanlock.inquire() on the host running the job and check that the host reports the volume lease. Avihai, can you add QE ack to this bug? We need this for bug 1961752 and we are the only user of sanlock python binding. See comment 1 on how this can be tested. It is also possible to test this with modified vdsm using this feature in one of the next rhv 4.4.7 builds. I will add more details about this in bug 1961752. Corey from lvm QE can help with the RHEL process bits. Sure, we (cluster-qe) can help with the errata process, regression testing, etc. We just don't typically do api level tests. (In reply to Nir Soffer from comment #2) > Avihai, can you add QE ack to this bug? We need this for bug 1961752 > and we are the only user of sanlock python binding. I can not QE ACK for RHEL QE in a RHEL bug as I'm RHV QE. Can't this be tested in RHEL level? Of course we'll will help with verification if needed but again can not QE ACK it in RHEL QE's name. Merged upstream in:
commit 2d3e2fceb615a5bd12d26b09fe95668152fb0743
Author: Nir Soffer <nsoffer>
Date: Wed Apr 28 02:20:28 2021 +0300
python: Add inquire()
Use sanlock_inquire() to query the resource held by the current process
(using the slkfd= argument) or held by another program (using the pid=
argument).
When using the slkfd= argument, we communicate with sanlock daemon using
slkfd, ensuring that the current process is connected to sanlock. If the
current process is not connected, sanlock assumes that the process is
dead, and release all the leases acquired by the process.
When using the pid= argument, the function opens a new socket to sanlock
daemon and query the status of resources owned by specified pid.
In both cases the information comes from sanlock daemon, without
accessing storage. To verify storage content, the caller should use
read_resource() and read_resource_owners().
The call returns list of resources dicts that can be used for verifying
that sanlock state matches the program state.
sanlock_inquire() reports the SANLOCK_RES_LVER or sanlock.RES_SHARED
flags in the resource flags field. Add the field to the returned dict
and add sanlock constants for the flag.
The resource flags are needed if you want to restore a lease after it
was released, ensuring that nobody else acquired the lease after it was
released. This flow is used by libvirt using libsanlock. With this
change we can implement the same flow using the python binding.
Signed-off-by: Nir Soffer <nsoffer>
Marking this verified in the latest rpms based on our regression testing and the above comments from RHV testing. sanlock-3.8.4-1.el8 BUILT: Tue Jun 1 16:16:52 CDT 2021 sanlock-lib-3.8.4-1.el8 BUILT: Tue Jun 1 16:16:52 CDT 2021 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory (sanlock bug fix and enhancement update), and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2021:4422 |