Commit Graph

171 Commits

Author SHA1 Message Date
Kostia Balytskyi
29f1b16154 live_commit_sync_config: asyncify commit sync config accessors
Summary:
This is a preparation for potential necessity of IO being done by this trait and its implementors.

We think the IO might be needed if we move commit sync config storage from `Configerator` into xdb, or some place else. To be clear, I personally am not certain we'll *need* this, but in any case, asyncifying the trait does not seem like a risky thing here (because we usually have only 0-2 sync functions in the stack above `LiveCommitSyncConfig` accessors, so it does not require large-scale code flow changes or anything).

I intentionally did not touch the push-redirection accessors, as those I don't think will ever move away from configerator.

Reviewed By: StanislavGlebik

Differential Revision: D26275905

fbshipit-source-id: 1bfdca087434d475d50032dd47dd94f16be051f9
2021-02-08 00:42:31 -08:00
Alex Hornby
e27e269274 mononoke: add throttleblob bytes/s limit
Summary:
Add support for directly throttling blobstores based on read and write bandwidth used.

Read bytes throttling can only approximate given we only know the size *after* the inner Blobstore::get().

Reviewed By: krallin

Differential Revision: D26022763

fbshipit-source-id: b8019f53bda326117511aa659dcdab2a958dbd27
2021-02-06 02:22:23 -08:00
Alex Hornby
539544af09 mononoke: add scrub options to cmdlib
Summary: Scrub options are of use to walker, manual_scrub and admin tool,  should be cmdlib blobstore options rather than per-tool.

Reviewed By: krallin

Differential Revision: D25928062

fbshipit-source-id: a5bbf518c4e5d97275fb3d8effd923fcca691891
2021-02-05 01:19:54 -08:00
Thomas Orozco
89774b4be4 mononoke/server: move the scuba configuration to the CLI not the config
Summary:
We always log to the same destination, but this is a little annoying as it
stands for e.g. hooking in EdenAPI because that wants 1 Scuba dataset for the
whole thing instead of per-repo.

This also means that logging to Scuba for things that aren't tied to a repo
isn't possible, which might explain why our logging in connection_acceptor
is a) very sparse and b) only logs to stderr.

To make the transition smooth here, I added support for a default Scuba
table and used this in Mononoke Server. I think we can remove this after
updating our tasks to explicitly receive the dataset as an argument.

Reviewed By: StanislavGlebik

Differential Revision: D26126012

fbshipit-source-id: 0fa92dc8c5d5ddeed99dd7d9dd5a2288b8300bf3
2021-02-04 10:40:03 -08:00
Thomas Orozco
baa948b3f5 mononoke: remove --test-instance
Summary:
Like it says in the title. Explicitly changing behavior between tests and prod
seems a bit random, and it had two callsites only:

- In commit sync config to avoid having to setup a Configerator config, which
  in turn means we take a totally new codepath in tests. That seems a bit
  misguided: let's just set an empty config.
- In config source setup, which is a lot more legit, but also somewhat
  unnecessary: instead of passing `--test-instance`, we can just pass the
  config source itself.

Reviewed By: StanislavGlebik

Differential Revision: D26108442

fbshipit-source-id: a2c112d175031708646efacd5c02dd36be0c3eac
2021-02-04 10:40:02 -08:00
Alex Hornby
b74ab091c3 mononoke: add option to allow remaining deferred edges
Summary: Add option to allow remaining deferred edges at the end of a walker run so that any repos with unresolved edges can still be tailed.

Reviewed By: StanislavGlebik

Differential Revision: D26230927

fbshipit-source-id: 19eed6a616f722d522c7bca30bbe3bc4dae08655
2021-02-04 08:01:20 -08:00
Alex Hornby
960740c37d mononoke: return Result from cmdlib::args::parse_blobstore_options
Summary: Use normal ? style rather than panic with except.

Reviewed By: krallin

Differential Revision: D26176912

fbshipit-source-id: d04ebc4b6c04dd1f8f34b49bee350b52feb11ec1
2021-02-04 00:26:33 -08:00
Stefan Filip
91bce412a4 cache: add segmented-changelog-cache-size argument
Summary:
We have the code that checks that value of the argument but we don't have the
actual entry in the argument list.

Reviewed By: quark-zju

Differential Revision: D26236489

fbshipit-source-id: a418f309a73430915ee8b130adb3b9a92ceecc23
2021-02-03 21:07:25 -08:00
Egor Tkachenko
1b473dcd9c Syncronise lfs entries during darkstorm backups
Summary: Sync job doesn't syncronize large files. For darkstorm backup sync lets make a special lfs verifier, which will upload files from origin blobstore into backup.

Reviewed By: StanislavGlebik

Differential Revision: D24991705

fbshipit-source-id: de668b7ad33ace3445f50cd9c92a678201ffb6f6
2021-02-01 11:23:47 -08:00
Kostia Balytskyi
43d406a808 make get_scuba_sample_builder use observability_context
Summary:
Prior to this diff, only mononoke server initialized
`MononokeScubaSampleBuilder` in a way that used observability context, and
therefore respected vebosity settings.

Let's make a generic sample initializing function use this config too.

Reviewed By: ahornby

Differential Revision: D26156986

fbshipit-source-id: 632bda279e7f3905367b82db5b36f81264156de3
2021-02-01 03:57:06 -08:00
Stefan Filip
549ba8cac3 segmented_changelog: setup caching at the application layer
Summary: Configure segmented changelog to use caching when caching is requested.

Reviewed By: krallin

Differential Revision: D26121496

fbshipit-source-id: d0711a5939b5178b3a93d081019cfab47996da40
2021-01-29 16:41:42 -08:00
Alex Hornby
eb566b5157 mononoke: remove open_sql_with_config_and_mysql_options
Summary: This was just a thin wrapper around with_metadata_database_config and it was using old futures, so remove it.

Differential Revision: D26100512

fbshipit-source-id: 22aa40ed73df2555645ba1d639fee3ae3dd38a09
2021-01-29 10:01:15 -08:00
Simon Farnsworth
db3c193eb4 Measure per-generation sizes in XDB Blobstore
Summary:
Provide a command that measures per-generation sizes, to be run in
Chronos.

Reviewed By: ahornby

Differential Revision: D25981511

fbshipit-source-id: 7d9877dd5d04ac6881b5024e0ba132c234499d5a
2021-01-27 12:35:09 -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
Alex Hornby
799203c8fa mononoke: remove ThrottleOptions::new, make struct instance instead
Summary: Its easier to distinguish the parameters when constructing it directly rather than via a new() method.

Differential Revision: D26017347

fbshipit-source-id: a020db1133de727f217f67a05953059122e3623a
2021-01-22 07:24:14 -08:00
Alex Hornby
f2e3367985 mononoke: move add_blobstore_args into MononokeAppBuilder
Summary: Its only called from inside MononokeAppBuilder so move it inside to save passing all the struct members as params.

Differential Revision: D25976405

fbshipit-source-id: e95d7b8f5f4474f0289d29bb7bb0a8b0780112e0
2021-01-22 07:24:14 -08:00
Alex Hornby
94010f8539 mononoke: remove BlobConfig::Scrub variant
Summary:
Scrub was being enabled by mutating the BlobConfig into the BlobConfig::Scrub.

This change removes the BlobConfig::Scrub variant as its not present in the thrift config any more, so there is not need for it to exist. Scrubbing is an optional mode of multiplexed store construction, so instead add ScrubOptions to BlobstoreOptions.

Reviewed By: StanislavGlebik

Differential Revision: D25927253

fbshipit-source-id: 29fceae59be8f7068300a7b8b298c6edbe4da04b
2021-01-20 02:31:36 -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
Alex Hornby
395ec9dbeb mononoke: remove Scrubbing enum, all callsites had same value
Summary: This enum no longer serves a purpose,  delete it

Reviewed By: ikostia

Differential Revision: D25927254

fbshipit-source-id: 6731d6a57313946ee70b301ebc4f5cd634a90e61
2021-01-18 03:15:52 -08:00
Alex Hornby
c291e6cbb3 mononoke: remove unused open_scrub_repo from cmdlib
Summary: Nothing using this,  remove

Reviewed By: ikostia

Differential Revision: D25927256

fbshipit-source-id: 8f3b970fa5c001eca5440c9ab1977631e6205f47
2021-01-18 03:15:52 -08:00
Alex Hornby
d17ec72093 mononoke: add log tag filtering to cmdlib
Summary:
Add arguments to cmdlib so we can filter log messages by the slog tag, using new Drains added in slog_ext.

To use tagging from slog the form is:

```
const FOO_TAG: &str = "foo";
info!(logger, #FOO_TAG, "hello foo!");
```

Reviewed By: krallin

Differential Revision: D25837627

fbshipit-source-id: b164d508a2e82a80c4ff6f5f35c0c722257b9a2a
2021-01-15 03:13:27 -08:00
Stanislau Hlebik
04f439b2f2 mononoke: make sure we initialize tunables in derived_data_tailer
Summary:
Previously we weren't initializing tunables at all in derived_data_tailer and
probably in lots of other binaries as well.

This is unfortunate, since derived_data_tailer runs for a long time and it
would be good to be able to control its behaviour.

Let's fix it by using init_mononoke() function.

Reviewed By: ikostia

Differential Revision: D25912156

fbshipit-source-id: eabd1c56120d087a169746077c8a7d36855c2b84
2021-01-14 13:02:43 -08:00
Alex Hornby
2d0b7db627 mononoke: allow cmdlib init_logging to return a Result
Summary: Allow us to return arg parsing errors rather than panicing

Reviewed By: krallin

Differential Revision: D25837626

fbshipit-source-id: 87e39de140b1dcd3b13a529602fdafc31233175d
2021-01-14 09:52:40 -08:00
Stanislau Hlebik
f0d438e694 mononoke: add an option to read content ids from file in fixrepocontents
Summary:
Sometimes we want to rechunk just a few file contents, this diff makes it
possible to do so.

Reviewed By: ahornby

Differential Revision: D25804144

fbshipit-source-id: 6ce69f7cee8616a872531bdf5a48746dd401442d
2021-01-07 10:03:25 -08:00
Stanislau Hlebik
a09d7264f8 mononoke: allow selecting a multiplex blobstore component in fixrepocontents
Summary:
In some cases we might have chunked file content in one blobstore component and
unchunked file content in another. And rechunking the second component was
awkward since we never know which version a filestore will fetch - filestore
can fetch a chunked version and decide that rechunking is not necessary.

This diff makes it possible to rechunk only a single component of a multiplexed
blobstore. It does so by manually creating BlobRepo with the single-component
blobstore.

Reviewed By: krallin

Differential Revision: D25803821

