Bug 1221222

Summary: yast2-storage-ng fails to build against swig 4.2
Product: [openSUSE] openSUSE Tumbleweed Reporter: Dominique Leuenberger <dimstar>
Component: YaST2Assignee: E-mail List <yast2-maintainers>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None CC: aschnell
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Dominique Leuenberger 2024-03-11 07:57:25 UTC
swig has been submitted to be updated to version 4.2.1

https://build.opensuse.org/request/show/1154599/changes

This in turn makes yast2-storage-ng fail to build:

[   51s]      ArgumentError:
[   51s]        Wrong arguments for overloaded method 'LvmVg.create_lvm_lv'.
[   51s]        Possible C/C++ prototypes are:
[   51s]            storage::LvmLv LvmVg.create_lvm_lv(std::string const &lv_name, storage::LvType lv_type, unsigned long long size)
[   51s]            storage::LvmLv * LvmVg.create_lvm_lv(std::string const &lv_name, unsigned long long size)

swig is currently in Staging:K - buildlog for y2-storage-ng at
https://build.opensuse.org/package/live_build_log/openSUSE:Factory:Staging:K/yast2-storage-ng/standard/x86_64
Comment 1 Stefan Hundhammer 2024-03-11 10:08:30 UTC
AFAICS that's the libstorage-ng bindings.

-> Arvin
Comment 2 Arvin Schnell 2024-03-11 13:52:03 UTC
AFAIS the bindings work. I have added an example using create_lvm_lv
and that works with swig 4.2.1:

https://github.com/openSUSE/libstorage-ng/blob/master/bindings/ruby/examples/lvm.rb

I assume YaST passes the wrong types to create_lvm_lv. Maybe the
new swig version is more strict in that regard (the changelog addition
itself is several hundreds lines long so I cannot say for sure).
In the YaST code for me it is unclear where the conversion from
DiskSize to unsigned long long is done.
Comment 3 Stefan Hundhammer 2024-03-11 15:45:59 UTC
This does not at all look like a generic problem with DiskSize; in that entire build log only two methods are failing:

> % grep 'Wrong arguments for overloaded method' build.log | perl -pe 's/^\s*//' | sort -u
> Wrong arguments for overloaded method 'Lvm.Vg.create_lvm_lv'.
> Wrong arguments for overloaded method 'LvmVg.create_lvm_lv'.


...which begs the question: What is special about those two methods?
Comment 4 Stefan Hundhammer 2024-03-11 16:36:44 UTC
In many of the failed tests, I see this:

Failure/Error: before { devicegraph_stub("trivial_lvm_and_other_partitions") }

where that YAML file yast-storage-ng/test/data/devicegraphs/trivial_lvm_and_other_partitions.yml has this section about the LV:


- lvm_vg:
    vg_name: vg0
    lvm_pvs:
        - lvm_pv:
            blk_device: /dev/sda1

    lvm_lvs:
        - lvm_lv:
            size:         unlimited
            lv_name:      lv1
            file_system:  btrfs
            mount_point:  /


The FakeDeviceFactory which is used throughout the yast-storage-ng unit tests checks various keys that it receives from a YAML file, e.g. "size", and converts the corresponding value to a DiskSize object. The special value "unlimited" is translated to -1 which means "unlimited".

But it's -1 which certainly cannot be converted to an unsigned long long.


I guess in this context it means "take everything that is available", i.e. the sum of all associated PVs. This used to work before, and the code is quite trivial:

https://github.com/yast/yast-storage-ng/blob/master/src/lib/y2storage/fake_device_factory.rb#L772 

  lvm_lv = parent.create_lvm_lv(lv_name, size)

'size' should now be DiskSize("unlimited"), i.e. -1.

'parent' *should* be     

  # @param parent [Object] volume group object

which I hope is a Ruby object here.

But SWIG seems to be confused about that; look closely at the exact alternatives that it proposes:

> storage::LvmLv LvmVg.create_lvm_lv(std::string const &lv_name, storage::LvType lv_type, unsigned long long size)
> storage::LvmLv * LvmVg.create_lvm_lv(std::string const &lv_name, unsigned long long size)


I.e. a non-pointer storage::LvmLv object vs. a storage::LvmLv pointer.
Comment 5 Arvin Schnell 2024-03-11 16:44:31 UTC
(In reply to Stefan Hundhammer from comment #4)

> https://github.com/yast/yast-storage-ng/blob/master/src/lib/y2storage/
> fake_device_factory.rb#L772 
> 
>   lvm_lv = parent.create_lvm_lv(lv_name, size)
> 
> 'size' should now be DiskSize("unlimited"), i.e. -1.

One entry in the swig changelog includes "Ruby negative number check". Maybe swig
now detects that -1 is not a unsigned long long and thus cannot decide which function
to use.

> But SWIG seems to be confused about that; look closely at the exact
> alternatives that it proposes:
> 
> > storage::LvmLv LvmVg.create_lvm_lv(std::string const &lv_name, storage::LvType lv_type, unsigned long long size)
> > storage::LvmLv * LvmVg.create_lvm_lv(std::string const &lv_name, unsigned long long size)
> 
> I.e. a non-pointer storage::LvmLv object vs. a storage::LvmLv pointer.

Yes, I also noticed the wrong non-pointer.
Comment 6 Arvin Schnell 2024-03-11 16:49:59 UTC
(In reply to Arvin Schnell from comment #5)

> One entry in the swig changelog includes "Ruby negative number check". Maybe
> swig
> now detects that -1 is not a unsigned long long and thus cannot decide which
> function
> to use.

That seems to be the case. If I pass a size of -1 in the new example
mentioned above it fails with the new swig version. If I compile the
bindings with the old swig version swig does not complain and passes
-1 alias 16 EiB to libstorage-ng.
Comment 7 Stefan Hundhammer 2024-03-12 10:36:16 UTC
OK, so this could be fixed with a one-liner in the FakeDeviceFactory: If the requested size for an LV is 'unlimited' (-1), use a huge size instead like 16 EiB.

I guess that only works because somewhere in libstorage-ng this is limited by the available size for that LV, right?
Comment 8 Arvin Schnell 2024-03-12 11:13:15 UTC
(In reply to Stefan Hundhammer from comment #7)
> OK, so this could be fixed with a one-liner in the FakeDeviceFactory: If the
> requested size for an LV is 'unlimited' (-1), use a huge size instead like
> 16 EiB.
> 
> I guess that only works because somewhere in libstorage-ng this is limited
> by the available size for that LV, right?

No, the volume group is overcommitted in that case. Maybe the result is
not really needed in the testcases.
Comment 9 Stefan Hundhammer 2024-03-12 11:58:56 UTC
PR with a fix:

  https://github.com/yast/yast-storage-ng/pull/1374

this will become available as yast2-storage-5.0.9.
Comment 10 Stefan Hundhammer 2024-03-12 14:06:07 UTC
New PR since the previous one did not find agreement:

  https://github.com/yast/yast-storage-ng/pull/1375

this will become available as yast2-storage-5.0.9.
Comment 11 Stefan Hundhammer 2024-03-12 14:37:20 UTC
Merged PR #1375, but Jenkins is down right now. An auto-submission will follow as soon as it's back up.
Comment 12 Stefan Hundhammer 2024-03-13 10:58:56 UTC
Submitted manually to OBS Factory:

https://build.opensuse.org/request/show/1157596
Comment 13 Stefan Hundhammer 2024-04-03 13:01:59 UTC
PR for SLE-15-SP6:

  https://github.com/yast/yast-storage-ng/pull/1378
Comment 14 Stefan Hundhammer 2024-04-04 09:21:06 UTC
SR to IBS for SLE-15-SP6:

  https://build.suse.de/request/show/325354