Commit Graph

29 Commits

Author SHA1 Message Date
Thomas Orozco
c2c904f933 mononoke: initialize loggers, config, caching, tunables & runtime in MononokeMatches
Summary:
Basically every single Mononoke binary starts with the same preamble:

- Init mononoke
- Init caching
- Init logging
- Init tunables

Some of them forget to do it, some don't, etc. This is a mess.

To make things messier, our initialization consists of a bunch of lazy statics
interacting with each other (init logging & init configerator are kinda
intertwined due to the fact that configerator wants a logger but dynamic
observability wants a logger), and methods you must only call once.

This diff attempts to clean this up by moving all this initialization into the
construction of MononokeMatches. I didn't change all the accessor methods
(though I did update those that would otherwise return things instantiated at
startup).

I'm planning to do a bit more on top of this, as my actual goal here is to make
it easier to thread arguments from MononokeMatches to RepoFactory, and to do so
I'd like to just pass my MononokeEnvironment as an input to RepoFactory.

Reviewed By: HarveyHunt

Differential Revision: D27767698

fbshipit-source-id: 00d66b07b8c69f072b92d3d3919393300dd7a392
2021-04-16 10:27:43 -07:00
Simon Farnsworth
0f817c72fb Provide an admin command for blobstore unlink
Summary: Currently just does XDB Blobstore, because the work to do other types and/or go via Packblob is significant.

Reviewed By: markbt

Differential Revision: D27735093

fbshipit-source-id: d3797017a2e0ff7c60525d1f4d4ee3e63b519d49
2021-04-13 08:38:29 -07:00
Stanislau Hlebik
e40aceac52 mononoke: add admin command to do blobstore upload
Reviewed By: farnz

Differential Revision: D26948394

fbshipit-source-id: 646be0e952e98c9e8cd2b6cdf93d4366e234202e
2021-03-10 11:16:19 -08:00
Thomas Orozco
097e4ad00c mononoke: remove tokio-compat (i.e. use tokio 0.2 exclusively)
Summary:
The earlier diffs in this stack have removed all our dependencies on the Tokio
0.1 runtime environment (so, basically, `tokio-executor` and `tokio-timer`), so
we don't need this anymore.

We do still have some deps on `tokio-io`, but this is just traits + helpers,
so this doesn't actually prevent us from removing the 0.1 runtime!

Note that we still have a few transitive dependencies on Tokio 0.1:

- async-unit uses tokio-compat
- hg depends on tokio-compat too, and we depend on it in tests

This isn't the end of the world though, we can live with that :)

Reviewed By: ahornby

Differential Revision: D26544410

fbshipit-source-id: 24789be2402c3f48220dcaad110e8246ef02ecd8
2021-02-22 09:22:42 -08:00
Kostia Balytskyi
dc2e1a850f admin: create a subcommand for a rebase
Summary:
This allows to create a changeset clone with p1 changed. Essentially, this is a
bonsai-only rebase without any safety checks. The safety of this operation
(i.e. the usability of the resulting changeset) is highly dependent on the
context the ultimate responsibility is on the person running this command. For
instance, this does not do *any conflict checks*. As such, this is really only
useful to rebase additions/deletions/modifications of unchanged files.

Reviewed By: StanislavGlebik

Differential Revision: D25947017

fbshipit-source-id: 4093c432e4f8ba2a647ee4b17c6840c33d13be81
2021-02-16 16:11:59 -08:00
Alex Hornby
0f25acc8ab mononoke: update admin to use new common cmdlib scrub action argument
Summary: Update to use the new common argument from cmdlib version

Reviewed By: krallin

Differential Revision: D25976404

fbshipit-source-id: a1089b82e6455254fed32317e76764498dcfa130
2021-02-05 01:19:54 -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
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
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
Mark Juggurnauth-Thomas
1b8b8cc099 admin: add skeleton manifests to admin command
Summary:
Add skeleton manifests to `derived-data verify-manifests` and add a
`skeleton-manifests` subcommand that allows listing and traversing of skeleton
manifests.

Since skeleton manfiests don't contain the content id or file type, they are
valid simply if they contain the same set of files as the manifest we are
comparing against.

To allow testing of these items while backfilling is still in progress, add an
`--if-derived` option to these commands that work even if derivation is
disabled, provided the manifest has already been derived.

Reviewed By: ikostia

Differential Revision: D25064785

fbshipit-source-id: a6f923bfc53262a5b2118917f8fdd3e99407e036
2020-11-30 06:23:46 -08:00
Alex Hornby
14128ce2dc mononoke: remove unnecessary .version("0.0.0") in clap App setup
Summary: We don't need to declare a fake empty version number

Reviewed By: farnz

Differential Revision: D24757981

fbshipit-source-id: 594c97e225704d783bea723efcbb9dfc4d5d800b
2020-11-06 02:23:46 -08:00
Egor Tkachenko
f44014de6f Add new command create bonsai
Summary:
We can have different bonsai changesets hash for the same hg changeset. Consider situation - we have hg repo:
```
  o  B (Add file "b")
  │
  o  A (Add file "a")
```
The correct bonsai changeset for B will have only entry `(<Path_to_b>,Some(<hash_b>))` in `file_changes`. But we can also have bonsai changeset for B with 2 entries `(<Path_to_b>,Some(<hash_b>)), (<Path_to_a>,Some(<hash_a>))`. This diff provides the functionality to manually create such situation. And later it will be used for verification blobimport backups

Reviewed By: StanislavGlebik

Differential Revision: D24589387

