-
Notifications
You must be signed in to change notification settings - Fork 85
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(compose): when --output
is used, use --output
in supergraph bin
#2045
Conversation
ab80131
to
6bebbfa
Compare
6bebbfa
to
bc76c80
Compare
bc76c80
to
f169d05
Compare
src/utils/supergraph_config.rs
Outdated
// WARNING: this is current behavior, we might switch it to respect the target | ||
#[case::no_remote_and_local_with_target( | ||
TestCase::NoRemoteLocalWithTarget, | ||
// Target is fed two because local has fed one | ||
Some(FederationVersion::LatestFedTwo), | ||
// Expected because target | ||
// WARNING: note that this isn't the target | ||
FederationVersion::LatestFedOne | ||
)] |
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.
pay special attention to this
22abd9a
to
2383407
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.
All in all this looks great, but I think we should correct the anomalous behaviour because:
a) I doubt anyone is relying on it doing that since it's a pretty new feature
b) It seems a lot more intuitive that it takes the version that's specified in the local version if we have one
Further, just wanted to check this ties up with the work @dotdat did around precedence of all these version, want to make sure we don't regress things there
src/utils/supergraph_config.rs
Outdated
// WARNING: this ignores the target fed version; should we ignore it? | ||
(None, Some(local_config)) => Some(local_config), |
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.
This is an oversight, I feel like the expected behaviour is that if you've given us a local file that has a version in it then we should respect that and not ignore it
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.
Yeah, I think there is an oversight here in that local_config
isn't guaranteed to have a federation_version. This block should do something like:
if local_config.get_federation_version().is_none() {
local_config.set_federation_version(target_federation_version.unwrap_or(FederationVersion::LatestFedTwo));
}
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.
Additionally, we should probably work towards having a refined type that guarantees a federation version.
// If it was, we use a file in the supergraph binary; this cuts down the overall time | ||
// it takes to do composition when we're working on really large compositions, but it | ||
// carries with it the assumption that stdout is superfluous | ||
Some(filepath) => { | ||
Command::new(&exe) | ||
.args(["compose", yaml_path.as_ref(), filepath.as_ref()]) | ||
.output() | ||
.context("Failed to execute command")?; |
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.
We should check the version of composition and return a useful error if the user tries to use the new option with a too-old version of composition. Otherwise, they'll get a confusing message, since it's really not on them to know that we're passing through the option to another binary.
In fact, it might be even better to support the new option for older compositions, and we just redirect the output ourselves instead of passing through the option?
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.
ahh, smart! I added a check for supergraph binary version and am ignoring the flag when it's lower than 2.9.0
since this isn't a customer-requested feature, I'm going to punt on supporting older compositions by adding more logic--we can always add it later if/when folks want it
58c7000
to
24a5530
Compare
# [0.26.1] - 2024-09-04 ## 🚀 Features - **Respect the use of `--output` flag in the supergraph binary - @aaronArinder PR #2045** In testing to attempt to reduce the runtime of `supergraph compose` we noticed that a very large proportion of the time spent (in the case of large supergraphs) was spent printing the result to `stdout`. With this change we add an `--output` flag to the `supergraph` binary which means this time can be reduced significantly, leading to much faster compositions. - **Add `--license` flag to `rover dev` - @loshz PR #2078** Adds the ability to pass along an offline enterprise licence to the router when running `rover dev` - **Remove Rayon and reduce usage of Crossbeam - @jonathanrainer PR #2081** Now that `rover` has transitioned to using an asynchronous runtime we don't need to use Rayon any more. This also resolves a bug whereby `rover dev` could lock up if passed a `supergraph.yaml` file with lots of subgraphs in. - **Introduce new print macros - @loshz PR #2090** Adds three new macros to the codebase so that we can still visually distinguish between INFO, WARNING and ERROR log lines without the use of emoji - **Use new print macros in place of emoji - @loshz PR #2096** Updates the locations that previously used emoji to utilise the new macros defined in the previous PR ## 🐛 Fixes - **Stop Windows Installer failing if whitespace is accidentally passed to the `rover install` command - @jonathanrainer PR #1975** In some situations it was possible for whitespace to be passed to the `rover install` command which then caused the installer to fail. A guard has now been added to strip whitespace out before it is passed to the install command. ## 🛠 Maintenance - **Move CI to using newly create Ubuntu images - @jonathanrainer PR #2080** CircleCI is removing support for older Ubuntu machine images, this brings us up to date but does **not** change any of our `glibc` support etc. - **Add check for aarch-64-unknown-linux-musl to installers - @loshz PR #2079** - **Update node.js packages - @jonathanrainer PR #2070** Includes `eslint` to v9.9.1 and `node` to 20.17.0 - **Update `node` CircleCI orb to v5.3.0 - @jonathanrainer PR #2071** - **Update `apollographql/federation-rs` to v2.9.0 - @jonathanrainer PR #1983** - **Update `apollographql/router` to v1.52.1 - @jonathanrainer PR #2077** - **Update `node` Docker Image to v20.17.0 - @jonathanrainer PR #2072** - **Update `apollographql/router` to v1.53.0 - @jonathanrainer PR #2084** - **Update `npm` to v10.8.3 - @jonathanrainer PR #2091** - **Update `slackapi/slack-github-action` to v1.27.0 - @jonathanrainer PR #2092** - **Update `node` CircleCI orb to v6.1.0 - @jonathanrainer PR #2093** - **Fix some bugs in the smoke tests - @jonathanrainer PR #2094** ## 📚 Documentation - **Add `cloud config` docs - @loshz PR #2066**
In Rover v2.6.1 (#2045) we added some logic to disable the `--output` flag and print a warning when the federation version is less than 2.9. Due to a precedence error, the warning also prints when the federation version is a 2.x version less than 2.9 and the `--output` flag is *not* provided. The only negative effect is a confusing error being printed, as `output_file = None` is a no-op in this case. This PR removes the misleading error.
}), | ||
// When the `--output` flag is used, we need a supergraph binary version that is at least | ||
// v2.9.0. We ignore that flag for composition when we have anything less than that | ||
if output_file.is_some() && exact_version.major < 2 |
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.
Looks like there's a precedence error here that can lead to the warning being printed when it shouldn't (but no other negative effects). Fixed in #2100
…ed (#2100) In Rover v2.6.1 (#2045) we added some logic to disable the `--output` flag and print a warning when the federation version is less than 2.9. Due to a precedence error, the warning also prints when the federation version is a 2.x version less than 2.9 and the `--output` flag is *not* provided. The only negative effect is a confusing error being printed, as `output_file = None` is a no-op in this case.
…ed (#2100) In Rover v2.6.1 (#2045) we added some logic to disable the `--output` flag and print a warning when the federation version is less than 2.9. Due to a precedence error, the warning also prints when the federation version is a 2.x version less than 2.9 and the `--output` flag is *not* provided. The only negative effect is a confusing error being printed, as `output_file = None` is a no-op in this case.
--output
works as expected because we have tests for it; this change uses supergraph's--output
flag, but there's no way (that I can find) to test the presence/absence of its output (which suggests the real heart of this change: quieting down the supergraph binary when doing composition by not dumping it to stdout)