-
Notifications
You must be signed in to change notification settings - Fork 160
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
Allow dkms to work in a chroot environment without /proc #485
base: master
Are you sure you want to change the base?
Conversation
@akorn I'm all for the change, but the tests are failing, can you have a look? Thanks. If the change requires changes to the tests, please provide those as well. |
@scaronni, with my latest commit the tests mostly succeed, except this one:
It seems that where the test expects Is that really a problem? If yes, I don't know how to fix it (i.e. break it again); I couldn't immediately understand how the tests even work. |
@anbe42, you wrote that noisy test that now succeeds instead of failing. Can you help a bit here? Why/how is |
Do you have the same kernel running on the host and installed in the chroot? Try a different kernel in the chroot. Usually host and chroot have different kernels (as it happens in all the CI scenarios) and the wrong 'make clean' command picks the wrong kernel (the one from the host). IIRC I had some checks for this issue, but maybe not in this specific test case. |
If I only have a different kernel in the chroot, the tests fail much sooner:
If I have both the same and a newer kernel, the testsuite fails later:
And if I have an older, the same, and a newer kernel:
It doesn't seem like I can satisfy this particular test. @anbe42, any suggestions? |
@scaronni meanwhile, can you perhaps rerun the tests in the official test environment? Who knows, they might succeed there. :) Thanks! |
The applied substitution does not produce identical results if it involves empty command output:
This breaks e.g. 'autoinstall'
Please rebase your branch on master. |
@akorn i've also fixed the issues with the fedora rawhide containers, so if you rebase on master at least you would get working tests. |
I know. I was hunting for occurrences where this mattered and already resolved some of them in commits 6801dc1 and 5f9f3c0, but not all (not being able to run the tests myself doesn't help -- I guess I'll just disable the noisy one locally).
I'll deal with this soon.
Done. |
@scaronni, can you rerun the tests? They succeed for me now (except the noisy one, but I don't think that's related to my changes). |
Running, sorry for the delay. |
it now works for me in my Debian test setup I'll try to test without /proc, too @scaronni: is it possible to add one test (any distribution, prefereably one utilizing the weak module code paths) with /proc unmounted to the CI matrix? @akorn: please rebase ( |
I think we can just add an extra tag in the table here: https://github.com/dell/dkms/blob/master/.github/workflows/tests.yml#L15 And then trigger a specific task in the tests than unmouns
Yes please, do a clean rebase (Fast Forward merge), no merge commits please. Besides this, I think it's fine for merging once corrected. Thanks. |
26afe79
to
57e045b
Compare
@anbe42 I'm fine with merging as soon as the tests pass. Do you agree? |
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.
In bash we can use [[ $var ]]
to check for non-empty values. While it is not being used consistently, [[ -n "$var" ]]
is less common (8 vs. 13 occurrences). So I'd prefer the shorter form.
Should I make this change everywhere for consistency, or just in the new lines that I'm adding? |
only in your new bits in order not to interfere with the ongoing shellcheck changes (#492) |
Done, I think. |
I finally managed to reproduce that and I'm currently testing a fix ... |
need to try that again, my machine crashed last night ... hopefully unrelated to that test ;-) |
In do_status_weak(), the previous code that relied on "< <" didn't run the loop when `module_status_weak()` returned failure. The new code, with "<<<", ignores the return status of `module_status_weak()` and only uses its output, even if it's empty. This change exits the `while` loop in `do_status_weak()` if `module_status_weak()` returned nothing. Similar changes may be necessary elsewhere, but let's see if this fixes the test.
In `setup_kernel_arches()`, we try to determine whether the architecture should be `ia32e`, based on some heuristics involving /proc/cpuinfo. This change allows the code to continue if `/proc/cpuinfo` doesn't exist, e.g. because we're in a chroot and `/proc` isn't mounted. In chroot situations where this heuristic architecture detection is expected to work (which I assume to be rare), a faux `/proc/cpuinfo` file should be created before calling `dkms`, e.g. by copying it from the host's real `/proc`. Since `dkms` would have just failed in such chroot environments before, this change still results in an improvement; the code can be refined later if necessary.
The shift from the `< <(cmd)` idom to `<<<"$(cmd)"` which is needed to work without /proc being mounted has the unfortunate side effect that the exit status of `cmd` is ignored where it wasn't before. This can cause statements that previously always had valid input to be called on empty strings. One such occurrence was in `setup_kernels_arches()`, which, among other things, populates the `kernelver` array; after the `<<<` change, this array could contain an empty string as an element. This commit adds a sanity check to make sure we don't pretend there is a kernel whose version number is the empty string.
For me, the tests succeed now, but maybe not all of these changes were necessary.
We were testing `[[ -n "$status" ]]` twice; go with the more explicit/readable `|| continue` version like everyhwere else.
(Only in new lines added by the chroot-no-proc branch.)
11af52a
to
16e4d5a
Compare
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 think you can squash most of your fixup commits together. The /proc/cpuinfo check should stay separate. If I'm not mistaken, everything else deals with skipping the empty lines introduced by using the alternate idiom.
Please wait with rebasing for #492 (the shellcheck changes) being merged, that may cause some conflicts and may require some further reworking.
I've just tried adding a umount /proc && run_tests.sh
test to the Debian package and tested your branch with it. Didn't explode ;-)
@@ -384,7 +384,7 @@ setup_kernels_arches() | |||
local i | |||
i=0 | |||
while read line; do | |||
[[ -n "$line" ]] || continue | |||
[[ "$line" ]] || continue |
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.
please use unquoted [[ $line ]]
Yes, I think so too.
Roger that, standing by.
That's good news -- I think I fixed almost all bugs that could have led to actual explosions. :) |
I didn't author these changes; I'm just submitting the pull request (with the author's permission) in the hope that it can be merged with little or no discussion.
It's a fairly small and self-explanatory set of changes that, at least at first glance, shouldn't alter existing behaviour, just make dkms as a whole more robust by not requiring
/proc
to be mounted for it to work.