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

feat: Build Rover without supergraph compose for Alpine #538

Merged
merged 18 commits into from
May 17, 2021

Conversation

EverlastingBugstopper
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper commented May 13, 2021

This PR satisfies the first steps checklist outlined in #537.

  • Adds a composition-js cargo feature to Rover (which is enabled by default)
  • In release.yml we compile for x86_64-unknown-linux-musl with the --no-default-features flag
  • In our test.yml we run an extra cargo check --workspace --locked --no-default-features to make sure it compiles OK
  • Both the npm installer and the curl installer now check for the existence of glibc >= 2.18 and downloads the musl binary if it does not exist. It will also print a warning to the user that their install is not fully-featured.

If a user installs the musl binary and attempts to run rover supergraph compose, they will get the following error:

$ rover supergraph compose
error: This version of Rover does not support this command.
        If the command `ldd --version` prints a `glibc` version >= 2.18, you can try installing the Rover binary built for `x86_64-unknown-linux-gnu`.

I... couldn't find a nice way to check the glibc version right in Rust. I think that error message should be good enough in that case? It's not perfect.


A few other things:

Installing on Alpine will give you the following warning message:

$  curl -sSL https://rover.apollo.dev/nix/latest | sh
This operating system does not support dynamic linking to glibc.
Downloading musl binary that does not include `rover supergraph compose`.
downloading rover from https://github.com/apollographql/rover/releases/download/v0.1.1/rover-v0.1.1-x86_64-unknown-linux-musl.tar.gz
Writing binary to /home/avery/.rover/bin/rover
rover was successfully installed. Great!

To get started you need Rover's bin directory (/home/avery/.rover/bin) in your PATH environment variable. Next time you log in this will be done automatically.

To configure your current shell, you can run:
exec /bin/ash -l
If you would like to disable Rover's anonymized usage collection, you can set APOLLO_TELEMETRY_DISABLED=1
You can check out our documentation at https://go.apollo.dev/r/docs.

I've added the -l flag to the exec $SHELL command that we recommend since Alpine will only re-source .profile on login shells. This flag also works on zsh and bash.

@EverlastingBugstopper EverlastingBugstopper added the feature 🎉 new commands, flags, functionality, and improved error messages label May 13, 2021
@EverlastingBugstopper EverlastingBugstopper added this to the May 25 milestone May 13, 2021
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

This was mostly not Rust, so I reviewed that more carefully. I did review the Rust, and didn't notice anything unexpected.

.github/workflows/release.yml Show resolved Hide resolved
installers/binstall/scripts/nix/install.sh Outdated Show resolved Hide resolved
installers/npm/binary.js Outdated Show resolved Hide resolved
src/command/supergraph/compose/no_compose.rs Outdated Show resolved Hide resolved
@EverlastingBugstopper
Copy link
Contributor Author

maybe what we do is we check ldd --version for the string "musl" and base it on that since ldd exists on both alpine and non-alpine images?

@abernix
Copy link
Member

abernix commented May 13, 2021

I think that's a good approximation. Expanding on that I trust this implementation which uses that approach but expands on it a bit!

https://github.com/lovell/detect-libc

@EverlastingBugstopper
Copy link
Contributor Author

oo look what i found

@EverlastingBugstopper EverlastingBugstopper force-pushed the avery/alpine-build branch 3 times, most recently from e27ee67 to 8bba2d9 Compare May 13, 2021 21:21
@@ -57,7 +65,7 @@ strsim = "0.10"
structopt = "0.3.21"
toml = "0.5"
tracing = "0.1.26"
url = "2.2.2"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think compiling with --no-default-features made this break, so had to add it explicitly so our no-composition-js would compile

/// The relative path to the supergraph configuration file.
#[structopt(long = "config")]
#[serde(skip_serializing)]
config_path: Option<Utf8PathBuf>,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

made this an option so folks wouldn't see an error message requiring this flag that, if provided, wouldn't do anything anyway

let mut err = RoverError::new(anyhow!(
"This version of Rover does not support this command."
));
err.set_suggestion(Suggestion::CheckGnuVersion);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should be doing this in our command code waaayyy more often. i forgot i made the api like this.

@@ -127,8 +128,7 @@ impl Display for Suggestion {
Suggestion::Adhoc(msg) => msg.to_string(),
Suggestion::CheckServerConnection => "Make sure the endpoint is accepting connections and is spelled correctly".to_string(),
Suggestion::ConvertGraphToSubgraph => "If you are sure you want to convert a non-federated graph to a subgraph, you can re-run the same command with a `--convert` flag.".to_string(),


Suggestion::CheckGnuVersion => "If the command `ldd --version` prints a `glibc` version >= 2.18, you can try installing the Rover binary built for `x86_64-unknown-linux-gnu`.".to_string(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't love this messaging... lemme know if y'all have ideas

@EverlastingBugstopper
Copy link
Contributor Author

EverlastingBugstopper commented May 14, 2021

Alright! I think this is good to go, I've tested everything out on my fork and installs work great on both Alpine and Ubuntu.

I made a few small small tweaks that I have kicked off a build for. By the time anybody sees this, hopefully the following command is good to go if you want to test everything yourself:

curl -sSL https://raw.githubusercontent.com/EverlastingBugstopper/rover/v0.1.1-test.10/installers/binstall/scripts/nix/install.sh | sh

Cargo.toml Show resolved Hide resolved
src/error/metadata/suggestion.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🎉 new commands, flags, functionality, and improved error messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants