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

netdog: remove conditional compilation #3700

Merged

Conversation

jmt-lab
Copy link
Contributor

@jmt-lab jmt-lab commented Jan 6, 2024

Issue number:
Closes #3618

Removes conditional compilation of netdog for wicked and systemd networkd. This change moves our build system to build two variants of the netdog rpm: one for wicked and one for systemd-networkd. To facilitate this change the following was done:

  • Migrate #[cfg(net_backend = ] to #[cfg(feature =
  • Add two cargo features to sources/api/netdgo: 'wicked' and 'systemd-networkd'
  • Extract netdog to its own package folder (packages/netdog)
  • Extract netdog rpm building to netdog.spec
  • Create two subpackages one netdog-wicked and netdog-systemd-networkd which are selected via image-features
  • Migrated netdog to utilize the dogtag hostname detectors

Testing done:
Built and published aws-ecs-1 (wicked) and aws-ecs-2 (systemd-networkd) and verified network accessibility and use in a ecs cluster.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@jmt-lab jmt-lab marked this pull request as ready for review January 8, 2024 19:27
packages/netdog/netdog.spec Show resolved Hide resolved
sources/api/netdog/Cargo.toml Outdated Show resolved Hide resolved
variants/aws-ecs-2/Cargo.toml Outdated Show resolved Hide resolved
variants/aws-ecs-1-nvidia/Cargo.toml Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from 3797d34 to 142ab64 Compare January 9, 2024 22:52
Copy link
Contributor

@cbgbt cbgbt left a comment

Choose a reason for hiding this comment

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

Nice work! Please pardon any midair collisions with @sam-berning. I think we reviewed concurrently.

sources/api/netdog/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/Cargo.toml Outdated Show resolved Hide resolved
sources/api/netdog/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/Cargo.lock Outdated Show resolved Hide resolved
packages/settings-motd/Cargo.lock Outdated Show resolved Hide resolved
packages/os/Cargo.lock Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
variants/aws-dev/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/release/Cargo.lock Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch 7 times, most recently from 3bce866 to 903e65d Compare January 10, 2024 00:43
sources/api/netdog/src/cli/mod.rs Show resolved Hide resolved
variants/aws-dev/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/.gitignore Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from 903e65d to d7373d6 Compare January 10, 2024 20:44
@jmt-lab jmt-lab requested a review from cbgbt January 10, 2024 21:28
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch 4 times, most recently from e9ebd6f to 8d178ac Compare January 11, 2024 22:01
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Jan 11, 2024

Rolled back to handling the binary split in the rpm spec. It is more than sufficient and attempts to split the binary at cargo level fell upon issues with how netdog is structured that were not minimal to address

@jmt-lab
Copy link
Contributor Author

jmt-lab commented Jan 12, 2024

Reason for return of using rpmspec:

The reason for this was a bunch of roadblock updates i ran into with splitting the binaries out:

  • I first attempted a pretty straight forward split where i copied main.rs to two bin/networkd.rs and bin/wicked.rs files, this worked fine however leads to very large duplicate files since netdog currently re-uses its main.rs to set a large amount of static consts used throughout the crate
  • I then tried a hack by just symlinking main.rs twice to avoid cargo complaining about two targets using the same main.rs This did not propagate well into git and our ci cd
  • I then tried to do a lib and bin split where i took all the static const and most of the shared code to be in lib.rs and only moved the async main to the separated files, however this led to a collision with how netdog's multiple modules use private error messages with no shared top-type (meaning build error on visibility) this is fixable but would require alot ot making things public that i wasn't sure we wanted as such

As you can see above each approach i took to do the binary split at cargo time was bringing with it a bunch of more work when we had a functional solution. I decided to go back to a functional solution and file a github issue (which i need to do) for us to refactor netdog in the future to handle both this and how the cfgs are too integrated into too many source files

packages/netdog/Cargo.toml Show resolved Hide resolved
packages/netdog/netdog.spec Show resolved Hide resolved
packages/os/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
sources/api/netdog/src/main.rs Outdated Show resolved Hide resolved
@@ -142,7 +142,7 @@ impl Display for NetDevMacAddress {
}

