Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into simon/limit-request-size
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Jun 1, 2023
2 parents 19f3491 + df80a34 commit 492b76d
Show file tree
Hide file tree
Showing 75 changed files with 4,182 additions and 2,728 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 2.1
# across projects. See https://circleci.com/orbs/ for more information.
orbs:
gh: circleci/github-cli@2.2.0
slack: circleci/slack@4.12.1
slack: circleci/slack@4.12.5

executors:
amd_linux_build: &amd_linux_build_executor
Expand All @@ -21,8 +21,8 @@ executors:
amd_linux_test: &amd_linux_test_executor
docker:
- image: cimg/base:stable
- image: cimg/redis:7.0.9
- image: jaegertracing/all-in-one:1.42.0
- image: cimg/redis:7.0.11
- image: jaegertracing/all-in-one:1.45.0
resource_class: xlarge
environment:
CARGO_BUILD_JOBS: 4
Expand Down
33 changes: 33 additions & 0 deletions .github/workflows/update_uplink_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Update Uplink Schema
run-name: ${{ github.actor }} is updating the Uplink schema 🚀
on:
workflow_dispatch:
schedule:
# On the 5 of every hour
- cron: '5 * * * *'
jobs:
Update-Uplink-Schema:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rover
run: |
curl -sSL https://rover.apollo.dev/nix/v0.14.1 | sh
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- name: Make changes to pull request
run: |
rover graph introspect https://uplink.api.apollographql.com/ | perl -pe 'chomp if eof' > ./apollo-router/src/uplink/uplink.graphql
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v5
with:
commit-message: Update Uplink schema
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: create-pull-request/uplink-schema-updates
add-paths: |
apollo-router/src/uplink/uplink.graphql
delete-branch: true
title: 'chore: Update Uplink schema'
body: |
This updates the copy of `uplink.graphql` which this repository relies on with the latest copy fetched via `rover graph introspect`.
168 changes: 162 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,166 @@ All notable changes to Router will be documented in this file.

This project adheres to [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html).

# [1.20.0] - 2023-05-31

## 🚀 Features

### Configurable histogram buckets for metrics ([Issue #2333](https://github.com/apollographql/router/issues/2333))

It is now possible to change the default bucketing for histograms generated for metrics:

