Commit Graph

57 Commits

Author SHA1 Message Date
Thomas Orozco
201a50db11 mononoke/server: expose EdenAPI
Summary:
Like it says in the title, this adds support for exposing EdenAPI in Mononoke
Server. That's it!

Differential Revision: D26131777

fbshipit-source-id: 15ed2d6d80b1ea06763adc0b7312d1cab2df5b76
2021-02-04 10:40:04 -08:00
Thomas Orozco
632c6e2280 mononoke/gotham_ext: move trusted-proxy check out of middleware
Summary:
I'd like to support bridging to EdenAPI Server in Mononoke Server. Mononoke
Server already performs an ACL check for trusted proxies when the client
connects, I'd like to pass this information to EdenAPI to avoid re-doing
a check we've already done.

This allows that.

Reviewed By: ahornby

Differential Revision: D26108441

fbshipit-source-id: f0a294e340f38d039b3ba30a4c262c4a8ccbb318
2021-02-04 10:40:03 -08:00
Mark Juggurnauth-Thomas
3f20c956a2 fix warnings
Summary:
Fix some warnings in the Mononoke build:

- URLs in doc comments should be delimited with `<` and `>`.

- Permission checker `try_from_ssh_encoded` parameter is unused.

Reviewed By: krallin

Differential Revision: D26224590

fbshipit-source-id: 49ce62655189a7045b78538642dbf638519f71de
2021-02-04 01:09:15 -08:00
Thomas Orozco
ad5dc2d59d third-party/rust: hyper-02: update to 0.13.9
Summary:
Just a minor version update. I'd like to add a patch on top of this for a PR
that hasn't been merged yet, but updating to the underlying released version
first will make the diff clearer.

Reviewed By: ahornby

Differential Revision: D26047997

fbshipit-source-id: 91856f645ec3aaaf4fbf256a23c7e8d4db0f6b37
2021-01-26 07:21:28 -08:00
Daniel Xu
5715e58fce Add version specificiation to internal dependencies
Summary:
Lots of generated code in this diff. Only code change was in
`common/rust/cargo_from_buck/lib/cargo_generator.py`.

Path/git-only dependencies (ie `mydep = { path = "../foo/bar" }`) are not
publishable to crates.io. However, we are allowed to specify both a path/git
_and_ a version. When building locally, the path/git is chosen. When publishing,
the version on crates.io is chosen.

See https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations .

Note that I understand that not all autocargo projects are published on crates.io (yet).
The point of this diff is to allow projects to slowly start getting uploaded.
The end goal is autocargo generated `Cargo.toml`s that can be `cargo publish`ed
without further modification.

Reviewed By: lukaspiatkowski

Differential Revision: D26028982

fbshipit-source-id: f7b4c9d4f4dd004727202bd98ab10e201a21e88c
2021-01-25 22:10:24 -08:00
Thomas Orozco
4dd3461824 third-party/rust: update Tokio 0.2.x to 0.2.24 & futures 1.x to 1.30
Summary:
When we tried to update to Tokio 0.2.14, we hit lots of hangs. Those were due
to incompatibilities between Tokio 0.2.14 and Futures 1.29. We fixed some of
the bugs (and others had been fixed and were pending a release), and Futures
1.30 have now been released, which unblocks our update.

This diff updates Tokio accordingly (the previous diff in the stack fixes an
incompatibility).

The underlying motivation here is to ease the transition to Tokio 1.0.
Ultimately we'll be pulling in those changes one or way or another, so let's
get started on this incremental first step.

Reviewed By: farnz

Differential Revision: D25952428

fbshipit-source-id: b753195a1ffb404e0b0975eb7002d6d67ba100c2
2021-01-25 08:06:55 -08:00
Radu Szasz
5fb5d23ec8 Make tokio-0.2 include test-util feature
Summary:
This feature is useful for testing time-dependent stuff (e.g. it
allows you to stop/forward time). It's already included in the buck build.

Reviewed By: SkyterX

Differential Revision: D25946732

fbshipit-source-id: 5e7b69967a45e6deaddaac34ba78b42d2f2ad90e
2021-01-18 10:38:08 -08:00
Evgenii Kazakov
579e3cbd1c mononoke/lfs_server: Update Mononoke LFS reverse DNS lookups to use the trust-dns crate
Summary:
Before this diff, we did DNS lookups using a crate called `dns_lookup`. This crate is a thin layer over libc DNS lookups. Those lookups are blocking (i.e. they hold a thread), so they're not very friendly to asynchronous code. We currently offload them on a dedicated thread pool to mitigate the issue, but this isn't ideal: if we experience e.g. slow DNS responses, we could saturate this thread pool pretty easily.

I updated it to use the trust-dns crate, which provides an asynchronous implementation of DNS lookups, and is currently used in other parts of Mononoke.

Reviewed By: krallin

Differential Revision: D25849872

fbshipit-source-id: 826ab4e5618844f3b48e5def4ad9bd163753ebb1
2021-01-11 18:03:11 -08:00
Thomas Orozco
772680f2f7 third-party: rust: update Gotham to 0.5
Summary:
This updates Gotham. Under the hood I rebased our fork, you can see the diff
here: P161171514.

The stuff that is relevant is that Gotham got rid of its dependency on
`failure` and now uses `anyhow` instead, and I also added a little bit to our
existing socket data patch by making a few things public so that we can get
access to a few more internals.

Reviewed By: StanislavGlebik

Differential Revision: D25850262

fbshipit-source-id: 25ebf5d63be39e3e93208705d91abc5c61c90453
2021-01-11 03:32:25 -08:00
Thomas Orozco
81d6aae51d mononoke/edenapi_server: capture handler errors
Summary:
Right now we don't log handler errors to Scuba. This can make debugging a
little tricky: if a client is sending an invalid request, we'll see that we
sent them a 400, but we won't know what was invalid about the request.

This diff updates our logging to actually log that.

Reviewed By: sfilipco

Differential Revision: D25826522

fbshipit-source-id: 89486014e0eeaac5c9b149224601db54a26080d9
2021-01-08 08:45:01 -08:00
Stefan Filip
2193b84b43 autocargo: regen
Summary: Regen autocargo

Reviewed By: quark-zju

Differential Revision: D25409963

fbshipit-source-id: 7dbbe420aeb30248bf43d3a96a9aa6a47bb2b0be
2020-12-08 18:30:24 -08:00
Kostia Balytskyi
e4dab84619 scuba: turn ScubaSampleBuilderExt into a wrapper struct
Summary:
This diff prepares the Mononoke codebase for composition-based extendability of
`ScubaSampleBuilder`. Specifically, in the near future I will add:
- new methods for verbose scuba logging
- new data field (`ObservabilityContext`) to check if verbose logging should
  be enabled or disabled

The higher-level goal here is to be able to enable/disable verbose Scuba
logging (either overall or for certain slices of logs, like for a certain
session id) in real time, without restarting Mononoke. To do so, I plan to
expose the aforementioned verbose logging methods, which will run a check
against the stored `ObservabilityContext` and make a decision of whether the
logging is enabled or not. `ObservabilityContext` will of course hide
implementation details from the renamed `ScubaSampleBuilderExt`, and just provide a yes/no
answer based on the current config and sample fields.

At the moment this should be a completely harmless change.

Reviewed By: krallin

Differential Revision: D25211089

fbshipit-source-id: ea03dda82fadb7fc91a2433e12e220582ede5fb8
2020-11-30 21:26:24 -08:00
Arun Kulshreshtha
bd0b2a04a4 gotham_ext: use pin_project in SignalStream
Summary: This code predates the use of `pin_project`, which simplifies the implementation of pinned types using proc macros. We now use `pin_project` in most other places in this crate where we define custom `Future`s and `Stream`s, so let's use it in `SignalStream` as well. (This makes the code easier to modify and removes the need for `unsafe` code.)

Reviewed By: farnz