impl NetDevConfig {
const FILE_EXT: &str = "netdev";
const FILE_EXT: &'static str = "netdev";
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a requirement of upgrated rust sdk. I'm surprised we aren't being riddled with more of these errors, but when the rust update landed as part of 1.18 into develop and i upgraded the PR it started flagging this as an error (previously was a warning) All module global consts need to have a static lifetime if using a type that requires lifetimes such as &str. It is no longer implicit

sources/api/netdog/src/cli/mod.rs Show resolved Hide resolved
sources/api/netdog/src/cli/mod.rs Show resolved Hide resolved
variants/aws-ecs-2/Cargo.toml Outdated Show resolved Hide resolved
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Jan 19, 2024

fix version number and remove accidental file

variants/aws-ecs-2/Cargo.toml Outdated Show resolved Hide resolved
packages/systemd/systemd.spec Outdated Show resolved Hide resolved
sources/netdog/build.rs Outdated Show resolved Hide resolved
sources/netdog/README.md Outdated Show resolved Hide resolved
sources/netdog/src/cli/mod.rs Show resolved Hide resolved
sources/netdog/src/networkd/config/netdev.rs Show resolved Hide resolved
packages/netdog/Cargo.toml Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from a00c56f to 4d95728 Compare February 1, 2024 20:43
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from 66e7dc7 to 2d8d69f Compare April 22, 2024 21:00
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Apr 22, 2024

For testing I did the following:

  • aws-ecs-2 test
    • verify network connectivity
    • verify netdog-systemd-networkd is installed and symlinked
    • verify 10-reverse-dns is installed
    • verify 20-imds is installed
    • verify hostname got set correctly and it did not fall through to setting ip
  • aws-ecs-1 test
    • verify network connectivity
    • verify netdog-wicked is installed and symlinked
    • verify 10-reverse-dns is installed
    • verify 20-imds is installed
    • verify hostname got set correctly and it did not fallthrough to setting ip

variants/aws-k8s-1.24/Cargo.toml Outdated Show resolved Hide resolved
packages/netdog/Cargo.toml Show resolved Hide resolved
sources/dogtag/src/lib.rs Outdated Show resolved Hide resolved
sources/netdog/src/cli/generate_hostname.rs Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch 3 times, most recently from 999abe3 to 88cb74b Compare April 25, 2024 22:52
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Apr 25, 2024

Updated dogtag to handle fallback to ip address

@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch 2 times, most recently from a30c741 to 1f1c14b Compare April 25, 2024 23:09
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch 2 times, most recently from e93b898 to 8447e26 Compare April 25, 2024 23:47
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Apr 25, 2024

Fix formatting

@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from 8447e26 to de33087 Compare April 26, 2024 00:00
packages/netdog/Cargo.toml Outdated Show resolved Hide resolved
[package.metadata.build-packages]
source-groups = [
"netdog",
"dogtag",
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we could put dogtag under netdog (like how various update-related crates are under sources/updater) but that can be done later

sources/netdog/src/cli/generate_hostname.rs Outdated Show resolved Hide resolved
packages/os/os.spec Show resolved Hide resolved
packages/netdog/netdog.spec Outdated Show resolved Hide resolved
@jmt-lab jmt-lab force-pushed the jmt/netdog/conditional-removal branch from de33087 to e0b18ac Compare April 29, 2024 20:14
@jmt-lab
Copy link
Contributor Author

jmt-lab commented Apr 29, 2024

  • Rebased off develop
  • Bump netdog version
  • Adjust Requires
  • Add missing newline
  • Remove extra newline
  • Adjust comment

Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

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

🚢 🚢 🚢 🥅 🐶

@jmt-lab jmt-lab merged commit 8933289 into bottlerocket-os:develop May 2, 2024
33 checks passed
@jmt-lab jmt-lab deleted the jmt/netdog/conditional-removal branch May 2, 2024 19:42
@bcressey bcressey changed the title Jmt/netdog/conditional removal netdog: remove conditional compilation May 7, 2024
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.

OOTB: Remove conditional compilation from netdog
6 participants