Skip to content
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

Split out a sled-hardware-types crate #5245

Merged
merged 6 commits into from
Mar 13, 2024
Merged

Conversation

jgallagher
Copy link
Contributor

On main as of #5158, we unexpectedly get some binaries depending on libnvme that shouldn't. In release builds:

installinator
omicron-dev
omicron-package
services-ledger-check-migrate
sled-agent
sled-agent-sim
wicketd

and in debug builds, all of the above plus omdb. We don't really care about this for binaries that don't run on the rack, so stripping the list down to binaries we do care about:

installinator
omdb (debug only)
sled-agent
wicketd

It's correct and expected that installinator and sled-agent depend on libnvme, but omdb shouldn't (and doesn't in release), and wicketd must not, as libnvme isn't available in the switch zone.

This PR fixes that incorrect dependency by splitting the parts of the sled-hardware crate that wicketd and omdb depended on (directly or transitively) into a new sled-hardware-types crate. On this PR, we are left with only the following needing libnvme, in both debug and release:

installinator
omicron-dev
omicron-package
services-ledger-check-migrate
sled-agent
sled-agent-sim

I assume with a bit more work we could trim out everything but installinator and sled-agent, and that might be worth doing, but we'd like to land this ASAP so as to not break any updates performed off of main. Separately, we could also imagine a CI check that we don't have unexpected library dependencies present in the final binaries; @papertigers is going to work on that.

Copy link
Contributor

@papertigers papertigers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm thanks again for the assist on this.

For future reference the way we were checking where this library was needed was with elfedit -r -e 'dyn:tag NEEDED' /path/to/file.

Then combined with find:

mike - atrium ~/src/omicron (git:john/sled-hardware-types) $ fd --max-depth=1 -t f . ./target/release/ -x bash -c "elfedit -r -e 'dyn:tag NEEDED' \{} 2>&1 | rg -v elfedit | rg libnvme && echo \{}"
       [1]  NEEDED            0x8b956a            libnvme.so.1
./target/release/sled-agent
       [1]  NEEDED            0x7e2b7a            libnvme.so.1
./target/release/services-ledger-check-migrate
       [0]  NEEDED            0x4d1be1            libnvme.so.1
./target/release/installinator
       [1]  NEEDED            0x895f0f            libnvme.so.1
./target/release/sled-agent-sim
       [9]  NEEDED            0x17d5ceb           libnvme.so.1
./target/release/omicron-dev
       [0]  NEEDED            0x3f5431            libnvme.so.1
./target/release/omicron-package

@jgallagher jgallagher merged commit 85150a7 into main Mar 13, 2024
22 checks passed
@jgallagher jgallagher deleted the john/sled-hardware-types branch March 13, 2024 00:07
papertigers added a commit that referenced this pull request Mar 22, 2024
After #5158 was integrated
@Rain noticed that attempting to run a build of `omdb` in the switch
zone suddenly stopped working and filed
oxidecomputer/helios-omicron-brand#15.
@jgallagher ended up fixing this by splitting out the sled-hardware
types into their own crate in
#5245.

We decided it would be good if we added some sort of CI check to omicron
to catch these library leakages earlier. This PR introduces that check
and adds it to the helios build and test buildomat job. I have also
added some notes to the readme for others that may end up adding a new
library dependency.

Locally I modified the allow list so that it would produce errors, those
errors end up looking like:
```
$ cargo xtask verify-libraries
    Finished dev [unoptimized + debuginfo] target(s) in 0.42s
     Running `target/debug/xtask verify-libraries`
    Finished dev [unoptimized + debuginfo] target(s) in 4.11s
Error: Found library issues with the following:
installinator
	UNEXPECTED dependency on libipcc.so.1
omicron-dev
	UNEXPECTED dependency on libipcc.so.1
	UNEXPECTED dependency on libresolv.so.2
sp-sim
	UNEXPECTED dependency on libipcc.so.1
	UNEXPECTED dependency on libresolv.so.2
sled-agent
	NEEDS libnvme.so.1 but is not allowed
mgs
	UNEXPECTED dependency on libipcc.so.1
	UNEXPECTED dependency on libresolv.so.2


If depending on a new library was intended please add it to xtask.toml
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants