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

ROVER-286 Removing routing_url gives correct error message #2360

Open
wants to merge 6 commits into
base: jr/task/ROVER-280
Choose a base branch
from

Conversation

jonathanrainer
Copy link
Contributor

As per title, due to some particularly inconvenient handling of federation resolution subgraphs losing a routing_url while the LSP was running, or not having one to start with were causing us many problems. This is now resolved and I've run over the test suite we have and all tests are passing (with the exception of the --profile ones, which are a known issue).

Some comments are added throughout to explain the decisions taken.

There seems to have been a thought that a subgraph should be considered
added and removed if the `routing_url` changes. That is not a good idea
and is now reverted.
When we resolve our subgraphs we now use a default value rather
than erroring if the Routing URL is missing in two specific cases.
Otherwise we cannot boot the CompositionPipeline without all
routing_urls which goes against our requirement we be able to start
up even with a broken `supergraph.yaml`
@jonathanrainer jonathanrainer requested a review from a team as a code owner January 17, 2025 14:22
@svc-apollo-docs
Copy link
Collaborator

svc-apollo-docs commented Jan 17, 2025

⚠️ Docs preview not attached to branch

The preview was not built because the PR's base branch jr/task/ROVER-280 is not in the list of sources.

An Apollo team member can comment one of the following commands to dictate which branch to attach the preview to:

  • !docs set-base-branch main

Build ID: 009b3066610e3c762feaef65

Copy link
Contributor Author

@jonathanrainer jonathanrainer left a comment

Choose a reason for hiding this comment

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

Added a few comments to explain the more obscure parts

Comment on lines +48 to +51
let routing_url = unresolved_subgraph
.routing_url()
.clone()
.unwrap_or(String::from("UNKNOWN"));
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 change, and the similar one which removes ResolveSubgraphError::MissingRoutingUrl are made so that if the routing_url is missing in these two cases, when we come to resolve. We'll resolve with a junk value instead of erroring. Erroring at this point causes it to bubble up to the very top level of the composition pipeline, and that is fatal for the LSP early on. This junk value is not visible to users and as there is no value, and UNKNOWN is not a valid URL no traffic will be directed anywhere we don't want.

Furthermore once a user tries to correct this it will get overwritten with either a correct value, or an error will get thrown if they don't include a routing_url in the first place, so this strikes a balance between getting good behaviour even if the supergraph.yaml is broken and not having very complex error handling

Comment on lines +112 to +114
pub fn get_subgraph(&mut self, name: &str) -> Option<FullyResolvedSubgraph> {
self.subgraphs.get(name).cloned()
}
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 to enable us to get a copy of a subgraph from a live SupergraphConfig, then update its routing_url and put it back again, as update requires us to have the whole subgraph. I tried a version that used get_mut but this caused FileWatchers to be dropped amongst other things and debugging that seemed harder than just using this slightly more round-a-bout method

Comment on lines +130 to +133
None => {
debug!("Could not find subgraph '{}'", name);
continue
},
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 arm is really only included for completeness, as if this method is called there should be a subgraph otherwise it wouldn't be being called in the first place.

Comment on lines +100 to +103
/// A change to the watched subgraphs schema
SchemaChanged(SubgraphSchemaChanged),
/// A change to the watched subgraphs routing_url
RoutingUrlChanged(SubgraphRoutingUrlChanged),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Clippy complained about all of these having the same prefix so I made a slight change here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems that at some point I thought that the pair of name and routing_url should uniquely identify a subgraph but that's nonsense and changing this doesn't break anything so I'm planning on reverting this and leaving it.

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