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(gateway): Update managed federation to fetch "cloud config" #458

Merged
merged 39 commits into from
Mar 17, 2021

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Feb 9, 2021

This PR moves the gateway over to a simplified startup and updating mechanism in managed mode. With the gateway now able to consume CSDL as input, it's no longer necessary for the gateway to perform a series of fetches in order to collect each service's partial SDL and do composition on the fly.

In order to take full advantage of this capability, we will serve CSDL straight to the gateway rather than all of the individual partials.

This feature is being implemented as opt-in only for now, and should not be used by the general public. The means to opt-in is by providing appropriate configuration by either defining:
Via gateway configuration: experimental_schemaConfigDeliveryEndpoint: string OR
Via env var: APOLLO_SCHEMA_CONFIG_DELIVERY_ENDPOINT

Related prior work in preparation for this PR:
#278
#440

Note to the reviewer: this PR currently includes unrelated work (gateway stop functionality) which is already addressed in #452. Any stop related code in this PR can effectively be ignored since it'll be replaced by @glasser 's implementation once it lands.
Resolved.

TODO:

  • Align with @glasser 's recent work on stop behavior (simplifies the scope of this PR)
  • Internal testing using latest managed mode in our infrastructure
  • Finalize / productionize our new CSDL delivery mechanism

Final TODO is no longer a requirement since new delivery mechanism is opt-in, meaning we can ship this with no effect for our users for now.

@glasser
Copy link
Member

glasser commented Feb 11, 2021

FYI the stop stuff is on main (and is released as v0.23.0) — hope that helps!

@glasser
Copy link
Member

glasser commented Feb 11, 2021

Should I wait until that is done before I review? Also is this based on the newest version of the join/core spec, or is this just about changing how we talk to managed federation?

@abernix abernix changed the title feat(gateway): Update managed federation to use CSDL feat(gateway): Update managed federation to fetch "cloud config" Feb 11, 2021
This is mostly a fairly large update / revamp to the networkRequests
test file. Previously skipped /flaky tests are now up-to-date and
functioning as expected!

Some smaller changes were made to the gateway: i.e. the stop()
function was updated to actually do something. It doesn't stop the
gateway process or even from serving requests, but it does stop it
from polling. This behavior was needed for the sake of testing so that
gateways still running in tests didn't overpoll and ruin network
mocks.

^additional commentary on above: this was only my suspicion and my
changes seem to have resolved the issue. Though I don't fully
understand why this wasn't a problem in the first place - or maybe
it was and was causing the flakiness in the past? I don't know.
@trevor-scheer
Copy link
Member Author

trevor-scheer commented Feb 11, 2021

@glasser the stop work is integrated now. I think there's a little bit of cleanup left for me to do here but it's definitely ready for a first pass!

Nothing to do with core / join yet.

@trevor-scheer trevor-scheer marked this pull request as draft February 12, 2021 18:14
Copy link
Contributor

@jsegaran jsegaran left a comment

Choose a reason for hiding this comment

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

What is our plan for releasing this change? I think it would break any http caching solutions our users use or ip/url based firewalls.

gateway-js/src/loadCsdlFromStorage.ts Show resolved Hide resolved
gateway-js/src/config.ts Show resolved Hide resolved
gateway-js/src/index.ts Outdated Show resolved Hide resolved
gateway-js/src/index.ts Show resolved Hide resolved
gateway-js/src/index.ts Show resolved Hide resolved
gateway-js/src/index.ts Outdated Show resolved Hide resolved
gateway-js/src/index.ts Outdated Show resolved Hide resolved
gateway-js/src/loadCsdlFromStorage.ts Show resolved Hide resolved
gateway-js/src/index.ts Show resolved Hide resolved
AUTHENTICATION_FAILED = 'AUTHENTICATION_FAILED',
ACCESS_DENIED = 'ACCESS_DENIED',
UNKNOWN_REF = 'UNKNOWN_REF',
RETRY_LATER = 'RETRY_LATER',
Copy link
Member

Choose a reason for hiding this comment

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

Should we handle this retry later specially?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, though it sounds like Gravity has some changes in the works and I'm unsure what these errors are going to look like. I'm going to hold off for now and see if this concept even still exists in the next iteration.

gateway-js/src/index.ts Show resolved Hide resolved
* Don't log and rethrow an error which is already handled further up
* Include original error message and originating service in health check error message
@trevor-scheer trevor-scheer marked this pull request as ready for review March 11, 2021 22:23
@trevor-scheer trevor-scheer requested review from glasser and removed request for pcarrier March 11, 2021 22:23
Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

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

Yeah this all basically looks good, with the only serious concerns being the env var vs option precedence and not wanting to use graphql-tag's unbounded cache (plus the csdl naming which you were planning to get to lately). Pretty sure clicking that green button will be easy on Monday, but I'm out for the weekend. Have a nice weekend!

gateway-js/src/loadCsdlFromStorage.ts Outdated Show resolved Hide resolved
gateway-js/src/loadCsdlFromStorage.ts Outdated Show resolved Hide resolved
gateway-js/src/loadCsdlFromStorage.ts Outdated Show resolved Hide resolved
benjaminjkraft added a commit to Khan/federation that referenced this pull request Mar 16, 2021
@trevor-scheer
Copy link
Member Author

@glasser I can't reply to PR review comment, but -
env var vs. config behavior: fcf5fc4
gql-tag reversion: 636fc1f

@trevor-scheer
Copy link
Member Author

trevor-scheer commented Mar 16, 2021

Why is it nullable? Is this something Gravity is going to fix?

Yes, I've requested it be non-nullable :)

Copy link
Member

@glasser glasser left a comment

Choose a reason for hiding this comment

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

ok:

  • typing fix you're working on already
  • quick test suggestion
  • comment deletion
  • request for comment-and-link-to-issue for extraneous parse call
  • concern about quality of errors which could be comment-and-link-to-issue as well

I'd click the green button now but we're both around and can get a last round of back-and-forth in quickly.

gateway-js/src/__tests__/integration/configuration.test.ts Outdated Show resolved Hide resolved
gateway-js/src/config.ts Outdated Show resolved Hide resolved
gateway-js/src/loadCsdlFromStorage.ts Outdated Show resolved Hide resolved
gateway-js/src/loadCsdlFromStorage.ts Outdated Show resolved Hide resolved
gateway-js/src/index.ts Show resolved Hide resolved
@trevor-scheer trevor-scheer merged commit ccc63c1 into main Mar 17, 2021
@trevor-scheer trevor-scheer deleted the trevor/fetch-csdl branch March 17, 2021 18:14
trevor-scheer added a commit that referenced this pull request Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants