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

expose the custom endpoints from RouterServiceFactory #1402

Merged
merged 5 commits into from
Jul 15, 2022

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Jul 15, 2022

Fix #1400

the StateMachine was holding a copy of the plugin list to extract the
custom endpoints registered by some of the plugins, like the prometheus
endpoint.

With the Tower refactoring, that plugin list was empty so the endpoints
were not registered.

This commit makes sure that the plugins are only held byt the
RouterServiceFactory instance, and that it implements a method to return
the list of endpoints, that can be used by the StateMachine instance

the StateMachine was holding a copy of the plugin list to extract the
custom endpoints registered by some of the plugins, like the prometheus
endpoint.

With the Tower refactoring, that plugin list was empty so the endpoints
were not registered.

This commit makes sure that the plugins are only held byt the
RouterServiceFactory instance, and that it implements a method to return
the list of endpoints, that can be used by the StateMachine instance
@github-actions

This comment has been minimized.

@Geal Geal requested review from garypen and abernix July 15, 2022 09:51
Copy link
Contributor

@garypen garypen left a comment

Choose a reason for hiding this comment

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

Looks good. A few small NITS (which may be ignored) to reduce use noise and perhaps improve readability.

apollo-router/src/state_machine.rs Outdated Show resolved Hide resolved
apollo-router/src/state_machine.rs Outdated Show resolved Hide resolved
apollo-router/src/state_machine.rs Outdated Show resolved Hide resolved
Co-authored-by: Gary Pennington <[email protected]>
@Geal Geal enabled auto-merge (squash) July 15, 2022 10:19
Copy link
Member

@abernix abernix left a comment

Choose a reason for hiding this comment

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

LGTM. One changelog consistency thing. I have a more meta question about why the test here wasn't failing, but that can be answered elsewhere (the answer is probably state machines):

let http_req_prom = http_ext::Request::fake_builder()
.uri(Uri::from_static(
"http://localhost:4000/plugins/apollo.telemetry/prometheus",
))
.method(Method::GET)
.body(Bytes::new())
.build()
.unwrap();
let resp = handler.oneshot(http_req_prom).await.unwrap();
assert_eq!(resp.status(), StatusCode::OK);

NEXT_CHANGELOG.md Outdated Show resolved Hide resolved
### Expose the custom endpoints from RouterServiceFactory [PR #1402](https://github.com/apollographql/router/pull/1402)

Plugin HTTP endpoints registration was broken during the Tower refactoring. We now make sure that the list
of endpoints is generated from the `RouterServiceFactory` instance.
Copy link
Member

Choose a reason for hiding this comment

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

❤️ (`<3`)

@Geal Geal disabled auto-merge July 15, 2022 10:28
Co-authored-by: Jesse Rosenberger <[email protected]>
@Geal
Copy link
Contributor Author

Geal commented Jul 15, 2022

LGTM. One changelog consistency thing. I have a more meta question about why the test here wasn't failing, but that can be answered elsewhere (the answer is probably state machines):

it was testing the plugin HTTP handlers directly, but here the issue was in how the state machine codes was taking those handlers and setting them up in axum

@Geal Geal enabled auto-merge (squash) July 15, 2022 10:42
@Geal Geal merged commit d06c0c3 into main Jul 15, 2022
@Geal Geal deleted the geal/expose-endpoints-from-routerservicefactory branch July 15, 2022 11:00
@o0Ignition0o o0Ignition0o added this to the v0.12.0 milestone Jul 18, 2022
@o0Ignition0o o0Ignition0o mentioned this pull request Jul 18, 2022
o0Ignition0o added a commit that referenced this pull request Jul 18, 2022
# [0.12.0] - 2022-08-18

## ❗ BREAKING ❗

### Move `experimental.rhai` out of `experimental` [PR #1365](#1365)

You will need to update your YAML configuration file to use the correct name for `rhai` plugin.

```diff
- plugins:
-   experimental.rhai:
-     filename: /path/to/myfile.rhai
+ rhai:
+   scripts: /path/to/directory/containing/all/my/rhai/scripts (./scripts by default)
+   main: <name of main script to execute> (main.rhai by default)
```

You can now modularise your rhai code. Rather than specifying a path to a filename containing your rhai code, the rhai plugin will now attempt to execute the script specified via `main`. If modules are imported, the rhai plugin will search for those modules in the `scripts` directory. for more details about how rhai makes use of modules, look at [the rhai documentation](https://rhai.rs/book/ref/modules/import.html).

The simplest migration will be to set `scripts` to the directory containing your `myfile.rhai` and to rename your `myfile.rhai` to `main.rhai`.

By [@garypen](https://github.com/garypen) in #1365

## 🐛 Fixes

### The opentelemetry-otlp crate needs a http-client feature [PR #1392](#1392)

The opentelemetry-otlp crate only checks at runtime if a HTTP client was added through
cargo features. We now use reqwest for that.

By [@Geal](https://github.com/geal) in #1392

### Expose the custom endpoints from RouterServiceFactory ([PR #1402](#1402))

Plugin HTTP endpoints registration was broken during the Tower refactoring. We now make sure that the list
of endpoints is generated from the `RouterServiceFactory` instance.

By [@Geal](https://github.com/geal) in #1402

## 🛠 Maintenance

### Dependency updates [PR #1389](#1389) [PR #1394](#1394) [PR #1395](#1395)

Dependency updates were blocked for some time due to incompatibilities:

- #1389: the router-bridge crate needed a new version of `deno_core` in its workspace that would not fix the version of `once_cell`. Now that it is done we can update `once_cell` in the router
- #1395: `clap` at version 3.2 changed the way values are extracted from matched arguments, which resulted in panics. This is now fixed and we can update `clap` in the router and related crates
- #1394: broader dependency updates now that everything is locked
- #1410: revert tracing update that caused two telemetry tests to fail (the router binary is not affected)

By [@Geal](https://github.com/Geal) in #1389 #1394 #1395 and [@o0Ignition0o](https://github.com/o0Ignition0o) in #1410
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.

Prometheus endpoint 404-ing when enabled
4 participants