-
Notifications
You must be signed in to change notification settings - Fork 273
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
Configuration: Update default web endpoints, and make them configurable #1718
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Nice work!
I think the helm chart will need to be updated to reflect these changes. At least the health check stuff and I expect a lot of internal yaml attribute chasing will need to be updated. Let me know if you want me to work on the helm stuff.
Not sure why the CI fails on linux, and just on linux, rerunning the job Edit: it just passed Oo |
@@ -120,52 +165,57 @@ where | |||
}) | |||
} | |||
|
|||
fn ensure_listenaddrs_consistency( |
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.
could there be a comment here explaining the goal of this function?
|
||
#[tokio::test] | ||
#[should_panic( | ||
expected = "Failed to create server factory: DifferentListenAddrsOnSamePort(127.0.0.1, 0.0.0.0, 4000)" |
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.
what's the reason behind this? Do we consider that a sandbox with a different IP but same port would be a misconfiguration? What about this:
- graphql server listening on
0.0.0.0:4000
- sandbox listening on
<IP accessible only from the internal network>:4000
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 want the test to fail if two different listenaddrs want to bind to the same port. This would be a security issue (binding to 127.0.0.1:4000 and 0.0.0.0:4000 would effectively mean the 127.0.0.1 endpoint is accessible from WAN)
The reason why this test fails this way is because we're using the default graphql endpoint (127.0.0.1:4000) and 0.0.0.0:4000 sandbox, which would "leak the graphql endpoint".
The example you have in mind is currently not supported (this would require more efforts like binding to 0.0.0.0:4000 and then manually "route" the connections according to the configuration, so we decided to not support it yet.
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 would be a security issue (binding to 127.0.0.1:4000 and 0.0.0.0:4000 would effectively mean the 127.0.0.1 endpoint is accessible from WAN)
It looks like I don't have the right understanding of this PR then. In which case could this happen? What would it look like in the configuration file?
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.
Let's pretend you wanna expose the graphql endpoint and the prometheus one on the same port:
sandbox:
listen: 0.0.0.0:4000
path: /
enabled: true # NOT MANDATORY?
telemetry:
metrics:
prometheus:
listen: 127.0.0.1:4000
path: /metrics
enabled: true
With this setup /metrics would be exposed to WAN AFAICT, which would be a security issue.
ensure_listenaddrs_consistency
makes sure the configuration doesn't have this, and raises an error if it's the case.
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.
Ok, so the way I imagined the feature was more aligned with this:
The example you have in mind is currently not supported (this would require more efforts like binding to 0.0.0.0:4000 and then manually "route" the connections according to the configuration, so we decided to not support it yet.
But since it is not implemented yet we can end up with a security issue, right?
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 can’t, because the router explicitly refuses to start if that’s the case
#[serde(default = "default_defer_support")] | ||
pub(crate) preview_defer_support: bool, | ||
fn default_health_check_listen() -> ListenAddr { | ||
SocketAddr::from_str("127.0.0.1:9090").unwrap().into() |
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.
wasn't the 9090 port supposed to be used only by the prometheus endpoint?
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.
I don't think so, the comment i ve worked from says otherwise
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.
Originally the health check was on the same port as the graphql server, that's why it was under the .well-known
path
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.
yes, this is an intentional breaking change, the goal is to not expose it to internet by default.
…use an add in use
Co-authored-by: Gary Pennington <gary@apollographql.com>
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.
Great work. I think this is a big improvement on what we had.
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.
To be able to run cargo xtask test
locally without killing my local router instance
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.
Great work!
Fixes #1500
Configuration: Update metrics and healthcheck web endpoints, and make them configurable (#1500)
The web endpoints exposed by the router listen to 127.0.0.1 by default, and the ports and paths for health check and prometheus have changed.
Here's the list of the endpoints exposed by the router:
While you could previously only customize the path for these endpoints, you can now customize the full IP address, PORT and PATH.
In order to enable this new feature, various
server
attributes such aslisten
,graphql_path
andlanding_page
moved to more relevant sections.Likewise,
introspection
andpreview_defer_support
have moved from theserver
section to thesupergraph
section:This previous configuration:
Now becomes:
By @o0Ignition0o in #1718