fbshipit-source-id: 89c56fca935dffe3cbfb282995efb287726a3ca9
2020-11-04 01:29:42 -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
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
Stanislau Hlebik
ea92153c36 mononoke: add a pushrebase command to mononoke_admin
Summary:
a simple command that can be used to pushrebase a commit. Note that this
command is very low level so it skips a lot of checks that we do during the
normal push process (e.g. it doesn't run hooks).

Reviewed By: krallin

Differential Revision: D24534960

fbshipit-source-id: 0f1e27005fa450c86c310d66e3215747ca6a49e2
2020-10-26 04:57:44 -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
Stanislau Hlebik
87f26ebe8d mononoke: admin rsync command
Summary:
This is a command that creates a commit that copies one directory into another.
Later you can take a commit and push it.

At the moment the command is very simple and also not very useful. At the very
least we need a way to limit the size of the commit, and this option is coming
in the next diff.

Note that the command doesn't overwrite the files if they exist in the target
directory - we may add an option to do so in future. Also if a file exists in
target directory but doesn't exist in source directory then it's left
untouched.

Reviewed By: ikostia

Differential Revision: D24451568

fbshipit-source-id: 2c7b945aadc99a1ca960349992c3684ef02ba35e
2020-10-22 13:01:25 -07:00
Thomas Orozco
179e4eb80e mononoke/admin: add a subcommand for dumping paths
Summary:
This adds a subcommand for dumping all the paths in a repository. This is
helpful when you have a Content ID, limited imagination and time on your hands,
and you'd like to turn those into a file path where that Content ID lives.

This uses fsnodes for the traversal because that's O(# directories) as opposed
top O(# files). I had an earlier implementation that used unodes, but that was
really slow.

Reviewed By: StanislavGlebik

Differential Revision: D23471561

fbshipit-source-id: 948bfd20939adf4de0fb1e4b2852ad4d12182f16
2020-09-03 09:32:06 -07:00
Kostia Balytskyi
1e5a0dc4db admin: add crossrepo config subcommand
Summary: This is to be able to inspect `LiveCommitSyncConfig` from our admin tooling.

Reviewed By: StanislavGlebik

Differential Revision: D22497065

fbshipit-source-id: 3070890b7dc2a4075a5c15aca703494e33ee6530
2020-07-22 07:34:59 -07:00
Mark Thomas
a51d164892 admin: increase type_length_limit
Reviewed By: ikostia

Differential Revision: D22476055

fbshipit-source-id: 1df7556a5cf774744b26f09e3ed681cceb30c617
2020-07-10 05:55:06 -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
Kostia Balytskyi
7141232a6d admin: move arg definitions into subcommand files
Summary:
Now that subcommand building is extracted into separate files, it feels logical
to also put arg definitions there.

Reviewed By: StanislavGlebik

Differential Revision: D21143851

fbshipit-source-id: fee7ce72a544cf66e6bc26b7128aa95b2b9ea5f3
2020-04-21 02:30:08 -07:00
Kostia Balytskyi
1e95aa7293 admin: move subcommand definitions into subcommand files
Summary:
This feels like a more natural place to store them. Also, it will make
`main.rs` more readable.

Reviewed By: StanislavGlebik

Differential Revision: D21143850

fbshipit-source-id: 6ab3ec268beea92d7f897860f7688a775d60c4bf
2020-04-21 02:30:07 -07:00
Kostia Balytskyi
220edc6740 admin: add a subcommand to manipulate mutable_counters
Summary:
This is generally something I wanted to have for a long time: instead of having to open a writable db shell, now we can just use the admin command. Also, this will be easier to document in the oncall wikis.

NB: this is lacking the `delete` functionality atm, but that one is almost never needed.

Reviewed By: krallin

Differential Revision: D21039606

fbshipit-source-id: 7b329e1782d1898f1a8a936bc711472fdc118a96
2020-04-16 03:19:44 -07:00
Jeff Zhang
c517e81329 Push compat down deeper into subcommands & make subcommand functions async in eden/mononoke/cmds/admin/main.rs
Summary: Continue to push `compat()` deeper into subcommands. This enables us to refactor each file one at a time and ultimately remove the old futures from our code base.

Reviewed By: farnz

Differential Revision: D20132126

fbshipit-source-id: cc10dde6eda7ddcbf911dbe8d3ebe1713f8ec2ab
2020-02-27 12:39:28 -08:00
Jeff Zhang
33140b117c Push compat down one level in eden/mononoke/cmds/admin/main.rs
Summary: Moving `compat` one level down to the call sites of subcommand functions.

Reviewed By: farnz

Differential Revision: D20085398

fbshipit-source-id: 461e147d2ae6e560b3a75fb92fa6b23f9f54d13e
2020-02-25 10:22:03 -08:00
Lukasz Piatkowski
542d1f93d3 Manual synchronization of fbcode/eden and facebookexperimental/eden
Summary:
This commit manually synchronizes the internal move of
fbcode/scm/mononoke under fbcode/eden/mononoke which couldn't be
performed by ShipIt automatically.

Reviewed By: StanislavGlebik

Differential Revision: D19722832

fbshipit-source-id: 52fbc8bc42a8940b39872dfb8b00ce9c0f6b0800
2020-02-11 11:42:43 +01:00
Lukasz Piatkowski
e8d62b64d5 mononoke: move the codebase under eden/ directory
fbshipit-source-id: 43a0252cb3ec42aa365f20d1b6faa4d24d74c9b8
2020-02-06 13:46:04 +01:00