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

Phil/workspace deps #691

Merged
merged 9 commits into from
Sep 27, 2022
Merged

Phil/workspace deps #691

merged 9 commits into from
Sep 27, 2022

Conversation

psFried
Copy link
Member

@psFried psFried commented Sep 23, 2022

Description:

Changes our Rust dependency configuration to use Workspace Inheritance. This is a very new feature, so this PR also increases the minimum supported rust version to 1.64 (the most recent stable release). All dependencies are now declared in in the root Cargo.toml file. Individual workspace crates now simply reference the workspace dependency using, for example, serde_json = { workspace = true }.

My initial position on how we should use this feature is to declare all dependencies in the root Cargo.toml. The rationale being that we should default to always ensuring that a single version of each dependency is used across all the crates in our workspace. If this becomes untenable, then we can revisit it later.

This also updates all dependencies to use explicit version requirements. There are no longer any version = "*" dependencies. Turns out that it's really a pain to use a crate having * dependencies as a dependency in an external crate. For example, depending on a workspace crate from another repo. Explicit version requirements make this much more robust. The * dependencies were also a barrier to us ever publishing crates to crates.io, so removing them seemed to move us in the right direction.

Many dependencies were updated as part of this, but not all of them. Notable updates are:

  • tonic, prost, and the rest of the grpc gang: This brought some changes to the generated protobuf code. This included a cosmetic change to comment formatting that caused some code comments to get interpreted as code blocks, which then caused doc tests to fail. I disabled doc tests in proto-gazette to work around this.
  • insta: Had a breaking change to how serde_json::value::RawValues are serialized. IMO the new behavior is preferable, but it did require updating a bunch of snapshots. issue here

Finally, I also made a few updates to the build in an attempt to reduce build times, which had gotten out of hand after the incorporate of animated-carnival:

  • Allow catalog-test and end-to-end test to skip re-building stuff, and to only rely on the binaries that were output from the first two build stages.
  • Rename some Makefile targets to clarify what they're building within the context of our now multi-platform build process.
  • Group related outputs into a single cargo build command with multiple -p arguments instead of invoking cargo build separately for each desired output.

There's definitely lots more room for improvement with builds, but I don't want to spend a ton of time on build right now. Also, there seems to be a ton of variability of timing run-to-run in GH actions, so we may benefit from some additional time to characterize the build performance as it is.


This change is Reviewable

@psFried psFried force-pushed the phil/workspace-deps branch from 358da29 to 5d0ffb8 Compare September 23, 2022 23:15
Changes all Rust crates to use workspace inheritance for specifying
dependencies. Also updates some dependencies in order to standardize on
the same versions of all direct dependencies across all crates.
@psFried psFried force-pushed the phil/workspace-deps branch from 5d0ffb8 to f0cd66b Compare September 25, 2022 19:01
The latest Rust is needed in order to use workspace inheritance.
The Go version was just kinda old and didn't match the version in the
other stage.
Update insta, and updates a failing test due to breaking serialization
change. Issue for the serialization change: mitsuhiko/insta#290
@psFried psFried force-pushed the phil/workspace-deps branch 3 times, most recently from a1f4425 to 9ce3057 Compare September 26, 2022 17:16
Adds a `SKIP_BUILD` option to the Makefile for the `catalog-test` and
`end-to-end-test` tasks, to allow re-building of binaries to be skipped
during CI.

Also install protoc during Mac builds.
@psFried psFried force-pushed the phil/workspace-deps branch from 9ce3057 to 865fe4f Compare September 26, 2022 17:55
@psFried psFried marked this pull request as ready for review September 26, 2022 19:22
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

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

Some nitpicks, but overall looks good.

I ran this locally to make sure it would build for me, and it seems like it does. Previously I could run make package and it would (re-)build everything I needed. Now, it seems that has changed, and to get an equivalent "rebuild everything if needed" I need to use make linux-binaries. This seems fine (although the nomenclature leaves something to be desired when building on mac), but will take a little bit of adjustment.

Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Cargo.toml Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
crates/flowctl/Cargo.toml Outdated Show resolved Hide resolved
Updates all Cargo.toml files to inherit most of their `package`
properties from the workspace root. For the most part, this only changes
metadata. But one notable change is that some crates were upgraded from
rust edition 2018 to 2021. There were no observed compile or test
failures as a result. Now all crates are using the 2021 edition, which
is the most recent one.
@psFried
Copy link
Member Author

psFried commented Sep 26, 2022

@williamhbaker thanks for the review. I took care of all the leftover comments, which had all been resolved.

to get an equivalent "rebuild everything if needed" I need to use make linux-binaries. This seems fine (although the nomenclature leaves something to be desired when building on mac), but will take a little bit of adjustment.

Yeah, you're correct that linux-binaries is the intended replacement for package. The naming was chosen because I'd assumed that the output would always be only linux binaries. But now that I take another look, it seems like we don't actually supply an explicit --target argument when building linux-gnu-binaries. Are you getting native mac binaries when you run make linux-binaries? I think I'll try to get my mac setup to test this locally (I've been meaning to, anyway), but it's seeming like we should have a simple and direct way of building this stuff on mac.

@williamhbaker
Copy link
Member

Are you getting native mac binaries when you run make linux-binaries?

For the most part...the musl ones obviously are not:

agent:                 Mach-O 64-bit executable arm64
etcd:                  Mach-O 64-bit executable arm64
etcdctl:               Mach-O 64-bit executable arm64
fetch-open-graph:      Mach-O 64-bit executable arm64
flow-connector-proxy:  ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flow-network-tunnel:   ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flow-parser:           ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flow-schema-inference: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flow-schemalate:       ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flowctl:               ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, with debug_info, not stripped
flowctl-admin:         Mach-O 64-bit executable arm64
flowctl-go:            Mach-O 64-bit executable arm64
gazette:               Mach-O 64-bit executable arm64
sops:                  Mach-O 64-bit executable arm64

It's not immediately clear to me why flowctl would need to be a musl binary?

@psFried psFried force-pushed the phil/workspace-deps branch from 9059c45 to e5f6a18 Compare September 27, 2022 14:33
@psFried psFried force-pushed the phil/workspace-deps branch from e5f6a18 to 7d59d4e Compare September 27, 2022 15:40
@psFried
Copy link
Member Author

psFried commented Sep 27, 2022

It's not immediately clear to me why flowctl would need to be a musl binary?

It doesn't need to be. It's basically just away to make it easy to install on a variety of linux systems. If you link against glibc, then the binary can only run on systems having a glibc version that's at least as new as the version it was built with. We kinda need to statically link some other dependencies, like librocksdb, since the versions in most apt/yum repositories aren't built with the RTTI feature. So it kinda just made sense to statically link the whole thing, and that way installation can be as simple as copying the binary to your local system and putting it on your PATH.

That said, if there was a good alternative to linux app packaging, then it might be worth moving to at some point. It's a little unfortunate to have to build some things with musl and others with glibc, and it'd be nice if we could just build everything with one or the other. I'm leaving that for a future exercise, though.

@psFried psFried merged commit aa8fd12 into master Sep 27, 2022
@psFried psFried deleted the phil/workspace-deps branch September 27, 2022 17:06
@oliviamiannone oliviamiannone added the docs complete / NA No (more) doc work related to this PR label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs complete / NA No (more) doc work related to this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants