-
Notifications
You must be signed in to change notification settings - Fork 70
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
RHOAIENG-9707: chore(tests/containers): check shared objects with ldd #871
base: main
Are you sure you want to change the base?
Conversation
This sanity check will report any ELF files with dynamic linking that have unsatisfied dependencies. * apply the `"LD_LIBRARY_PATH": os.path.dirname(dlib)` fix/workaround cuda image already has some LD_LIBRARY_PATH, this is to be preserved ``` (app-root) sh-5.1$ echo $LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64 ``` * use subtests to handle multiple libs not found * skip known issue and false positives
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
isdirectory = stat.S_ISDIR(s.st_mode) | ||
isfile = stat.S_ISREG(s.st_mode) | ||
executable = bool(s.st_mode & (stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)) | ||
if isdirectory or not executable or not isfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder whether we should log/print the skipped/ignored files here with the explanation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe, but for /opt/app-root this will produce a lot of output that nobody in their right mind will have the energy to read through
cc @opendatahub-io/notebook-devs wdyt? do you like your pytest tests to be vvvverbose or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logged ticket for improving output
continue | ||
with open(dlib, mode='rb') as fp: | ||
magic = fp.read(4) | ||
if magic != b'\x7fELF': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar as above - do we want to log/print files like these for the convenience?
/lgtm |
@jiridanek: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
This sanity check will report any ELF files with dynamic linking that have unsatisfied dependencies.
"LD_LIBRARY_PATH": os.path.dirname(dlib)
fix/workaroundcuda image already has some LD_LIBRARY_PATH, this is to be preserved
use subtests to handle multiple libs not found
skip known issue and false positives
Description
Running
ldd
one by one on every file is quite lengthy on macOS, due to cross-architecture emulationcompare that with native linux vm, without this cross-arch translation
Since there's 1000 to 2000 dynamic libs to check in each of our images, the check on a macOS when using ldd can take 70 or more seconds.
When mentioned on a daily meeting, ppl weren't very concerned, so I'm not going to optimize this now.
For the future, already tried out one approach, using the debug/elf package in Go's standard library to simply read the DT_NEEDED field out of the libraries and check that. It's quite a lot of code, but it seems to work, and work fast.
check_elf_file_2.go.txt
Alternatively, it should be possible to just go around loading the dlls from the python script directly, to see if it loads or not
Question is whether binaries can be casually dlopened like this. I did this in skupper-router (dlopening the current executable ;) so it is possible sometimes, just don't know if always; worry that binary has to be compiled with some special options.
How Has This Been Tested?
Checked all what it found by hand and populated an allowlist to suppress false positives.
Over all, the usefulness of this check will be best seen when we do version upgrades or some significant version upgrades for 2025.a images. Is this going to be full of false positives for trivialities, or is it going to save us from dll hell? So far it found a true positive https://issues.redhat.com/browse/RHOAIENG-18904, but I do worry that the maintenance of the allowlist is not going to be worth it.
Possibly running
import xyz
for every python package we have is more useful. Adding to that small helloworld script to check functionality would be even more powerful.Merge criteria: