Repository navigation
fix(web): keep the /graphql proxy when graphql starts after the indexer - #17
Merged
Merged
Conversation
Mux() resolved the GraphQL upstream once at startup and skipped the proxy if the name did not resolve yet. After a host reboot Docker starts every container at once, so the indexer could come up before its graphql container and serve 404 on /graphql until someone restarted it. The private-address check now runs on every connection instead: the proxy is always registered, a not-yet-running upstream gets a 502 for that request, and the proxy works as soon as the upstream resolves. The dialer connects to the vetted IP itself, so the DNS answer cannot change between the check and the connect. A literal public IP is still refused at startup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#Closes MAG-4953
Jira ticket: MAG-4953
Summary
Mux()resolved the GraphQL upstream once, at startup. If the name didn't resolve yet, it loggedgraphql.upstream rejected, skipping proxyand never registered/graphql. After a host reboot Docker starts every container at once, so the indexer can come up before itsgraphqlcontainer. It then answers 404 on/graphqluntil someone restarts it.privateDialContext):HTTP(S)_PROXY.parseProxyUpstreamstill rejects bad schemes, a missing host and literal public IPs at startup. A hostname is no longer resolved there.Test plan
go build ./... && go vet ./... && go test ./...all pass.internal/web/server_test.go:TestParseProxyUpstream: an unresolvable hostname is accepted;ftp://, a missing host,8.8.8.8and169.254.169.254are rejected.TestPrivateDialContextRefusesPublicAddresses: public and link-local addresses are refused at dial time.TestGraphQLProxyRegisteredWhenUpstreamDoesNotResolve:/graphqlanswers 502, not 404.TestGraphQLProxyRecoversWhenUpstreamStarts: 502 while the upstream is down, then 200 once it listens, with no restart.main'sserver.go,TestParseProxyUpstreamandTestGraphQLProxyRegisteredWhenUpstreamDoesNotResolvefail. The second fails with/graphql status = 404, the exact symptom.