AIX Open Source

 View Only
  • 1.  ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Sat September 24, 2022 09:12 AM

    I am opening this thread on behalf of an AIX client.

    Some systems have broken symlinks after a dnf update.

    Traceback (most recent call last):
    File "/usr/bin/dnf", line 57, in <module>
    from dnf.cli import main
    <...>
    File "/opt/freeware/lib/python3.7/site-packages/dnf/yum/rpmtrans.py", line 26, in <module>
    import rpm
    ModuleNotFoundError: No module named 'rpm'

    The user tracked this down to a broken link:
    /opt/freeware/lib/python3.7/site-packages/rpm -> ../../../../..//usr/opt/rpm/lib/python3.7/site-packages/rpm

    I analyzed the case, from an AIX perspective, to ensure they were not encountering some issues with the KSH shell, which had some specific "cd ../.." issues. The affected levels were older service packs, and had ifixes so I wanted to rule out the issue with the KSH shell:

    Further review and testing revealed this was not applicable to the environment.

    I tested their levels, and ifixes, and could not reproduce the issue. Furthermore, the majority of their systems did not have this issue, at the same shell and oslevels.

    At the time, I was not sure the issue was specific to one directory, but further discussions indicate this was, indeed specific to the rpm-python3 package symlink:

    /opt/freeware/lib/python3.7/site-packages/rpm -> ../../../../..//usr/opt/rpm/lib/python3.7/site-packages/rpm
    

    The source /usr/opt/rpm/lib/python3.7/site-packages/rpm was OK, but they could not list the inode information for this symlink:

    istat /usr/opt/rpm/lib/python3.7/site-packages/rpm --> OK
    istat /opt/freeware/lib/python3.7/site-packages/rpm  --> istat: Unable to stat /opt/freeware/lib/python3.7/site-packages/rpm
    ls -lrt  ../../../../..//usr/opt/rpm/lib/python3.7/site-packages/rpm "not found"  

    Relinking resolved the issue.

    ln -sf /usr/opt/rpm/lib/python3.7/site-packages/rpm /opt/freeware/lib/python3.7/site-packages/rpm
    

    It seems some underlying inode is invalid, but I cannot determine the root cause, and cannot reproduce the error, although I have attempted this for 2 days, with many tests.

    I checked the delivering package:

    # rpm2cpio rpm-python3-4.15.1-32_1.aix7.1.ppc.rpm | /opt/freeware/bin/cpio -idmv
    
    # find .   \( -type l -o -type d \) -name rpm -ls | grep site-packages
    21352    1 lrwxrwxrwx  1 root      system          59 Sep 22 20:41 ./opt/freeware/lib/python3.7/site-packages/rpm -> ../../../../..//usr/opt/rpm/lib/python3.7/site-packages/rpm
    21358    1 drwxr-xr-x  2 root      system         256 Sep 22 20:41 ./usr/opt/rpm/lib/python3.7/site-packages/rpm

    I am not sure what could have happened.

    I have also tried to reproduce the issue, by changing inodes under symlinks:

    I created a symlink directory, like the package contains:

    # cd /tmp/dirB/testdir/linktest
    # ln -sf ../../../../..//tmp/dirB/testdir/linktest/source target
    

    Copied this to a new directory:

    # cp -hr /tmp/dirB/testdir /tmp/dirA
    # cd /tmp/dirA/testdir/linktest
    # ls -lrt target
    lrwxrwxrwx 1 root system 48 Sep 24 07:06 target -> ../../../../..//tmp/dirB/testdir/linktest/source
    

    Checked inodes:

    # istat /tmp/dirB/testdir/linktest/target
    # istat /tmp/dirA/testdir/linktest/target
    Inode 21786 on device 10/7      Directory
    

    Then I moved, then copied to a new directory:

    mv /tmp/dirB /tmp/dirB.old
    cp -hr /tmp/dirB.old /tmp/dirB
    

    Inodes are changed for BOTH directories, so no errors:

    # istat /tmp/dirB/testdir/linktest/target
    # istat /tmp/dirA/testdir/linktest/target
    Inode 21798 on device 10/7      Directory
    

    They have 3 oslevels:

    7200-05-02-2114 - Only 3 have this issue, and 51 do not have the issue.
    7200-04-02-2028
    7200-03-03-1914

    I have advised that, unless they did the DNF update with debug enabled, there would not be any additional information, and I'm not even sure that debug output would show what happened, The systems were updated before the user inherited them, so he does not have any specific details about the environment at the time the update happened.


    I have advised them that you might not be able to provide any additional root cause analysis, but perhaps can suggest some debug steps to apply before doing any future updates.  I will advise them to communicate with you in this forum for more advice.



    ------------------------------
    Jan Harris
    AIX Development Support (Liaison to the AIX Toolbox for Open Source)
    IBM (Contract)
    Austin TX
    ------------------------------


  • 2.  RE: ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Tue September 27, 2022 10:09 AM
    Jan,
    Thank you for creating this post in the community.  Any help we can get on this issue is greatly approciated.

    ------------------------------
    Ken Foster
    ------------------------------



  • 3.  RE: ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Thu September 29, 2022 01:10 PM
    Hello
    We have discussed, tested, and discussed again.  It is possible that, *if* the issue occurred again, and the problem occurs during a DNF update, a truss could provide some clues.  We have not been able to replicate this issue.

    # truss -t\!lseek,\!_sigaction,\!kioctl,\!kfcntl,\!sbrk,\!__loadx,\!sigprocmask,\!_sigaction,\!thread_setmymask_fast,\!kwaitpid,\!__libc_sbrk -feado /tmp/truss.out ./dnf_aixtoolbox.sh -d


    ​​

    ------------------------------
    Jan Harris
    AIX Development Support (Liaison to the AIX Toolbox for Open Source)
    IBM (Contract)
    Austin TX
    ------------------------------



  • 4.  RE: ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Fri September 30, 2022 04:14 PM
    I am the owner of this issue would like to see if anyone has suggestions on why the link was set up this way?

    ------------------------------
    Todd Japak
    ------------------------------



  • 5.  RE: ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Tue October 04, 2022 10:36 AM
    Still looking for any thoughts or suggestions for this issue.

    ------------------------------
    Todd Japak
    ------------------------------



  • 6.  RE: ModuleNotFoundError: No module named 'rpm' invalid symlink under site-packages

    Posted Tue October 04, 2022 10:51 PM
    Hi Todd,

    We weren't able to find the how this issue could be reproduce.
    For 7.3 we are creating an absolute path.
    We will check if using the same method is better here as well.

    ------------------------------
    SANGAMESH
    ------------------------------