fbshipit-source-id: f2a992b73d0c5fc9d389a4b81e0f3e312c17fdea
2021-01-06 11:20:32 -08:00
Kostia Balytskyi
175b9157f1 observability: fix double-filtering bug
Summary:
We should not filter based on parsed level when passiing an inner drain into
the `DynamicLevelDrain`, as in cases when the binary is ran
`--with-dynamic-observability=true`, this would default the level to `INFO` and
make the inner drain filter on that level, which would essentially make debug
logging impossible. Instead, we should pass unfiltering inner drain into
`DynamicLevelDrain`, as `DynamicLevelDrain` actually uses
`ObservabilityContext`, which when the binary is called with `--debug` or
`--level=SOMETHING` would [instantiate](https://fburl.com/diffusion/sib8ayrn) a `Static` variant, behaving just as
current static level filtering.

Note also that this bug does not affect production, as we never actually try to
control the logging levels dynamically: we always run either with `--debug` or
with `--level=SOMETHING`, which again uses `Static` variant of
`ObservabilityContext`, which in turn filters the same way as the inner drain.

Reviewed By: krallin

Differential Revision: D25783488

fbshipit-source-id: 8054863fb655dd66747b6d2306a38c13cbc64443
2021-01-05 11:41:16 -08:00
Thomas Orozco
7480825838 mononoke/cmdlib: log errors when servers exit unexpectedly
Summary:
Like it says in the title. This is helpful with e.g. Mononoke server where the
"server" handle includes a long winded startup sequence. Right now, if we get
an error, then we don't get an error message immediately, even if we have one.
This leaves you with logs like this:

```
0105 04:20:48.563924 995374 [main] eden/mononoke/cmdlib/src/helpers.rs:229] Server has exited! Starting shutdown...
I0105 04:20:48.564076 995374 [main] eden/mononoke/cmdlib/src/helpers.rs:240] Waiting 0s before shutting down server
I0105 04:20:48.564238 995374 [main] eden/mononoke/cmdlib/src/helpers.rs:248] Shutting down...
E0105 04:20:48.564315 995374 [main] eden/mononoke/server/src/main.rs:119] could not send termination signal: ()
```

This isn't great because you might have to wait for a while to see the error,
and if something hangs in the shutdown sequence later, then you might not see
it at all.

The downside is we might log twice if we have a server that crashes like this,
but I guess that's probably better than not logging at all.

Reviewed By: StanislavGlebik

Differential Revision: D25781095

fbshipit-source-id: bf5bf016d7aa36e3ff6302175bef1aab826977bc
2021-01-05 07:01:13 -08:00
Aida Getoeva
7867ce6965 mononoke: fix mysql options
Summary: Because mysql connection pool options had both `conflicts_with(myrouter)` and default values, the binary always failed if myrouter option was provided.

Differential Revision: D25639679

fbshipit-source-id: 21ebf483d4ee88a05db519a14b7e2561b3089ad1
2020-12-18 11:21:38 -08:00
Lukas Piatkowski
67b05b6c24 mononoke/integration: make integration tests work under @mode/dev-rust-oss
Summary: Last step in covering Mononoke with mode/dev-rust-oss buck build mode.

Reviewed By: markbt

Differential Revision: D25461223

fbshipit-source-id: 3fa0fa05e8c96476e069990e8f5cc6d56acf38c0
2020-12-18 06:13:32 -08:00
Aida Getoeva
8b93f52b71 mononoke/mysql: use single static shared connection pool
Summary:
The correct workflow for using a multi-threaded connection pool for multiple DBs is to have a single shared pool for all the use-cases. The pool is smart enough to maintain separate "pools" for each DB locator and limit them to maximum 100 conn per key.

In this diff I create a `OnceCell` connection pool that is initialized once and reused for every attempt to connect to the DB.
The pool is stored in `MononokeAppData` in order to bind its lifetime to the lifetime of Mononoke app. Then it is passed down as a part of `MysqlOptions`.  Unfortunately this makes `MysqlOptions` not copyable, so the diff also contains lots of "clones".

Reviewed By: ahornby

Differential Revision: D25055819

fbshipit-source-id: 21f7d4a89e657fc9f91bf22c56c6a7172fb76ee8
2020-12-17 15:46:30 -08:00
Aida Getoeva
e9f3284b5b mononoke/mysql: make mysql options not copyable
Summary:
In the next diff I'm going to add Mysql connection object to `MysqlOptions` in order to pass it down from `MononokeAppData` to the code that works with sql.
This change will make MysqlOptions un-copyable.

This diff fixed all issues produced by the change.

Reviewed By: ahornby

Differential Revision: D25590772

fbshipit-source-id: 440ae5cba3d49ee6ccd2ff39a93829bcd14bb3f1
2020-12-17 15:46:30 -08:00
Pavel Aslanov
0fc5c3aca7 convert BlobRepoHg to new type futures
Summary: Convert all BlobRepoHg methods to new type futures

Reviewed By: StanislavGlebik

Differential Revision: D25471540

fbshipit-source-id: c8e99509d39d0e081d082097cbd9dbfca431637e
2020-12-17 07:45:26 -08:00
Alex Hornby
46e7757557 mononoke: add resolve_repos function to cmdlib::args
Summary:
Add a resolve_repos function to cmdlib::args for use from jobs that will run for multiple repos at once.

Planning to use this form the walker to scrub multiple small repos from single process

Differential Revision: D25422755

fbshipit-source-id: 40e5d499cf1068878373706fdaa72effd27e9625
2020-12-16 01:33:55 -08:00
Alex Hornby
fec3ef773c mononoke: introduce RepoRequirement enum to MononokeAppBuilder
Summary: Allows a binary to specify if the repo args are required on command line, and if so if OnlyOne of AtLeastOne is the requirement.

Reviewed By: farnz

Differential Revision: D25422757

fbshipit-source-id: 44d27c954bd1e0fa38b2d44c1c3b2eac3e50bd0c
2020-12-11 04:30:02 -08:00
Alex Hornby
6186481782 mononoke: factor out repo name and id resolution in cmdlib
Summary: Factor out functions in preparation for change that uses them to optionally resolve multiple repos from cmdlib

Differential Revision: D25422754

fbshipit-source-id: e0bd33ae533b1450e7084d78bd1765148b71bc76
2020-12-11 01:36:06 -08:00
Thomas Orozco
482ab2d2a6 eden/mononoke: allow turning on the bonsai / globalrev cache
Summary: Like it says in the title.

Reviewed By: StanislavGlebik

Differential Revision: D25336068

fbshipit-source-id: 113050215c28a28c820d938348a0a3e54c14c3ee
2020-12-07 08:23:19 -08:00
Kostia Balytskyi
3ed778a5ea observability: add dynamic level drain
Summary:
This makes logs go through a `Drain` which queries `ObservabilityContext` (introduced in a previous diff) for current logging level.  ATM I did not add any tests, and it's pretty easy to add a unit-test checking that the drain indeed respects the level, but it's so simple that I am not 100% convinced that test would be all that valuable.

Note that currently `ObservabilityContext` is enabled in a `Static` variation.

Reviewed By: mitrandir77

Differential Revision: D25232400

fbshipit-source-id: 7499916e0a3ddab43538343e6ed215818517eaf7
2020-12-04 14:30:29 -08:00
Kostia Balytskyi
c60fcebc12 observability: introduce ObservabilityContext
Summary:
`ObservabilityContext` is a structure that helps logging facilities within Mononoke to make logging decisions. Specifically, the upcoming `DynamicLoggingDrain` and already existing `MononokeScubaSampleBuilder` will have this structure as a component and decide whether a particular logging statement (slog or scuba) should go ahead.

Internally, `ObservabilityContext` is a wrapper around data received from a [configerator endpoint](https://www.internalfb.com/intern/configerator/edit/?path=scm%2Fmononoke%2Fobservability%2Fobservability_config.cconf).

This diff makes a few unobvious decisions about how this is organized. My goals were:
1. to have production (i.e. reading from configerator), static (i.e. emulating current prod behavior) and test variants of `ObservabilityContext`
1. to avoid having consumers know which of these variants are used
1. to avoid making all consumers of `ObservabilityContext` necessarily generic
1. to avoid using dynamic dispatch of `ObservabilityContext`'s methods

Points 3 and 4 mean that `ObservabilityContext` cannot be a trait. `enum` is a common solution in such cases. However, if `ObservabilityContext` is an `enum`, consumers will know which variant they are using (because `enum` variants are public). So the solution is to use a private enum wrapped in a struct.

Reviewed By: mitrandir77

Differential Revision: D25287759

fbshipit-source-id: da034c71570137e8a8fb7749b1e4ad43be482f66
2020-12-04 14:30:29 -08:00
Alex Hornby
591363e1c4 mononoke: allow binaries to specify a default for cachelib-only-blobstore
Summary: Reduces boilerplate for binaries usually run in this mode, notably the walker

Reviewed By: ikostia

Differential Revision: D25216883

fbshipit-source-id: e31d2a6aec7da3baafd8bcf208cf79cc696752c0
2020-12-04 03:07:04 -08:00
Alex Hornby
54bda6537d mononoke: allow binaries to default a blobstore read qps
Summary: This is useful to prevent accidentally consuming too much.  Enabled it for the walker

Reviewed By: ikostia

Differential Revision: D25216880

fbshipit-source-id: e80f490d6ece40d64cc8609e7d6b80d0ecbb1671
2020-12-04 03:07:04 -08:00
Alex Hornby
f814075cee mononoke: allow binaries to default blobstore-cachelib-attempt-zstd option
Summary: Reduces boiler plate on command line for binaries like walker that want different default

Reviewed By: krallin

Differential Revision: D25216876

fbshipit-source-id: 0df474568d28e0726be223e9dc0a760523063d21
2020-12-04 03:07:04 -08:00
Harvey Hunt
3b7978c437 mononoke: cmdlib: Fix default cachelib size crash
Summary:
D24761026 (caa684450f) formatted the default cachelib size with the specifier
`{:3}`. This specifier pads the left side of the string with spaces if there
are less than 3 digits.

Unfortunately, this means that attempting to parse the string into an `f64`
fails. Here's a minimal example:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=11a1e819f9919f7d02565cb8fa561b85

Remove the format specifier and instead call `.to_string()`.

Reviewed By: ahornby

Differential Revision: D25302079

fbshipit-source-id: 461dd628a312a967f6cf5958d2e5d51b72b0ffd8
2020-12-03 05:48:31 -08:00
Alex Hornby
99fb41c5bd mononoke: allow binaries to default readonly-storage option
Summary:
This will reduce boilerplate command line for the walker, as most of the time we want to run it with readonly storage

Because the existing --readonly-storage flag can't take a value this introduces a new --with-readonly-storage=<true|false> option

Reviewed By: krallin

Differential Revision: D25216871

fbshipit-source-id: e1b83b428a9c3787f48c18fd396d23ac95991b77
2020-12-02 07:27:23 -08:00
Alex Hornby
935a7ddfc8 mononoke: remove the need to pass in cachelib settings twice
Summary:
Previously needed to pass in cachelib settings once to MononokeAppBuilder and once to parse_and_init_cachelib.

This change adds a MononokeClapApp and MononokeMatches that preserve the settings, thus preventing the need to pass them in twice (and thus avoiding possible inconsistency)

MononokeMatches uses MaybeOwned to hold the inner ArgMatches, which allows us to hold both the usual reference case from get_matches and an owned case for get_matches_from which is used in test cases.

Reviewed By: krallin

Differential Revision: D24788450

fbshipit-source-id: aad5fff2edda305177dcefa4b3a98ab99bc2d811
2020-12-02 07:27:23 -08:00
Alex Hornby
caa684450f mononoke: show cachelib cache_size in --help usage
Summary:
Show cachelib cache_size default in --help usage so its clear what you'll get if no command line args passed

Because we need to convert from bytes to GiB, the lifetime of the help string isn't long enough for clap's reference recieving default_value, so use OnceCell to be able to pass a static reference.

Reviewed By: krallin

Differential Revision: D24761026

fbshipit-source-id: 81b5e7ceb832d5cb55cc9faef59c5e6432f7c4b0
2020-12-02 07:27:23 -08:00
Alex Hornby
f077f69408 mononoke: move expected_item_size_byte into CachelibSettings
Summary:
Move expected_item_size_byte into CachelibSettings, seems like it should be there.

To enable its use also exposes a parse_and_init_cachelib method for callers that have different defaults to default cachelibe settings.

Reviewed By: krallin

Differential Revision: D24761024

fbshipit-source-id: 440082ab77b5b9f879c99b8f764e71bec68d270e
2020-12-02 00:47:22 -08:00
Alex Hornby
a2247dc41c mononoke: rename MononokeApp to MononokeAppBuilder
Summary:
It has a build() method and later in stack it will build a mononoke
specific type rather than the clap::App

Differential Revision: D25216827

fbshipit-source-id: 24a531856405a702e7fecf54d60be1ea3d2aa6e7
2020-12-01 11:45:00 -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
Pavel Aslanov
6f08815dc3 convert BlobRepo::get_bonsai_bookmark to new type futures
Summary: convert `BlobRepo::get_bonsai_bookmark` to new type futures

Reviewed By: StanislavGlebik

Differential Revision: D25188577

fbshipit-source-id: fb6f2b592b9e9f76736bc1af5fa5a08d12744b5f
2020-11-27 11:11:18 -08:00
Lukas Piatkowski
fa1a195fd0 mononoke/blobstore: pass CoreContext via borrowed instead of owned value
Summary: Follow up after removing 'static from blobstore.

Reviewed By: StanislavGlebik

Differential Revision: D25182106

fbshipit-source-id: e13a7a31d71b4674425123268e655ae66127f1b7
2020-11-27 03:31:07 -08:00
Lukas Piatkowski
0f54cc3d63 mononoke/blobstore: make Blobstore generic over lifetime
Summary: Remove 'static requirement for async methods of Blobstore, propagate this change and fixup low hanging fruits where the code can become 'static free easily.

Reviewed By: ahornby, farnz

Differential Revision: D24839054

fbshipit-source-id: 5d5daa04c23c4c9ae902b669b0a71fe41ee6dee6
2020-11-20 05:51:52 -08:00
Egor Tkachenko
99643e0409 Added verification of generated bonsai changeset between backup and prod repos during blobimport
Summary: It is possible that hash of newly created bonsai_changeset will be different from what is in prod repo. In this case let's fetch bonsai from the prod, to make backup repo consistent with prod.

Reviewed By: StanislavGlebik

Differential Revision: D24593003

fbshipit-source-id: 70496c59927dae190a8508d67f0e3d5bf8d32e5c
2020-11-10 08:46:16 -08:00
Alex Hornby
6091d25bee mononoke: reduce visibility of add_* functions that MononokeApp controls
Summary:
Reduce visibility of add_* functions that MononokeApp controls, no need for them to be public.

Updated a couple of binaries to use MononokApp.with_fb303_args() instead of calling the add_fb303 function directly.

Reviewed By: krallin

Differential Revision: D24757202

fbshipit-source-id: a068ca4fd976429e7c02c4049429553cc8acf3d4
2020-11-09 02:25:25 -08:00
Alex Hornby
f28a33a86e mononoke: make MononokeApp arguments more configurable
Summary: make MononokeApp arguments more configurable so binaries can opt out of them if a section does not apply,  making the --help more relevant.

Reviewed By: krallin

Differential Revision: D24757007

fbshipit-source-id: eed2f321bdbd04208567ef9a45cf861e56cdd07e
2020-11-09 02:25:24 -08:00
Lukas Piatkowski
3c3de9e954 rust-shed/futures_01_ext: rename futures_ext to futures_01_ext
Summary: As part of the effort to deprecate futures 0.1 in favor of 0.3 I want to create a new futures_ext crate that will contain some of the extensions that are applicable from the futures_01_ext. But first I need to reclame this crate name by renaming the old futures_ext crate. This will also make it easier to track which parts of codebase still use the old futures.

Reviewed By: farnz

Differential Revision: D24725776

fbshipit-source-id: 3574d2a0790f8212f6fad4106655cd41836ff74d
2020-11-05 06:07:16 -08:00
Simon Farnsworth
fb9283c378 Remove old-style futures from cmdlib::args and fix up build failures
Summary: The more we remove, the easier it'll be to remove the last few problem cases.

Reviewed By: StanislavGlebik

Differential Revision: D24592052

fbshipit-source-id: de6371305991d54bf2802fd904850b49aeb11bbd
2020-10-30 11:55:15 -07:00
Kostia Balytskyi
8540105a10 cross_repo_sync: log commit syncs
Summary:
This adds some basic Scuba logging to commit sync logic in Mononoke. This can be disabled via a tunable.

Note: of course, the wrapping of logging functions would have been pretty cool to do in a macro, but I don't have time atm to figure it out, so have just code.

Reviewed By: StanislavGlebik

Differential Revision: D24571702

fbshipit-source-id: f8830fc675a2a62d2204671e86ab2c819372c5cc
2020-10-30 05:56:40 -07:00
Kostia Balytskyi
9d09b815c1 CommitSyncer: add wiring for Scuba reporing support
Summary: This adds a `ScubaSampleBuilder` field to the `CommitSyncer` and ensures this field is instantiated with correct values (real vs discarding sample) depending on circumstances.

Reviewed By: StanislavGlebik

Differential Revision: D24539732

fbshipit-source-id: 37aedcff9aefcfcd6b740a0491ab35f9e5ce7c77
2020-10-30 05:56:40 -07:00
Alex Hornby
89ace3790f mononoke: extend MononokeApp so admin apps can have a special default put behaviour
Summary:
Extend MononokeApp so admin apps can have a special default put behaviour (typically
 overwrite) vs the soon to be new default of IfAbsent

Use it from the admin tools.

Reviewed By: farnz

Differential Revision: D24623094

fbshipit-source-id: 5709c68429f8e1de0535eec132998d20411fc0e6
2020-10-29 16:07:22 -07:00
Kostia Balytskyi
e606572eb3 cross_repo_sync: get rid of CommitSyncerArgs
Summary:
`CommitSyncerArgs` was useful when `CommitSyncer` did not have a way to query
existing configs from the configerator. Now that `SyncDataProvider` is part of
`CommitSyncer`, we can get rid of `CommitSyncerArgs`, which will also make
further improvements more convenient.

Reviewed By: StanislavGlebik

Differential Revision: D24565773

fbshipit-source-id: 4dd507b06d946c6018a4a4e8d5e77c6b27abe195
2020-10-27 17:00:08 -07:00
Simon Farnsworth
4e59e26775 Thread ConfigStore into blobstore creation
Summary: SQLBlob GC (next diff in stack) will need a ConfigStore in SQLBlob. Make one available to blobstore creation

Reviewed By: krallin

Differential Revision: D24460586

fbshipit-source-id: ea2d5149e0c548844f1fd2a0d241ed0647e137ae
2020-10-27 04:14:24 -07:00
Simon Farnsworth
7e06175e61 Make config store always explicit
Summary: In D24447404, I provided some utility functions that allowed me to avoid constructing and/or passing around a ConfigStore. Remove those functions and fix up the code to run.

Reviewed By: krallin

Differential Revision: D24502692

fbshipit-source-id: 742dbc54fbcf735895d6829745b9317af14dfa0b
2020-10-24 06:23:49 -07:00
Simon Farnsworth
00871310a7 Ensure we have only one ConfigStore for the application
Summary: It's designed as a singleton store for normal use - rather than have lots of ways to get different config stores, let's use one global store

Reviewed By: krallin

Differential Revision: D24447404

fbshipit-source-id: 6ecc46351b14794471f654cec98527a11a93d3ef
2020-10-24 06:23:49 -07:00
Egor Tkachenko
2494f1db7e Fix cache pool sizes
Summary: My previous diff shrink the size of the cache so the pools can't fit there anymore. Adjust them as well. Plus made cache argument pareser understand float values for `cache-size-gb`

Reviewed By: johansglock

Differential Revision: D24448419

fbshipit-source-id: 2b73f789df10c5df7685ba96b7f19b8c9d04cc71
2020-10-21 10:16:45 -07:00
Alex Hornby
7a65b60841 mononoke: add --blobstore-put-behaviour argument
Summary: Add --blobstore-put-behaviour argument so we can try running some workloads with modified behaviour, firstly with logging on overwrites to gather metrics,  and then not able to overwrite at all.

Reviewed By: StanislavGlebik

Differential Revision: D24109292

fbshipit-source-id: bbea31eb40604fdedc3a0db7a84e99b5b1fe7a23
2020-10-13 03:09:38 -07:00
Alex Hornby
2abe862535 mononoke: add put behaviour to BlobstoreOptions
Summary:
Add put behaviour to BlobstoreOptions in preparation for passing in the put behaviour through blobstore_factory.

Later in the stack a command line option is added to set this non-None so that we can turn on overwrite logging for particular jobs.

Reviewed By: StanislavGlebik

Differential Revision: D24021169

fbshipit-source-id: 5692e2d3912ebde07b0d7bcce54b79df188a9f16
2020-10-07 12:11:10 -07:00
Kostia Balytskyi
2ea25308ab commit_rewriting: use is_empty() where possible
Summary: `clippy` often complains about the use of `.len() != 0`, `.len() > 0` or `.len() == 0`and proposes to use `.is_empty()` instead. This diff does that across Mononoke.

Reviewed By: aslpavel

Differential Revision: D24099427

fbshipit-source-id: 1bba2f958485b7efb3f41bf3eae820879c92b0e5
2020-10-04 10:03:42 -07:00
Aida Getoeva
40b8353d21 mononoke: integrate mysql client
Summary:
This diff introduces Mysql client for Rust to Mononoke as a one more backend in the same row with raw xdb connections and myrouter. So now Mononoke can use new Mysql client connections instead of Myrouter.

To run Mononoke with the new backend, pass `--use-mysql-client` options (conflicts with `--myrouter-port`).

I also added a new target for integration tests, which runs mysql tests using mysql client.
Now to run mysql tests using raw xdb connections, you can use `mononoke/tests/integration:integration-mysql-raw-xdb` and using mysql client `mononoke/tests/integration:integration-mysql`

Reviewed By: ahornby

Differential Revision: D23213228

fbshipit-source-id: c124ccb15747edb17ed94cdad2c6f7703d3bf1a2
2020-09-29 03:09:05 -07:00
Stanislau Hlebik
a47464f60d mononoke: remove create_commit_syncer_from_matches
Summary:
At the moment CommitSyncConfig can be set in two ways:
1) Set in the normal mononoke config. That means that config can be updated
only after a service is restarted. This is an outdated way, and won't be used
in prod.
2) Set in separate config which can be updated on demand. This is what we are
planning to use in production.