Differential Revision: D24285792

fbshipit-source-id: da018b9ed62c33d9d06ecf6caa4748969a057e66
2020-10-14 11:08:13 -07:00
Arun Kulshreshtha
5c1837e700 gotham_ext: add FuseOnErr stream combinator
Summary:
Add a stream combinator that causes a `TryStream` to end upon encountering the error. The resulting stream remains a `TryStream`, but will always terminate after yielding an error item.

Later in this stack, this will be used in the LFS server to cause mid-stream errors to always terminate the response.

Reviewed By: krallin

Differential Revision: D24301254

fbshipit-source-id: e71ddc16e79caeb195e23be7d6a93ee63a96a713
2020-10-14 11:08:13 -07:00
Arun Kulshreshtha
6cc6ee822f gotham_ext: add method to get username from client identity
Summary: Add a method to get the client's username from a client identity. This is helpful for logging, etc.

Reviewed By: krallin

Differential Revision: D24153766

fbshipit-source-id: 2ecf85e5de72918aeb292ce88539a991da4de900
2020-10-07 08:17:59 -07:00
Thomas Orozco
ee9ecf63bb gotham_ext: ^ is not **
Summary:
I spotted D23955629 recently, and it turns out I made the same mistake in LFS.
Let's fix it. In order to keep the same semantics (yield on every chunk from
the filestore), I lowered the threshold a bit from what it was intended to be.

Reviewed By: johansglock

Differential Revision: D23960152

fbshipit-source-id: 4d384752228fd125ade7e032a477648798e7fa44
2020-09-28 03:41:24 -07:00
Arun Kulshreshtha
3078f346f8 gotham_ext: make StreamBody take an infallible byte stream
Summary: Make `StreamBody` accept a `Stream` of `Bytes` instead of a `TryStream` of `Bytes`. This means that applications returning streaming responses will be forced to deal with errors prior to returning the response.

Reviewed By: krallin

Differential Revision: D23780216

fbshipit-source-id: dbad61947ef23bbfc4edf3d286ad0218c1859d87
2020-09-18 22:49:55 -07:00
Arun Kulshreshtha
3435319e52 gotham_ext: add EndOnErr TryStream combinator
Summary: Add a new `EndOnErr` combinator for `TryStream`s (exposed via the `GothamTryStreamExt::end_on_err` method) which fuses the underlying `TryStream` upon hitting an error, and passes the error to the user-provided callback. This is useful for contexts like the LFS server, where mid-stream errors are considered unrecoverable and must result in termination of the response.

Reviewed By: krallin

Differential Revision: D23778490

