RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1961748 - Expose sanlock_inquire() in python bindings
Summary: Expose sanlock_inquire() in python bindings
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sanlock
Version: 8.4
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: beta
: ---
Assignee: David Teigland
QA Contact: cluster-qe@redhat.com
URL:
Whiteboard:
Depends On:
Blocks: 1961752 1965483
TreeView+ depends on / blocked
 
Reported: 2021-05-18 15:48 UTC by Nir Soffer
Modified: 2021-11-10 08:43 UTC (History)
6 users (show)

Fixed In Version: sanlock-3.8.4-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1965483 (view as bug list)
Environment:
Last Closed: 2021-11-09 19:44:19 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2021:4422 0 None None None 2021-11-09 19:44:26 UTC

Description Nir Soffer 2021-05-18 15:48:48 UTC
Description of problem:

sanlock client library provides sanlock_inquire() API reporting all reosurces
managed for particular sanlock connection or process pid. This API is needed
by RHV to detect case like bug 1952345, when sanlock released resources owned
by vdsm without terminating vdsm.

sanlock_inquire() was never exposed in sanlock python binding, since RHV never used it. RHV want to start using this as soon as possible.

Version-Release number of selected component (if applicable):
3.8.3

Patch posted upstream for review:
https://lists.fedorahosted.org/archives/list/sanlock-devel@lists.fedorahosted.org/thread/FFKWOACPRF44TYJINMWVCNIIIH7HCEAF/

Comment 1 Nir Soffer 2021-05-19 16:05:35 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.

Comment 2 Nir Soffer 2021-05-19 19:20:53 UTC
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.

Comment 3 Corey Marthaler 2021-05-19 19:44:01 UTC
Sure, we (cluster-qe) can help with the errata process, regression testing, etc. We just don't typically do api level tests.

Comment 4 Avihai 2021-05-20 09:09:13 UTC
(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.

Comment 5 Nir Soffer 2021-05-20 11:15:08 UTC
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>

Comment 16 Corey Marthaler 2021-06-07 17:21:49 UTC
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

Comment 19 errata-xmlrpc 2021-11-09 19:44:19 UTC
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


Note You need to log in before you can comment on or make changes to this bug.