create_commit_syncer_from_matches was used to build a CommitSyncer object via
normal mononoke config (i.e. outdated option #1). According to the comments it
was done so that we can read configs from the disk instead of configerator, but
this doesn't make sense because you already can read configerator configs
from disk. So create_commit_syncer_from_matches doesn't look particularly
useful, and besides it also make further refactorings harder. Let's remove it.

Reviewed By: ikostia

Differential Revision: D23811090

fbshipit-source-id: 114d88d9d9207c831d98dfa1cbb9e8ede5adeb1d
2020-09-23 04:30:41 -07:00
Stanislau Hlebik
b5f1e53cd6 mononoke: use logical number of cpus in our runtime
Summary:
We are using older version of tokio which spawns as many threads as we have
physical cores instead of the number of logical cores. It was fixed in
https://github.com/tokio-rs/tokio/issues/2269 but we can't use it yet because
we are waiting for another fix to be released -
https://github.com/rust-lang/futures-rs/pull/2154.

For now let's hardcode it in mononoke

Reviewed By: krallin

Differential Revision: D23599140

fbshipit-source-id: 80685651a7a29ba8938d9aa59770f191f7c42b8b
2020-09-09 09:25:40 -07:00
Stanislau Hlebik
0740f99f13 mononoke: allow logging censored scuba accesses to file
Summary:
In the next diff I'm going to add log-only mode to redaction, and it would be
good to have a way of testing it (i.e. testing that it actually logs accesses
to bad keys).

In this diff let's use a config option that allows logging censored scuba
accesses to file, and let's update redaction integration test to use it

Reviewed By: ikostia

Differential Revision: D23537797

fbshipit-source-id: 69af2f05b86bdc0ff6145979f211ddd4f43142d2
2020-09-04 07:37:14 -07:00
Mark Thomas
8790a793b9 mononoke_api: add HookManager
Summary: We will shortly need a `HookManager` in the write methods of the source control service.  Add one to `mononoke_api::Repo`

Reviewed By: StanislavGlebik

Differential Revision: D23077552

fbshipit-source-id: e1eed3661fe26a839e50ac4d884f4fadf793dbbb
2020-08-25 09:14:07 -07:00
Arun Kulshreshtha
523013c808 cmdlib: remove extra comment slashes
Reviewed By: quark-zju

Differential Revision: D23111025

fbshipit-source-id: b8606c322439c41097d739df59b551a8432e7fe4
2020-08-14 18:04:26 -07:00
Alex Hornby
ecb58ff8d7 mononoke: add cmdlib argument to control cachelib zstd compression
Summary:
Add a cmdlib argument to control cachelib zstd compression. The default behaviour is unchanged, in that the CachelibBlobstore will attempted compression when putting to the cache if the object is larger than the cachelib max size.

To make the cache behaviour more testable, this change also adds an option to do an eager put to cache without the spawn. The default remains to do a lazy fire and forget put into the cache with tokio::spawn.

The motivation for the change is that when running the walker the compression putting to cachelib can dominate CPU usage for part of the walk, so it's best to turn it off and let those items be uncached as the walker is unlikely to visit them again (it only revisits items that were not fully derived).

Reviewed By: StanislavGlebik

Differential Revision: D22797872

fbshipit-source-id: d05f63811e78597bf3874d7fd0e139b9268cf35d
2020-07-31 01:12:02 -07:00
Mark Thomas
89bc34035b scuba: add log sequence numbers
Summary:
Add log sequence numbers to the scuba sample builder.  This provides an ordering
over the logs made by an individual instance of Mononoke, allowing them to be
sorted.

Reviewed By: krallin

Differential Revision: D22728880

fbshipit-source-id: 854bde51c7bfc469677ad08bb738e5097cb05ad5
2020-07-27 07:10:07 -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
be1bac6c06 mononoke/virtually_sharded_blobstore: expose this in cmdlib
Summary:
Eventually, I plan to make this the default, but for now I'd like to make it
something we can choose to turn on or off as a cmd argument (so we can start
with the experimental tier and Fastreplay).

Note that this mixes volatile vs. non-volatile pools when accessing the pools
for cacheblob. In practice, those pools are actually volatile, it's just that
things don't break if you access them as non-volatile.

Reviewed By: farnz

Differential Revision: D22356537

fbshipit-source-id: 53071b6b21ca5727d422e10f685061c709114ae7
2020-07-03 05:53:11 -07:00
Stanislau Hlebik
2a54f281f2 mononoke: add an option to perform a stack move in megarepotool
Summary:
We've recently added an option to perform a stack move in megarepolib. A "stack
move" it's a stack of commits that move a files according to a mover. Now let's
expose it in the megarepotool

Reviewed By: ikostia

Differential Revision: D22312486

fbshipit-source-id: 878d4b2575ed2930bbbf0b9b35e51bb41393e622
2020-07-03 00:18:41 -07:00
Stanislau Hlebik
8a137ae922 mononoke: add Scribe
Summary:
At the moment we can't test logging to scribe easily - we don't have a way to
mock it. Scribe are supposed to help with that.

They will let us to configure all scribe logs to go to a directory on a
filesystem similar to the way we configure scuba. The Scribe itself will
be stored in CoreContext

Reviewed By: farnz

Differential Revision: D22237730

fbshipit-source-id: 144340bcfb1babc3577026191428df48e30a0bb6
2020-06-29 12:15:22 -07:00
Harvey Hunt
026710c2cd mononoke: Remove --config_path from server arguments
Summary:
D21642461 (46d2b44c0e) converted Mononoke server to use the
`--mononoke-config-path` common argument style to select a config path.

Now that this change has been running for a while, remove the extra logic in
the server that allowed it to accept both the deprecated `--config_path / -P`
and the new arg.

Reviewed By: ikostia

Differential Revision: D22257386

fbshipit-source-id: 7da4ed4e0039d3659f8872693fa4940c58bae844
2020-06-29 07:28:36 -07:00
Kostia Balytskyi
9a00efc973 cmdlib: expose test-instance and local-configerator-path
Summary:
Before this diff only the main Mononoke server binary was able to use fs-based
`ConfigStore`, which is pretty useful in integration tests.

Reviewed By: farnz

Differential Revision: D22256618

fbshipit-source-id: 493a064a279250d01469c9ff7f747585581caf51
2020-06-26 06:51:07 -07:00
Simon Farnsworth
454de31134 Switch Loadable and Storable interfaces to new-style futures
Summary:
Eventually, we want everything to be `async`/`await`; as a stepping stone in that direction, switch some of the blobstore interfaces to new-style `BoxFuture` with a `'static` lifetime.

This does not enable any fixes at this point, but does mean that `.compat()` moves to the places that need old-style futures instead of new. It also means that the work needed to make the transition fully complete is changed from a full conversion to new futures, to simply changing the lifetimes involved and fixing the resulting compile failures.

Reviewed By: krallin

Differential Revision: D22164315

fbshipit-source-id: dc655c36db4711d84d42d1e81b76e5dddd16f59d
2020-06-25 08:45:37 -07:00
Kostia Balytskyi
016b101be9 xrepo: add CommitSyncerArgs
Summary:
Similarly to how we have `PushRedirectorArgs`, we need `CommitSyncerArgs`: a struct, which a long-living process can own and periodically create a real `CommitSyncer` out of it, by consuming freshly reloaded `CommitSyncConfig`.

It is a little unfortunate that I am introducing yet another struct to `commit_rewriting/cross_repo_sync`, as it's already pretty confusing with `CommitSyncer` and `CommitSyncRepos`, but hopefully `CommitSyncerArgs`'s purpose is simple enough that it can be inferred from the name. Note that this struct does have a few convenience methods, as we need to access things like `target_repo` and various repo ids before we even create a real `CommitSyncer`. This makes it's purpose a little less singular, but still fine IMO.

Reviewed By: StanislavGlebik

Differential Revision: D22197123

fbshipit-source-id: e2d993e186075e33acec00200d2aab10fb893ffd
2020-06-25 03:28:08 -07:00
Pavel Aslanov
a1f5e45a5a BlobRepoHg extension trait.
Summary: This diff introduces `BlobRepoHg` extension trait for `BlobRepo` object. Which contains mercurial specific methods that were previously part of `BlobRepo`. This diff also stars moving some of the methods from BlobRepo to BlobRepoHg.

Reviewed By: ikostia

Differential Revision: D21659867

fbshipit-source-id: 1af992915a776f6f6e49b03e4156151741b2fca2
2020-06-22 07:29:19 -07:00
Jeremy Fitzhardinge
35b292ce9d eden: manual dependency fixes
Summary:
Tooling can't handle named_deps yet, but it can warn about them

P133451794

Reviewed By: StanislavGlebik

Differential Revision: D22083499

fbshipit-source-id: 46de533c19b13b2469e912165c1577ddb63d15cd
2020-06-17 17:55:04 -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
Alex Hornby
9c53e07e46 mononoke: add optional compress to packblob put
Summary:
Add optional compress on put controlled by a command line option.

Other than costing some CPU time, this may be a good option when populating repos from existing uncompressed stores to new stores.

Reviewed By: farnz

Differential Revision: D22037756

fbshipit-source-id: e75190ddf9cfd4ed3ea9a18a0ec6d9342a90707b
2020-06-17 02:35:04 -07:00
Jeremy Fitzhardinge
c530d32056 rust: clean up some warnings
Summary: Prep for 1.44 but also general cleanups.

Reviewed By: dtolnay

Differential Revision: D22024428

fbshipit-source-id: 8e1d39a1e78289129b38554674d3dbf80681f4c3
2020-06-15 16:50:40 -07:00
Aida Getoeva
81e7b76475 mononoke/apiserver: remove content sha1 cache
Summary: It was used by APIServer only, now when it's decomissioned we can delete this.

Reviewed By: HarveyHunt

Differential Revision: D21954670

fbshipit-source-id: a16bbbbb9dfe17eda5ff1ee6267251708ee4d562
2020-06-10 19:29:48 -07:00
David Tolnay
cf412e0d6b rustfmt: Use use_try_shorthand default
Summary:
I observed that for whatever reason our setting of `use_try_shorthand = true` in rustfmt.toml was causing entire functions to not get processed by rustfmt. Even files that contain neither `try` nor `?`. Remove it and reformat fbsource.

Documentation of that config:

- https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#use_try_shorthand

We don't particularly care about the value anymore because nobody writes `r#try!(...)` in 2018 edition code.

Minimized:

```
fn f() {
    g(
        )
        // ...
        .h
}
```

This function gets formatted only if use_try_shorthand is not set.

The bug is fixed in the rustfmt 2.0 release candidate.

Reviewed By: jsgf

Differential Revision: D21878162

fbshipit-source-id: b028673c0eb703984d24bf0d2983453fc2a8c212
2020-06-10 19:29:15 -07:00
Mark Thomas
6ad7e5c96e metaconfig/parser: use free functions for loading configuration
Summary:
Replace the use of `RepoConfigs::read*` associated functions with free
functions.  These didn't really need to be associated functions (and in the
case of the common and storage configs, really didn't belong there either).

Reviewed By: krallin

Differential Revision: D21837270

fbshipit-source-id: 2dc73a880ed66e11ea484b88b749582ebdf8a73f
2020-06-02 09:30:03 -07:00
Harvey Hunt
46d2b44c0e mononoke: Use MononokeApp for mononoke server
Summary:
Mononoke server is the only binary using plain `clap::App`, whilst all
other services use `MononokeApp`. The `MononokeApp` variant configures some
default arguments and provides consistent argument naming between binaries.

Update the server to use `MononokeApp` and add some logic to allow passing
either `--config_path` or `--mononoke-config-path` until we remove all uses of
`--config-path`.

Reviewed By: StanislavGlebik

Differential Revision: D21642461

fbshipit-source-id: f42e0b6625f3979ced0920db269bdb4528f99e49
2020-05-20 05:47:17 -07:00
Stefan Filip
60966c93e7 autocargo: regenerate
Summary: maintenance

Reviewed By: StanislavGlebik

Differential Revision: D21640322

fbshipit-source-id: d0b2ce604735c05d540d06835c8e4c8a940fbf5c
2020-05-19 16:08:40 -07:00
Igor Katson
246e3e142b Remove .compat() from edenapi_server/main.rs
Summary: This removes .compat() from edenapi_server/main.rs. The actual removal probably could be done with less code, but in addition to removing compat(), I made most of the blocking code async.

Reviewed By: kulshrax, farnz

Differential Revision: D21426641

fbshipit-source-id: 1b3de4dc0b24d06faeb73de2e8658f0629d9491d
2020-05-11 09:12:07 -07:00
Stanislau Hlebik
c71469dc1c mononoke: add tunable for warm bookmark config
Summary: Let's make it tunable, more context in D21300885

Reviewed By: ikostia, krallin

Differential Revision: D21347636

fbshipit-source-id: 4bc91effdd212a3f5c4a0c3d4952f52a1cf417d7
2020-05-01 04:04:51 -07:00
Harvey Hunt
3cd49f9d3c mononoke: Add tunables - a simple form of config hot reloading
Summary:
Currently, Mononoke's configs are loaded at startup and only refreshed
during restart. There are some exceptions to this, including throttling limits.
Other Mononoke services (such as the LFS server) have their own implementations
of hot reloadable configs, however there isn't a universally agreed upon method.

Static configs makes it hard to roll out features gradually and safely. If a
bad config option is enabled, it can't be rectified until the entire tier is
restarted. However, Mononoke's code is structured with static configs in mind
and doesn't support hot reloading. Changing this would require a lot of work
(imagine trying to swap out blobstore configs during run time) and wouldn't
necessarily provide much benefit.

Instead, add a subset of hot reloadable configs called tunables. Tunables are
accessible from anywhere in the code and are cheap to read as they only require
reading an atomic value. This means that they can be used even in hot code
paths.

Currently tunables support reloading boolean values and i64s. In the future,
I'd like to expand tunables to include more functionality, such as a rollout
percentage.

The `--tunables-config` flag points to a configerator spec that exports a
Tunables thrift struct. This allows differents tiers and Mononoke services to
have their own tunables. If this isn't provided, `MononokeTunables::default()`
will be used.

This diff adds a proc_macro that will generate the relevant `get` and `update`
methods for the fields added to a struct which derives `Tunables`. This struct is
then stored in a `once_cell` and can be accessed using `tunables::tunables()`.

To add a new tunable, add a field to the `MononokeTunables` struct that is of
type `AtomicBool` or `AtomicI64`. Update the relevant tunables configerator
config to include your new field, with the exact same name.

Removing a tunable from `MononokeTunables` is fine, as is removing a tunable
from configerator.

If the `--tunables-config` path isn't passed, then a default tunables config
located at `scm/mononoke/tunables/default` will be loaded. There is also the
`--disable-tunables` flag that won't load anything from configerator, it
will instead use the `Tunable` struct's `default()` method to initialise it.
This is useful in integration tests.

Reviewed By: StanislavGlebik

Differential Revision: D21177252

fbshipit-source-id: 02a93c1ceee99066019b23d81ea308e4c565d371
2020-04-30 16:08:30 -07:00
Harvey Hunt
54e01c713a mononoke: Add init_mononoke helper function and update call sites
Summary:
Add a new function that initialises common parts of Mononoke:
- cachelib
- logging
- runtime

In the next diff, I will also update `init_mononoke` to initialise tunables
too.

I left some users of `init_runtime` unchanged (such as `mononoke_admin`) as
they conditionally enable cachelib.

Reviewed By: krallin

Differential Revision: D21177253

fbshipit-source-id: 40b534d1b244fd8dcd05e1cff1c9f3edfb32a4b9
2020-04-28 09:03:09 -07:00
Harvey Hunt
b24074ac35 mononoke: Add get_config_path helper to cmdlib
Summary:
Multiple functions in cmdlib were looking for
`"mononoke-config-path"`. Make it into a constant and provide a helper function
to reduce duplication.

Further, update `read_common_config` to accept `impl AsRef<Path>` to make
calling the function easier.

Reviewed By: farnz

Differential Revision: D21202528

fbshipit-source-id: 96cad817ed47be0f207965ad2bc33af13ca8b5fd
2020-04-23 07:43:37 -07:00
Stanislau Hlebik
3193f4fab3 mononoke: fail with non-zero exit code in serve_forever if failure happened
Summary:
Previously our jobs would have exit with error code 0 even if there was an
actual error. The reason for this was because error was just ignored (or rather
just printed to stderr).
This is not a huge problem but it makes tw output confusing - it shows that
the task was "Completed" while in reality it "Failed"

Reviewed By: ahornby

Differential Revision: D20693297

fbshipit-source-id: 4f615e2ef11f2edbb9bdbcf49cb1635929fdae89
2020-04-17 14:57:56 -07:00