```yaml title="router.yaml"
telemetry:
metrics:
common:
buckets:
- 0.05
- 0.10
- 0.25
- 0.50
- 1.00
- 2.50
- 5.00
- 10.00
- 20.00
```
By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/3098
## 🐛 Fixes
### Federation v2.4.7 ([Issue #3170](https://github.com/apollographql/router/issues/3170), [Issue #3133](https://github.com/apollographql/router/issues/3133))
This release bumps the Router's Federation support from v2.4.7 to v2.4.7, which brings in notable query planner fixes from [v2.4.7](https://github.com/apollographql/federation/releases/tag/%40apollo%2Fquery-planner%402.4.7). Of note from those releases, this brings query planner fixes that (per that dependency's changelog):
- Re-work the code use to try to reuse query named fragments to improve performance (thus sometimes improving query ([#2604](https://github.com/apollographql/federation/pull/2604)) planning performance)
- Fix a raised assertion error (again, with a message of form like `Cannot add selection of field X to selection set of parent type Y`).
- Fix a rare issue where an `interface` or `union` field was not being queried for all the types it should be.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/3185

### Set the global allocator in the library crate, not just the executable ([Issue #3126](https://github.com/apollographql/router/issues/3126))

In 1.19, Apollo Router [switched to use `jemalloc` as the global Rust allocator on Linux](https://github.com/apollographql/router/blob/dev/CHANGELOG.md#improve-memory-fragmentation-and-resource-consumption-by-switching-to-jemalloc-as-the-memory-allocator-on-linux-pr-2882) to reduce memory fragmentation. However, prior to this change this was only occurring in the executable binary provided by the `apollo-router` crate and [custom binaries](https://www.apollographql.com/docs/router/customizations/custom-binary) using the crate _as a library_ were not getting this benefit.

The `apollo-router` library crate now sets the global allocator so that custom binaries also take advantage of this by default. If some other choice is desired, the `global-allocator` Cargo [feature flag](https://doc.rust-lang.org/cargo/reference/features.html) can be disabled in `Cargo.toml` with:

```toml
[dependencies]
apollo-router = {version = "[…]", default-features = false}
```

Library crates that depend on `apollo-router` (if any) should also do this in order to leave the choice to the eventual executable. (Cargo default features are only disabled if *all* dependents specify `default-features = false`.)

By [@SimonSapin](https://github.com/SimonSapin) in https://github.com/apollographql/router/pull/3157

### Add `ca-certificates` to our Docker image ([Issue #3173](https://github.com/apollographql/router/issues/3173))

We removed `curl` from our Docker images to improve security, which meant that our implicit install of `ca-certificates` (as a dependency of `curl`) was no longer performed.

This fix reinstates the `ca-certificates` package explicitly, which is required for the router to be able to process TLS requests.

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3174

### Helm: Running of `helm test` no longer fails

Running `helm test` was generating an error since `wget` was sending a request without a proper body and expecting an HTTP status response of 2xx. Without the proper body, it expectedly resulted in an HTTP status of 400. By switching to using `netcat` (or `nc`) we will now check that the port is up and use that to determine that the router is functional.

By [@bbardawilwiser](https://github.com/bbardawilwiser) in https://github.com/apollographql/router/pull/3096

### Move `curl` dependency to separate layer in Docker image ([Issue #3144](https://github.com/apollographql/router/issues/3144))

We've moved `curl` out of the Docker image we publish. The `curl` command is only used in the image we produce today for the sake of downloading dependencies. It is never used after that, but we can move it to a separate layer to further remove it from the image.

By [@abernix](https://github.com/abernix) in https://github.com/apollographql/router/pull/3146

## 🛠 Maintenance

### Improve `cargo-about` license checking ([Issue #3176](https://github.com/apollographql/router/issues/3176))

From the description of this [cargo about PR](https://github.com/EmbarkStudios/cargo-about/pull/216), it is possible for `NOASSERTION` identifiers to be added when gathering license information, causing license checks to fail. This change uses the new `cargo-about` configuration `filter-noassertion` to eliminate the problem.

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3178



# [1.19.1] - 2023-05-26

## 🐛 Fixes

### Fix router coprocessor deferred response buffering and change JSON body type from Object to String ([Issue #3015](https://github.com/apollographql/router/issues/3015))

The current implementation of the `RouterResponse` processing for coprocessors forces buffering of response data before passing the data to a coprocessor. This is a bug, because deferred responses should be processed progressively with a stream of calls to the coprocessor as each chunk of data becomes available.

Furthermore, the data type was assumed to be valid JSON for both `RouterRequest` and `RouterResponse` coprocessor processing. This is also a bug, because data at this stage of processing was never necessarily valid JSON. This is a particular issue when dealing with deferred (when using `@defer`) `RouterResponses`.

This change fixes both of these bugs by modifying the router so that coprocessors are invoked with a `body` payload which is a JSON `String`, not a JSON `Object`. Furthermore, the router now processes each chunk of response data separately so that a coprocessor will receive multiple calls (once for each chunk) for a deferred response.

For more details about how this works see the [coprocessor documentation](https://www.apollographql.com/docs/router/customizations/coprocessor/).

By [@garypen](https://github.com/garypen) in https://github.com/apollographql/router/pull/3104

### Experimental: Query plan cache keys now include a hash of the query and operation name ([Issue #2998](https://github.com/apollographql/router/issues/2998))

> **Note**
> This feature is still _experimental_ and not recommended under normal use nor is it validated that caching query plans in a distributed fashion will result in improved performance.

The experimental feature for caching query plans in a distributed store (e.g., Redis) will now create a SHA-256 hash of the query and operation name and include that hash in the cache key, rather than using the operation document as it was previously.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/3101

### Federation v2.4.6 ([Issue #3133](https://github.com/apollographql/router/issues/3133))

This release bumps the Router's Federation support from v2.4.5 to v2.4.6, which brings in notable query planner fixes from [v2.4.6](https://github.com/apollographql/federation/releases/tag/%40apollo%2Fquery-planner%402.4.6). Of note from those releases, this brings query planner fixes that (per that dependency's changelog):

- Fix assertion error in some overlapping fragment cases. In some cases, when fragments overlaps on some sub-selections ([apollographql/federation#2594](https://github.com/apollographql/federation/pull/2594)) and some interface field implementation relied on sub-typing, an assertion error could be raised with a message of the form `Cannot add selection of field X to selection set of parent type Y` and this fixes this problem.

- Fix possible fragment-related assertion error during query planning. This prevents a rare case where an assertion with a ([apollographql/federation#2596](https://github.com/apollographql/federation/pull/2596)) message of the form `Cannot add fragment of condition X (runtimes: ...) to parent type Y (runtimes: ...)` could fail during query planning.

In addition, the packaging includes dependency updates for `bytes`, `regex`, `once_cell`, `tokio`, and `uuid`.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/3135

### Error redaction for subgraphs now respects _disabling_ it

This follows-up on the new ability to selectively disable Studio-bound error redaction which was released in https://github.com/apollographql/router/pull/3011 by fixing a bug which was preventing users from _disabling_ that behavior on subgraphs. Redaction continues to be on by default and both the default behavior and the explicit `redact: true` option were behaving correctly.

With this fix, the `tracing.apollo.errors.subgraph.all.redact` option set to `false` will now transmit the un-redacted error message to Studio.

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/3137

### Evaluate multiple keys matching a JWT criteria ([Issue #3017](https://github.com/apollographql/router/issues/3017))

In some cases, multiple keys could match what a JWT asks for (both the algorithm, `alg`, and optional key identifier, `kid`). Previously, we scored each possible match and only took the one with the highest score. But even then, we could have multiple keys with the same score (e.g., colliding `kid` between multiple JWKS in tests).

The improved behavior will:

- Return a list of those matching `key` instead of the one with the highest score.
- Try them one by one until the JWT is validated, or return an error.
- If some keys were found with the highest possible score (matching `alg`, with `kid` present and matching, too), then we only test those keys.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/3031

## 🛠 Maintenance

### chore(deps): `xtask/` dependency updates ([PR #3149](https://github.com/apollographql/router/pull/3149))

This is effectively running `cargo update` in the `xtask/` directory (our directory of tooling; not runtime components) to bring things more up to date.

This changeset takes extra care to update `chrono`'s features to remove the `time` dependency which is impacted by [CVE-2020-26235](https://nvd.nist.gov/vuln/detail/CVE-2020-26235), resolving a moderate severity which was appearing in scans. Again, this is not a runtime dependency and there was no actual/known impact to any users.

By [@abernix](https://github.com/abernix) in https://github.com/apollographql/router/pull/3149

### Improve testability of the `state_machine` in integration tests

We have introduced a `TestRouterHttpServer` for writing more fine-grained integration tests in the Router core for the behaviors of the state machine.

By [@o0Ignition0o](https://github.com/o0Ignition0o) in https://github.com/apollographql/router/pull/3099

# [1.19.0] - 2023-05-19

> **Note**
> This release focused a notable amount of effort on improving both CPU usage and memory utilization/fragmentization. Our testing and pre-release feedback has been overwhelmingly positive. 🙌
> This release focused a notable amount of effort on improving both CPU usage and memory utilization/fragmentization. Our testing and pre-release feedback has been overwhelmingly positive. 🙌

## 🚀 Features

Expand All @@ -29,9 +185,9 @@ By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/p

## 🐛 Fixes

### Prevent span attributes from being formatted to write logs
### Prevent span attributes from being formatted to write logs

We do not show span attributes in our logs, but the log formatter still spends time formatting them to a string, even when there will be no logs written for the trace. This adds the `NullFieldFormatter` that entirely avoids formatting the attributes to improve performance.
We do not show span attributes in our logs, but the log formatter still spends time formatting them to a string, even when there will be no logs written for the trace. This adds the `NullFieldFormatter` that entirely avoids formatting the attributes to improve performance.

By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/pull/2890

Expand All @@ -41,7 +197,7 @@ This release bumps the Router's Federation support from v2.4.2 to v2.4.5, which

- Improves the heuristics used to try to reuse the query named fragments in subgraph fetches. Said fragment will be reused ([apollographql/federation#2541](https://github.com/apollographql/federation/pull/2541)) more often, which can lead to smaller subgraph queries (and hence overall faster processing).
- Fix potential assertion error during query planning in some multi-field `@requires` case. This error could be triggered ([#2575](https://github.com/apollographql/federation/pull/2575)) when a field in a `@requires` depended on another field that was also part of that same requires (for instance, if a field has a `@requires(fields: "id otherField")` and that `id` is also a key necessary to reach the subgraph providing `otherField`).

The assertion error thrown in that case contained the message `Root groups (...) should have no remaining groups unhandled (...)`

By [@abernix](https://github.com/abernix) in https://github.com/apollographql/router/pull/3107
Expand All @@ -65,7 +221,7 @@ By [@Geal](https://github.com/Geal) in https://github.com/apollographql/router/p
If you were using local schema or config then previously the Router was performing blocking IO in an async thread. This could have caused stalls to serving requests.
The Router now uses async IO for all config and schema reloads.

Fixing the above surfaced an issue with the experimental `force_hot_reload` feature introduced for testing. This has also been fixed and renamed to `force_reload`.
Fixing the above surfaced an issue with the experimental `force_hot_reload` feature introduced for testing. This has also been fixed and renamed to `force_reload`.

```diff
experimental_chaos:
Expand Down Expand Up @@ -99,7 +255,7 @@ Adds an integration test that iterates over `./examples` looking for `.yaml` fil

By [@EverlastingBugstopper](https://github.com/EverlastingBugstopper) in https://github.com/apollographql/router/pull/3097

### Improve memory fragmentation and resource consumption by switching to `jemalloc` as the memory allocator on Linux ([PR #2882](https://github.com/apollographql/router/pull/2882))
### Improve memory fragmentation and resource consumption by switching to `jemalloc` as the memory allocator on Linux ([PR #2882](https://github.com/apollographql/router/pull/2882))

Detailed memory investigation revealed significant memory fragmentation when using the default allocator, `glibc`, on Linux. Performance testing and flame-graph analysis suggested that using `jemalloc` on Linux would yield notable performance improvements. In our tests, this figure shows performance to be about 35% faster than the default allocator, on account of spending less time managing memory fragmentation.

Expand Down
Loading

0 comments on commit 492b76d

Please sign in to comment.