Commit Graph

298 Commits (523fd0cabf73d712fb06011eebf7e76e391f9375)

Author SHA1 Message Date
wiedld daabe9663c chore(idpe-17434): make restrictive whitelist of chars accepted, for any NamespaceName 2023-04-21 16:36:00 -07:00
wiedld b870242ec7 chore(idpe-17434): remove utf8-percent encoding on v2 write path, such that it matches v1 writes and onCreate 2023-04-21 16:31:55 -07:00
wiedld 781d6c040d
fix: process query param for token, even when header is not present. (#7619)
* Move the or_else conditional out of the Some() chain
2023-04-21 17:44:59 +00:00
wiedld 1d2003d385
feat(idpe-17265): cst write authorization (#7527)
* feat(idpe-17265): authorization should occur as part of the single_tenant specific mod
* authz service is accessed only through the single_tenant mod handler
* authz service is wrapped in auth mod
* move auth integration test into auth mod
* push down the authorize() call into the query params parser call, in order to access query params in the extract_token
* provide configuration error when authz or single_tenant mode are not co-presented
* update authz e2e fixtures

* feat(idpe-17265): extract tokens based upon preferred ordering in spec, and write tests to verify behavior.

* chore(idpe-17265): update naming conventions for a unifying parser

* test: make MockAuthorizer have default, and add a test_delegate_to_authz for CST

* chore: record authz duration metric, and include in delegation test.

* chore: use authz terminology instead of auth_service

* chore: more explicit naming

* Revert "chore: record authz duration metric, and include in delegation test."

This reverts commit 05c36888ca7247b6953343d759a5185098fae679.

* refactor: extract_header_token versus the else condition

* refactor: make single_tenant mod and move auth within

* chore: make unreachable explicitly panic in the build

* test: make token values be const, to be consumed when MockAuthorizer is used

* test: use locking for calls_counter in test

* fix: add base64 encoding as expected for Basic header

* fix: merge conflict resolution. The AuthorizationHeaderExtension is now under the authz::http mod, which is a required feature for router package.

* chore: run rustfmt nightly with preferred import handling, on files with modified imports

* chore: code cleanup, to have minimal code needed
2023-04-19 15:28:10 +00:00
Dom Dwyer 03c5ea5488
feat(router): configurable RPC write message size
Provide a configuration item for the router (in RPC mode) that controls
the maximum outgoing RPC message size when communicating with an
Ingester.

Raises the maximum from the default 4MiB to 100MiB. This does not
increase exposure to memory-based DOS, as writes are size-limited by the
HTTP layer to 10MiB, preventing a user from submitting a write this
large (or larger!) across the RPC boundary.
2023-04-19 14:57:53 +02:00
Dom Dwyer cf38e3bae5
chore: use http in router authz deps
The router should be using the "http" feature - this prevents
crate-specific tests from compiling otherwise.
2023-04-19 14:57:53 +02:00
kodiakhq[bot] f8f57ceeec
Merge branch 'main' into dom/router-deps 2023-04-18 10:53:43 +00:00
Dom Dwyer f46a29aa42
refactor(router): remove unused deps
The Removes more unused dependencies in the router specifically.
2023-04-18 12:34:14 +02:00
Dom Dwyer 2b9a809de4
refactor: move HTTP authz helpers into authz
The "server_util" crate exists only to support HTTP authz operations, so
this commit moves it under the authz crate. This helper is gated by a
feature flag allowing callers to opt into this extra HTTP dependency
(disabled by default).
2023-04-18 12:30:56 +02:00
Dom Dwyer c5bb88e173
chore: remove unused dependencies
Some crates import dependencies they never use.
2023-04-18 12:07:13 +02:00
Carol (Nichols || Goulding) d60e4d5823
feat: Delete delete parsing code from router (#7573)
And return the "deletes unsupported" error sooner.

Co-authored-by: Dom <dom@itsallbroken.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-18 09:57:02 +00:00
wiedld ca492b09d2 fix(idpe-17449): accept content-encoding identity for the parseBody 2023-04-13 17:09:21 -07:00
dependabot[bot] e811a69a1e
chore(deps): Bump serde_json from 1.0.95 to 1.0.96 (#7535)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.95 to 1.0.96.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.95...v1.0.96)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-04-13 10:07:32 +00:00
kodiakhq[bot] 53ddca45d8
Merge branch 'main' into cn/remove-write-summary 2023-04-12 16:07:35 +00:00
Andrew Lamb 20e9c91866
refactor: Use workspace dependencies for `tonic`, `tonic-build`, etc (#7515)
* refactor: Use workspace dependencies for `tonic`, `tonic-build`, etc

* chore: Run cargo hakari tasks

---------

Co-authored-by: CircleCI[bot] <circleci@influxdata.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-12 16:07:19 +00:00
Carol (Nichols || Goulding) 6387a9576a
fix: Remove the write_summary crate and write info service 2023-04-12 11:31:23 -04:00
Carol (Nichols || Goulding) d025362ce0
fix: Remove old router 2023-04-12 10:15:48 -04:00
Fraser Savage dc6053bfba
refactor(router): Apply further code review changes, clean up docs 2023-04-12 14:40:02 +01:00
Fraser Savage 8a2b88398f
refactor(router): Apply suggestions from code review
Assert an invariant, document existing edge cases and a little cleanup.

Co-authored-by: Dom <dom@itsallbroken.com>
2023-04-12 14:12:12 +01:00
Fraser Savage a6ccb05caf
refactor(router): DML handler tests use helper fn to set-up NS cache 2023-04-11 16:47:48 +01:00
Fraser Savage 728b7293b9
feat(router): Use read-through namespace cache for NamespaceResolver
The NamespaceResolver was using its own very similar look-aside caching
to the DML handlers, this commit leverages the read-through cache
implementation to deduplicate more code and makes the read through
behavioural expectation explicit for namespace autocreation.
2023-04-11 15:38:18 +01:00
Fraser Savage d590d19e3b
feat(router): Use read-through NamespaceCache with DML handlers
This removes the look-aside cache from the retention_validation
and schema_validation DML handlers, instead setting up the new
NamespaceCache decorator and using that to handle cache misses.
2023-04-11 15:38:17 +01:00
Fraser Savage 0bb88dcd4f
refactor(router): Return Result from NamespaceCache, use GAT for Error
This commit refactors the NamespaceCache trait to return a result
instead of an option for calls to `get_schema()`, allowing callers and
decorators to differentiate between cache misses, namespaces not
existing and transient I/O errors. This allows implementations to
interact with backend catalog storage.
2023-04-11 15:38:17 +01:00
Fraser Savage 082e8db9ef
refactor(router): Make NamespaceCache an async_trait
In order to implement a read-through NamespaceCache
decorator the `get_cache()` call will need to interact
with async catalog methods, so this allows implementations
to call await within the `get_cache()` body.
2023-04-11 15:38:16 +01:00
Dom Dwyer 73d44ec9a1
Merge remote-tracking branch 'origin/main' into dom/req-mode-parsing 2023-04-11 13:34:52 +02:00
Martin Hilton d2585002fe
chore(authz): Change "namespace" to "database" (#7502)
Part of the wider effort to consistently use tht term "database"
for the user-facing terminology, update the authorization system.
Whilst this system is technically user-facing, it is unlikely many
users will see it. It is however new enough that the change is
relatively little effort.
2023-04-11 11:04:51 +00:00
wiedld 9a56d08ddc test: add namespace char validation tests, to highlight the current contracts for v1/v2 and MT/CST. Contracts will be iterated with followup issue 7489 2023-04-10 12:59:20 -07:00
wiedld 9288155ac4 test: add multi-tenant missing params test, invalid namespaceError test for v1 single tenant, and v2 single-tenant missing bucket should have consistent message. 2023-04-10 12:59:20 -07:00
Dom Dwyer 306bffb4b7 docs: fix comment
Copy/paste.
2023-04-10 12:59:20 -07:00
Dom Dwyer 7424ad62e1 test: multi-tenant write handler
Adds tests that drive the multi-tenant HTTP write request parser.

Note that in addition to these unit tests, there's still considerable
integration converge of the HTTP write endpoint in multi-tenant mode in
http.rs (test_write_handler!) that asserts the system is unchanged in
the "default" run-mode of multi-tenant.
2023-04-10 12:59:20 -07:00
Dom Dwyer 7fed2ba456 feat(router): single tenancy operational mode
Adds a single-tenant mode (CST) to the IOx routers.

Single-tenancy mode differs in two main ways:

    * V1 write endpoint is partially supported
    * V2 write endpoint ignores "org" parameter

The "normal" mode is "multi tenant" which is the default operational
mode, and all existing behaviour remains unchanged. Single tenant mode
can be enabled by specifying INFLUXDB_IOX_SINGLE_TENANCY=true.

Request parsing is delegated to two implementations of the
WriteParamExtractor trait, one each for CST and MT - the logic of each
"mode" is defined within these files and all other functionality is
common between the two.

This commit also renames some of the error types for clarity
(NoSpecified -> NoOrgBucketSpecified, other NotSpecified ->
NoQueryParams, etc).

Note: single tenant code requires testing
2023-04-10 12:59:20 -07:00
Dom Dwyer 9703719294 test(router): constify test namespace
Define the namespace as a const to make the purpose/magic clear.
2023-04-10 12:59:20 -07:00
Fraser Savage 9fcaee9ac9
Merge branch 'main' into savage/6824-update-namespace-service-limit-api-call 2023-04-05 14:52:44 +01:00
Fraser Savage b53b8c7d76
refactor(namespace): Flatten service protection limits in Namespace proto definition
This commit also cleans up the code formatting for the gRPC handler and
simplifies some of the gRPC handler tests for the new update service
limit API.
2023-04-05 14:46:30 +01:00
dependabot[bot] 66982f988b
chore(deps): Bump object_store from 0.5.5 to 0.5.6 (#7433)
Bumps [object_store](https://github.com/apache/arrow-rs) from 0.5.5 to 0.5.6.
- [Release notes](https://github.com/apache/arrow-rs/releases)
- [Changelog](https://github.com/apache/arrow-rs/blob/master/CHANGELOG-old.md)
- [Commits](https://github.com/apache/arrow-rs/commits)

---
updated-dependencies:
- dependency-name: object_store
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Dom <dom@itsallbroken.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-04-04 08:43:34 +00:00
Fraser Savage 3ad4cbe7a9
feat(router): Add grpc integration tests for namespace limit update
This adds additional testing coverage for updates to service protection
limits to a namespace, and how they affect subsequent writes that
exceed the limits.
2023-03-31 17:35:10 +01:00
Dom Dwyer d322791d12
refactor: tidy NamespaceName construction errors
There was a mix of different ways of returning errors - this commit
unifies them, adds some documentation to the returned errors, and
removes the capitalisation.

Errors should be lower-case so they compose nicely like this:
    "something failed: super important error: inner error"
rather than:
    "something failed: Super important error: Inner error"
2023-03-31 16:27:26 +02:00
Dom Dwyer d3bb75e1b5
perf(router): avoid cloning valid org/bucket value
Changes the org/bucket to NamespaceName calls to move the values into
the constructor, allowing it to reuse them if they do not require
encoding (the common case) instead of forcing them to be cloned to
obtain a 'static NamespaceName.
2023-03-31 16:14:33 +02:00
Dom Dwyer 65034cfaa6
refactor: org & bucket parser on NamespaceName
Moves the function org_and_bucket_to_namespace() to be an associated
method (constructor) on the NamespaceName itself.
2023-03-31 16:12:49 +02:00
dependabot[bot] 275dad704e
chore(deps): Bump futures from 0.3.27 to 0.3.28 (#7397)
Bumps [futures](https://github.com/rust-lang/futures-rs) from 0.3.27 to 0.3.28.
- [Release notes](https://github.com/rust-lang/futures-rs/releases)
- [Changelog](https://github.com/rust-lang/futures-rs/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/futures-rs/compare/0.3.27...0.3.28)

---
updated-dependencies:
- dependency-name: futures
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-03-31 10:44:23 +00:00
Martin Hilton 052e190dd0
feat(service_grpc_flight): optional query authorization (#7351)
* feat(service_grpc_flight): optional query authorization

Add support for requiriing namespace-level authorization for
arrow flight based query requests. These are the flight SQL commands
as well as the IOx-specific SQL over flight and InfluxQL over flight
protocols.

Supports the optional configuration of an authorization sidecar,
in the same manner as is used in the router. If this is configured
then all arrow flight gRPC requests that are implemented will require
a valid authorization token to be supplied in the request. For a
multi-legged operation such as GetFlightInfo + DoGet required for
FlightSQL then a valid authorization is required for every request.

Ideally this support would be implemented using some sort of
interceptor, however the namespace isn't known until the request
processing has been started. The authorization check is performed
as soon as possible once the desired operation is known.

The legacy "storage" API has no authorization checks. Care should
be taken to ensure this API is never exposed to an untrusted network.

* chore(service_grpc_flight): review suggestions

Implement some suggestions from reviewers. The main change is adding
authorization checks to the handshake command.

* chore(service_grpc_flight): remove authorization of handshake

The Handshake call is used by existing clients to verify the
connection. These clients do not send a namespace header with the
request meaning there is nothing to authorize against. Remove this
authorization for now to avoid breaking existing clients.

* refactor: implement Authorizer trait on Option

Based on a suggestion from Dom implement the Authorizer trait on
Option<T: Authorizer> so that the call sites no longer need to check
if an authorizer is configured. This simplifies the code at the
call sites.

To maximise the utility the signature has changed so that a optional
token is now used. When no authorizer is configured this will not
be looked at. When a token is required a new error will be returned
if no token was supplied.

* fix: suggestions from clippy
2023-03-31 07:33:54 +00:00
dependabot[bot] 1ad0160d30
chore(deps): Bump serde_json from 1.0.94 to 1.0.95 (#7348)
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.94 to 1.0.95.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.94...v1.0.95)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-03-28 11:09:59 +00:00
Carol (Nichols || Goulding) 621672b38f
test: Add an e2e test for write replication and fix it because it didn't work 😜 (#7344)
* test: Add an e2e test for write replication

* fix: Pass through rpc_write_replicas configuration to RpcWrite handler

---------

Co-authored-by: Dom <dom@itsallbroken.com>
2023-03-28 09:31:16 +00:00
Dom Dwyer 874325d9ce
refactor(test): generic return iterator
This change allows the MockWriteClient to accept more input types and
internalises the box dyn bits; I got tired of writing "Box::new()"
everywhere.
2023-03-27 13:31:31 +02:00
Dom 6105fd5bb7
refactor: compute n_copies once
Co-authored-by: Carol (Nichols || Goulding) <193874+carols10cents@users.noreply.github.com>
2023-03-27 10:04:17 +01:00
Dom Dwyer 125fef388c
feat: MVP replication support
This commit implements replication for the router's RpcWrite handler.

The desired number of replica copies is specified at startup time, and
each user write will be fanned-out with the specified replication factor
(replicas + 1).

A failure to write to any upstreams returns the write error, but a
failure to obtain enough ACKs (enough successful writes) after at least
1 ACK will return a "partial write" error - this differentiation is
important, as the user's write will be readable after a partial write
error has occurred.

This currently writes to upstreams serially; this is clearly an
opportunity for improvement! A follow-on PR will parallelise writes
across the desired number of replicas while maintaining the "at most one
ack'd write to one host" invariant.

Note that replication is currently hard-coded as disabled.
2023-03-23 17:48:41 +01:00
Dom Dwyer e899dc70c0
feat: meaningful RPC write failure errors
Whenever an RPC write to an upstream ingester fails, it is retried after
an increasing delay, until the RPC_TIMEOUT is hit. Because of this, any
RPC write error would be returned as a "timeout", masking the underling
reason the write actually failed.

This commit pushes down the timeout logic, and retains the most recently
observed RPC write error, returning it to the user instead of the
timeout error.
2023-03-23 16:01:59 +01:00
Dom Dwyer e885eb9061
test(router): RPC error responses from RpcWrite
This PR changes the RpcWrite DmlHandler to facilitate testing using
mocked RPC client circuit breaker states, and assert the error response
for no healthy upstreams.
2023-03-23 16:01:58 +01:00
Dom Dwyer f3d96b6ed1
refactor(mock): iter for MockWriteClient returns
Instead of accepting a finite VecDeque of return values, allow the
MockWriteClient to take any dyn Iterator that yields the required
response type.
2023-03-23 16:01:57 +01:00
Dom Dwyer 68f948c70b
refactor: rename generic type parameter
Rename C -> T, to be consistent with the Balancer, and open up C for
consistent usage between the two.
2023-03-23 16:01:57 +01:00