fbshipit-source-id: 05caa52ca62d085cc63cc8feb4619188fe0fac61
2020-09-18 22:37:42 -07:00
Arun Kulshreshtha
7f803818ee gotham_ext: implement ContentMeta for ForwardErr
Summary: Implement `ContentMeta` for streams wrapped with the `ForwardErr` combinator, so that they may be used as input to `StreamBody`. (Presently, this won't actually work since `StreamBody` expects a `TryStream`, but this will change later in the stack.)

Reviewed By: krallin

Differential Revision: D23777842

fbshipit-source-id: 234bcdf104afbf2c9832fbe54d85744bfb470363
2020-09-18 22:37:42 -07:00
Arun Kulshreshtha
26ff321006 gotham_ext: add ForwardErr combinator for TryStreams
Summary:
This diff adds a new `ForwardErr` combinator that allows redirecting the errors from a `TryStream` into a channel, allowing them to be processed asynchronously without disrupting the stream itself. This effectively splits the `TryStream` into two `Stream`s containing the successful items and errors respectively.

To make it easy to use the combinator, I've added a new `GothamTryStreamExt` extension trait (in the vein of the old `futures_ext` crate) that allows the user to simply call `forward_err` on any `TryStream`. The trait name is a bit of a misnomer (suggestions welcome!) in that there isn't anything Gotham-specific about it, but the name `TryStreamExt` is taken and I didn't want to set up a successor to `futures_ext` just for the sake of one combinator. (Though we will likely expand the trait in the future.)

Reviewed By: krallin

Differential Revision: D23777501

fbshipit-source-id: 8628cdc2e104cd9b972afda745858f9cb9e85245
2020-09-18 22:37:42 -07:00
Thomas Orozco
f93426a8c8 mononoke/gotham_ext: force compressed streams to send data every so often
Summary:
Compressed responses from LFS are slower than they should right now. Normally,
we'd expect something along the lines of normal response time + compression
time, but right now it's a lot more than this.

The reason for this is that our compressed streams are eager, i.e. they will
consume and compress as much of the underlying stream as possible before
sending off the data. This is problematic for LFS, because we try very hard to
serve everything out of RAM directly (and very often succeed), so that means
we compress the whole stream before sending it off.

This means we might spend e.g. 500ms compressing (this is how long it takes
zstd to compress the object I was testing on, which is a ~80MiB binary that
compresses down to 33% of that), and _then_ we'll spend some time transferring
the compressed data, when we could have started transferring immediately while
we were compressing.

To achieve this, let's simply tell our compressed stream to stop waiting for
more data once in a while (every 4 MiB, which seems very frequent but actually
really isn't).

Reviewed By: StanislavGlebik

Differential Revision: D23782756

fbshipit-source-id: a0d523d84f92e215eb366f551063383fc835fdd6
2020-09-18 05:39:38 -07:00
Thomas Orozco
05e9fa3a29 mononoke/gotham_ext: remove Brotli support
Summary:
I saw this throw the LFS server into an infinite loop when I tested it. We're
not using this right now, so I'm not investing time into root-causing the
issue, and instead let's just take this out.

Reviewed By: StanislavGlebik

Differential Revision: D23782757

fbshipit-source-id: f320fc72c3ff279042c2fe9fcb9c4904e9e1bfdf
2020-09-18 05:39:38 -07:00
Arun Kulshreshtha
6e5f95067a gotham_ext: move content streams into separate module
Summary:
The `gotham_ext::response` module was getting a bit large, so this diff moves `ContentMeta`, `ContentStream`, and `CompressedContentStream` into a new submodule, alongside the contents of the old `content_encoding` module. This way, the `response` module remains entirely centered around the `TryIntoResponse` trait (and the various body structs that implement that trait).

Later diffs in this stack will be adding an additional layer between the content streams and the body structs, at which point it probably doesn't make sense to have these right next to each other. Splitting them out now will allow for better code organization going forward.

Reviewed By: krallin

Differential Revision: D23777492

fbshipit-source-id: 86e598dcb37578d3b22217a2a65f1bde84d72215
2020-09-18 01:34:04 -07:00
Thomas Orozco
acc0d428cc mononoke/lfs_server: add support for response compression
Summary:
This adds support for compressing responses in the LFS Server, based on what
the client sent in `Accept-Encoding`. The compression changes are fairly
simple. Most of the codes changes are around the fact that when we compress,
we don't send a Content-Length (because we don't know how long the content will
be).

Note that this is largely implemented in StreamBody. This means it can be used
for free by the EdenAPI server as well. The reason it's in there is because we
need to avoid setting the Content-Length when compression is going to be used
(`StreamBody` is what takes charge for doing this). This also exposes a
callback to get access to the stream post-compression, which also needs to be
exposed in `StreamBody`, since that's where compression happens.

Reviewed By: aslpavel

Differential Revision: D23652334

fbshipit-source-id: 8f462d69139991c3e1d37f392d448904206ec0d2
2020-09-15 07:59:53 -07:00
Arun Kulshreshtha
4d76a4c241 gotham_ext: don't end SignalStream on error
Summary: Previously, `SignalStream` would assume that an error would always end the `Stream`, and would therefore stop and report the amount of transferred data upon encountering any error. This isn't always the desired behavior, as it is possible for `TryStream`s to return mid-stream errors without immediately ending. `SignalStream` should allow for this kind of usage.

Reviewed By: farnz

Differential Revision: D23643337

fbshipit-source-id: 2c7ffd9d02c05bc09c6ec0e282c0b2cca166e079
2020-09-11 09:51:10 -07:00
David Tolnay
be0786f14b Prepare for rustfmt 2.0
Summary:
Generated by formatting with rustfmt 2.0.0-rc.2 and then a second time with fbsource's current rustfmt (1.4.14).

This results in formatting for which rustfmt 1.4 is idempotent but is closer to the style of rustfmt 2.0, reducing the amount of code that will need to change atomically in that upgrade.

 ---

*Why now?* **:** The 1.x branch is no longer being developed and fixes like https://github.com/rust-lang/rustfmt/issues/4159 (which we need in fbcode) only land to the 2.0 branch.

 ---

Reviewed By: StanislavGlebik

Differential Revision: D23568780

fbshipit-source-id: b4b4a0aa683d236e2fdeb5b96d723ac2d84b9faf
2020-09-08 07:33:16 -07:00
Arun Kulshreshtha
83c54b48f8 gotham_ext: move ScubaMiddleware into gotham_ext
Summary:
Move `ScubaMiddleware` out of the LFS server and into `gotham_ext`.

This change required splitting up the `ScubaKey` enum to separate generally useful column names (e.g., HTTP columns that would be applicable to any HTTP service) from LFS-specific columns. `ScubaMiddlwareState` has been modified to accept any type that implements `Into<String>` as a key, and the `ScubaKey` enum has been split up into `HttpScubaKey` (in `gotham_ext`) and `LfsScubaKey` (in `lfs_server`).

The middleware now takes a type parameter to specify a "handler" (implementing the new `ScubaHandler`  trait) which allows the application to add application-specific Scuba columns in addition to the default columns. The application-specific columns will be added immediately prior to the sample being logged.

Reviewed By: krallin

Differential Revision: D23458748

fbshipit-source-id: 3e99f3e0b5d3475a4f5ac9eaefade2eeff12c2fa
2020-09-07 17:24:45 -07:00
Arun Kulshreshtha
858a080502 gotham_ext: make StreamBody automatically delay post-request callbacks
Summary: Now that post-request callbacks are available in `gotham_ext`, we can make `StreamBody` use them directly instead of using an LFS-specific wrapper (previously required to access the LFS server's `RequestContext`). This also means that the EdenAPI server will get this behavior for free.

Reviewed By: krallin

Differential Revision: D23402969

fbshipit-source-id: 56ab710473f13e8983b136664af364af6884bd3f
2020-09-03 11:59:32 -07:00
Arun Kulshreshtha
7144363d2c gotham_ext: move LogMiddleware to gotham_ext
Summary: Now that `LogMiddleware` no longer depends on `RequestContext`, it can be moved into `gotham_ext`.

Reviewed By: DurhamG

Differential Revision: D23298412

fbshipit-source-id: d5288decba98c3dd4605b9a44e41eba0f47fee37
2020-09-03 11:59:31 -07:00
Arun Kulshreshtha
35d292e513 gotham_ext: move LoadMiddleware to gotham_ext
Summary: Now that `LoadMiddleware` no longer depends on `RequestContext`, it can be moved into `gotham_ext`.

Reviewed By: DurhamG

Differential Revision: D23298416

fbshipit-source-id: 5d29da492e39beb5621daf0570d9b3e657cbfc04
2020-09-03 11:59:31 -07:00
Arun Kulshreshtha
3ad7fa8b6f gotham_ext: allow applications to dynamically configure PostRequestMiddleware
Summary: Make `PostRequestMiddleware` generic over a user-provided config struct which can be used to dynamically configure the behavior of post-request callback dispatching. Right now this is only used to support disabling hostname logging, but could be easily extended to cover more uses in the future.

Reviewed By: krallin

Differential Revision: D23495005

fbshipit-source-id: 3d59a8346f449775ec76d03c260d973d04fb90a9
2020-09-03 11:59:31 -07:00
Arun Kulshreshtha
cc0f2e4c40 gotham_ext: add PostRequestMiddleware
Summary: Add new middleware that allows HTTP handlers and other middleware to register callbacks that will be run once the current request completes. This is heavily based on the post-request callback functionality from the LFS server's `RequestContext`. The intention here is to expose this functionality in a manner that's independent of other, application-specific logic.

Reviewed By: krallin

Differential Revision: D23298419

fbshipit-source-id: e4b1534b02c35f685ce544de13e331947e187818
2020-09-03 11:59:31 -07:00
Arun Kulshreshtha
9f68c673f3 gotham_ext: move TimerMiddleware into gotham_ext
Summary: Now that `TimerMiddleware` no longer depends on `RequestContext`, it can be moved into `gotham_ext`.

Reviewed By: farnz

Differential Revision: D23298414

fbshipit-source-id: 058cb67c9294b28ec7aec03a45da9588e97facc5
2020-08-26 16:04:31 -07:00
Arun Kulshreshtha
c08f67f004 gotham_ext: move middleware.rs to middleware/mod.rs
Summary: Move `middleware.rs` to `middleware/mod.rs` for consistency with the prevailing module file structure in the Mononoke codebase.

Reviewed By: sfilipco

Differential Revision: D23298420

fbshipit-source-id: 4f88d046a2c6ca1be2e3e315c9eea17845c6b8b3
2020-08-25 17:33:42 -07:00
Arun Kulshreshtha
439dd2d495 gotham_ext: move client hostname lookup into gotham_ext
Summary: Move client hostname reverse DNS lookup from inside of the LFS server's `RequestContext` to an async method on `ClientIdentity`, allowing it to be used elsewhere. The behavior of `RequestContext::dispatch_post_request` should remain unchanged.

Reviewed By: krallin

Differential Revision: D22835610

fbshipit-source-id: 15c1183f64324f216bd639630396c9c6f19bcaaa
2020-07-30 10:27:35 -07:00
Arun Kulshreshtha
5f0181f48c Regenerate all Cargo.tomls after upgrade to futures 0.3.5
Summary: D22381744 updated the version of `futures` in third-party/rust to 0.3.5, but did not regenerate the autocargo-managed Cargo.toml files in the repo. Although this is a semver-compatible change (and therefore should not break anything), it means that affected projects would see changes to all of their Cargo.toml files the next time they ran `cargo autocargo`.

Reviewed By: dtolnay

Differential Revision: D22403809

fbshipit-source-id: eb1fdbaf69c99549309da0f67c9bebcb69c1131b
2020-07-06 20:49:43 -07:00
Thomas Orozco
ce7f53422f mononoke/lfs_server: support the client not having the data it wants to send us
Summary:
This diff is probably going to sound weird ... but xavierd and I both think
this is the best approach for where we are right now. Here is why this is
necessary.

Consider the following scenario

- A client creates a LFS object. They upload it to Mononoke LFS, but not
  upstream.
- The client shares this (e.g. with Sandcastle), and includes a LFS pointer.
- The client tries to push this commit

When this happens, the client might not actually have the object locally.
Indeed, the only pieces of data the client is guaranteed to have is
locally-authored data.

Even if the client does have the blob, that's going to be in the hgcache, and
uploading from the hgcache is a bit sketchy (because, well, it's a cache, so
it's not like it's normally guaranteed to just hold data there for us to push
it to the server).

The problem boils down to a mismatch of assumptions between client and server:

- The client assumes that if the data wasn't locally authored, then the server
  must have it, and will never request this piece of data again.
- The server assumes that if the client offers a blob for upload, it can
  request this blob from the client (and the client will send it).

Those assumptions are obviously not compatible, since we can serve
not-locally-authored data from LFS and yet want the client to upload it, either
because it is missing in upstream or locally.

This leaves us with a few options:

- Upload from the hg cache. As noted above, this isn't desirable, because the
  data might not be there to begin with! Populating the cache on demand (from
  the server) just to push data back to the server would be quite messy.
- Skip the upload entirely, either by having the server not request the upload
  if the data is missing, by having the server report that the upload is
  optional, or by having the client not offer LFS blobs it doens't have to the
  server, or finally by having the client simply disobey the server if it
  doesn't have the data the server is asking for.

So, why can we not just skip the upload? The answer is: for the same reason we
upload to upstream to begin with. Consider the following scenario:

- Misconfigured client produces a commit, and upload it to upstream.
- Misconfigured client shares the commit with Sandcastle, and includes a LFS
  pointer.
- Sandcastle wants to push to master, so it goes to check if the blob is
  present in LFS. It isn't (Mononoke LFS checks both upstream and internal, and
  only finds the blob in upstream, so it requests that the client submit the
  blob), but it's also not not locally authored, so we skip the push.
- The client tries to push to Mononoke

This push will fail, because it'll reference LFS data that is not present in
Mononoke (it's only in upstream).

As for how we fix this: the key guarantee made by our proxying mechanism is
that if you write to either LFS server, your data is readable in both (the way
we do this is that if you write to Mononoke LFS, we write it to upstream too,
and if you write to upstream, we can read it from Mononoke LFS too).

What does not matter there is where the data came from. So, when the client
uploads, we simply let it submit a zero-length blob, and if so, we take that to
mean that the client doesn't think it authored data (and thinks we have it), so
we try to figure out where the blob is on the server side.

Reviewed By: xavierd

Differential Revision: D22192005

fbshipit-source-id: bf67e33e2b7114dfa26d356f373b407f2d00dc70
2020-06-24 10:02:01 -07:00
Jeremy Fitzhardinge
1b4edb5567 eden: remove unused Rust dependencies
Summary:
Remove unused dependencies for Rust targets.

This failed to remove the dependencies in eden/scm/edenscmnative/bindings
because of the extra macro layer.

Manual edits (named_deps) and misc output in P133451794

Reviewed By: dtolnay

Differential Revision: D22083498

fbshipit-source-id: 170bbaf3c6d767e52e86152d0f34bf6daa198283
2020-06-17 17:55:03 -07:00
Arun Kulshreshtha
48544b0233 edenapi_server: add ErrorKind
Summary: Add an `errors` module containing an `ErrorKind` implemented via `thiserror`. All errors in the server's HTTP handles been annotated with an appropriate `ErrorKind` via `anyhow::Context`. Notably, there is specialized handling of `MononokeError`s from the `mononoke_api` crate via a new `MononokeErrorExt` trait.

Reviewed By: krallin

Differential Revision: D22012237

fbshipit-source-id: 5f6948696e4741816636f1c6fee12069ee1a4b32
2020-06-12 12:16:52 -07:00
Arun Kulshreshtha
5be68125a7 gotham_ext: Add StreamBody
Summary:
Move the LFS server's `StreamBody` into `gotham_ext`, along with some changes to decouple it from the LFS server.

In particular, the `Content-Length` header and post-request `Sender` have been made optional fields that can be set via a builder-style interface. The LFS server's `StreamBody` has been renamed to `LfsStreamBody` and is now a thin wrapper around `gotham_ext`'s `StreamBody` that preserves the old behavior.

Reviewed By: krallin

Differential Revision: D21988855

fbshipit-source-id: a9bf9c04bb791388d761fc705ebc38472a713b65
2020-06-11 13:03:24 -07:00
Johan Schuijt-Li
1d4c5cbfc4 mononoke: replace instances of whitelist/blacklist/blackhole
Summary:
There are people that are hurt by usage of these terms, this should be more
then enough reason to replace these. Newly chosen terms are more
self-explanatory as well.

This doesn't yet touch the actualy config files, as that requires a bit more
effort than 1 diff and will require more coordination.

Reviewed By: krallin

Differential Revision: D21924440

fbshipit-source-id: e24fc638dc8c9d6d20b6f3fa5f0d0bbc91bbf77b
2020-06-10 19:29:30 -07:00
Lukas Piatkowski
ad896878b5 mononoke: add Cargo.toml files for code previously depending on identity_ext
Reviewed By: farnz

Differential Revision: D21864833

fbshipit-source-id: 782175af73f5937534566c99e6dc1e7fcf319f6c
2020-06-10 18:16:04 -07:00
Lukas Piatkowski
f3753fd0bd permission_checker: add methods to parse MononokeIdentity from json and x509
Summary: This methods will replace the fbcode_build provided functions. Also add Cargo files for crates that are now thanks to that buildable in OSS.

Reviewed By: farnz

Differential Revision: D21549860

fbshipit-source-id: 69f4179aa7a9081d33fac1f2f88aa3b32cd31e17/
2020-06-10 18:16:04 -07:00
Lukas Piatkowski
8efc16b157 common/rust/identity_ext: unify identity parsing into a single crate
Summary: The `secure_utils` crate from common/rust/secure_utils was moved to rust-shed, the remaining crates in that folder are being refactored here into a single crate `identity_ext` for clarity.

Reviewed By: StanislavGlebik

Differential Revision: D21549861

fbshipit-source-id: 4da6566a09ba7a772e8062632f9d7520af2e09e6
2020-06-03 13:16:24 -07:00
Arun Kulshreshtha
1918683317 edenapi_server: add repos endpoint
Summary:
Add a simple `/repos` endpoint that returns the list of repos available in a JSON response.

While the handler itself is quite simple, this diff establishes the general pattern by which new handlers will be added to the server.

Reviewed By: krallin

Differential Revision: D21330778

fbshipit-source-id: 77f57c969c34c8c1f7c94979fac383ec442a1e14
2020-05-08 12:07:02 -07:00
Lukas Piatkowski
764023bc99 mononoke: replace all remaining usages of aclchecker with permission_checker
Summary: The changes to server/context, gotham_ext and the code that depends on them are the only reminding places where aclchecker is used directly and it is not easy to split this diff to convert them separately.

Reviewed By: krallin

Differential Revision: D21067809

fbshipit-source-id: a041ab141caa6fe6871e1fda6013e33f1f09bc56
2020-04-29 11:57:34 -07:00
Arun Kulshreshtha
43eae85091 gotham_ext: add into_handler_response method to HttpError
Summary: Add a convenience method to HttpError to return a JSON-formatted representation of the error to the client.

Reviewed By: krallin

Differential Revision: D21193939

fbshipit-source-id: e1ff1555b0016f46dbcd1847239d96daf8b45685
2020-04-23 13:58:04 -07:00
Arun Kulshreshtha
86fc9a4fdb gotham_ext: move body types into gotham_ext
Summary: Move the various body types out of the LFS server into `gotham_ext`. `StreamBody` was intentionally left behind for now since it contains some LFS-specific logic that would need to be factored out before it can be moved.

Reviewed By: krallin

Differential Revision: D21193941

fbshipit-source-id: 638b9e93e9dc7385f7fde9dbb3a2392ad0e18385
2020-04-23 13:58:03 -07:00
Arun Kulshreshtha
ff0ab62e33 gotham_ext: move SignalStream into gotham_ext
Summary: Move `SignalStream` out of the LFS server into `gotham_ext`. This is a step towards extracting all of the functionality needed to support streaming bodies in `gotham_ext`.

Reviewed By: krallin

Differential Revision: D21193940

fbshipit-source-id: 832a5254c80e4ee085ece371b45b38a4519403f3
2020-04-23 13:58:03 -07:00
Arun Kulshreshtha
25a3cfe0b5 gotham_ext: move HttpError into gotham_ext
Summary: Move the `HttpError` type out of the LFS server into `gotham_ext` so it can be used by the EdenAPI server too.

Reviewed By: krallin

Differential Revision: D21193937

fbshipit-source-id: dff59e3ae995fe5771db47174a96e31b2c9f4c73
2020-04-23 13:58:03 -07:00