Commit Graph

2727 Commits

Author SHA1 Message Date
Xavier Deguillard
6834785a45 cli_rs: add uptime
Summary: This implements the same logic as the `edenfsctl uptime`.

Reviewed By: fanzeyi

Differential Revision: D26412789

fbshipit-source-id: ebcf5f0b4767025ea210f7e9c69116b79436d5d0
2021-02-12 15:21:31 -08:00
Zeyi (Rice) Fan
5e5d334718 cli: one comma bug
Summary: comma_khan

Reviewed By: singhsrb

Differential Revision: D26408197

fbshipit-source-id: ccdf6d070069a870e3fa71b1d4f1b42239a7c203
2021-02-12 14:53:23 -08:00
Xavier Deguillard
621cadd6d6 cli_rs: add a default 3s connection timeout for health checks
Summary:
In Python, no passed in timeout means a 3s connection timeout, let's do the
same in Rust.

Reviewed By: chadaustin

Differential Revision: D26407991

fbshipit-source-id: ad2919e2cb72e5a113499d7e036ae285ecf9ae34
2021-02-12 14:38:22 -08:00
Zeyi (Rice) Fan
18b79205c8 cli: add get_config to EdenFsInstance
Summary: You can use `instance.get_config()` to get access to global EdenFS configurations

Reviewed By: chadaustin

Differential Revision: D26407350

fbshipit-source-id: 022cc59fd86b2711c15cfd781872465c6ada9081
2021-02-12 14:23:17 -08:00
Xavier Deguillard
b63f46c673 cli_rs: add pid command
Summary: This simply queries the pid from thrift.

Reviewed By: kmancini

Differential Revision: D26406797

fbshipit-source-id: 1d5d1b2d526e1de505d72747a5c903001b141d40
2021-02-12 13:47:48 -08:00
Zeyi (Rice) Fan
7de8d6a595 cli_rs: add edenfs-config for configuration loading
Summary:
This diff adds `edenfs-config` for loading EdenFS configurations from various
locations.

Reviewed By: xavierd

Differential Revision: D26391272

fbshipit-source-id: 3d34da98b2d530e13cdd831d3dc204e44304c486
2021-02-12 12:33:48 -08:00
Zeyi (Rice) Fan
8290ea3545 cli_rs: add stack config proc macro
Summary:
**Problem:** EdenFS has the classic hierarchical configuration design. We load from `/etc/eden/edenfs.rc` first, then `/etc/eden/conf.d/*` then `$HOME/.edenrc`. The latter can overwrite the former. At the end we have a complete view of the configurations.

`serde` is great, but it can't give us the information of whether it generated a field from `serde(default)` or from de-serialization. So we can't just deserialize then merge the configuration files. We need that information, and nor serde should give us that functionality.

`stack-config` is created to load configurations with serde. It automatically generates code with the intermediate data structure and taking care of merging of multiple configuration files. It derives a data type based on the original struct but wrap each field with `Option<T>` and mark it with Serde. Then it generates the code to merge and build the final concrete configuration data type.

It does not care what kind of data format the configuration file is, as long as it can deserialize into the generate optional type, it accepts it.

Example, say I have a file with this structure:

```
#[derive(StackConfig)]
struct Config {
  path: String,
}
```

Then this crate will generate:

```
mod __stack_config_private {
  #[derive(serde::Deserialize)]
  pub(super) struct ConfigOpt {
    path: Option<String>
  }

  ...
}

struct ConfigLoader {
  layers: Vec<__stack_config_private::ConfigOpt>,
}

impl ConfigLoader {
  fn new() { ... }
  fn load(&mut self, layer: __stack_config_private::ConfigOpt> { ... }
  fn build(self) -> Config { ... }
}
```

See `examples/parse.rs` for usage.

Reviewed By: xavierd

Differential Revision: D26377547

fbshipit-source-id: 1e07d9867742913fd76ed4f765160f0035a2f2a3
2021-02-12 12:33:47 -08:00
Zeyi (Rice) Fan
c601c6a46d cli_rs: set up debug logging
Summary: This diff sets up debug logging for EdenFS CLI with tracing.

Reviewed By: chadaustin

Differential Revision: D26354205

fbshipit-source-id: bcc89fe3eaf4c7ae7642b8c20fd74fd3ea6dd4ee
2021-02-12 12:33:47 -08:00
Zeyi (Rice) Fan
bd321ea0e3 cli_rs: reorganize Rust package structure
Summary: This diff splits edenfsctl binary target into several smaller crates.

Reviewed By: chadaustin

Differential Revision: D26349305

fbshipit-source-id: 8c506d50fd2bf8593a02a95ed2c839c0cbc62fb2
2021-02-12 12:33:46 -08:00
Zeyi (Rice) Fan
a3ddd302a5 cli_rs: implement status in Rust
Summary: This diff reimplements `edenfsctl status` in the Rust wrapper.

Reviewed By: chadaustin

Differential Revision: D25759315

fbshipit-source-id: 86ae4e89f74b41446cc52f106afd1e1e78c36d76
2021-02-12 12:33:46 -08:00
generatedunixname89002005307016
d59ae291e7 Add annotations to eden/fs/cli/top.py
Reviewed By: xavierd

Differential Revision: D26424699

fbshipit-source-id: 5980fb10640e904f31d299a8f6c510dd16533fa5
2021-02-12 11:38:44 -08:00
generatedunixname89002005307016
0eaf0f0dfe Add annotations to eden/fs/cli/top.py
Reviewed By: xavierd

Differential Revision: D26402730

fbshipit-source-id: 391442cae29e6c7ba686970e096a67c94ab0a091
2021-02-11 16:22:30 -08:00
Xavier Deguillard
7a0dec91ec cli: strictify all of the cli tests
Summary:
While I was fixing the cli_test I realized that the rest of the tests didn't
enforce strict type checking, let's make sure it is enabled so `pyre -l eden`
works for all the tests now and in the future.

Reviewed By: chadaustin

Differential Revision: D26356267

fbshipit-source-id: 4f026b6f96c410115a6a38d772f8e06ab977293b
2021-02-10 20:11:04 -08:00
Xavier Deguillard
ddb7859ffd cli: make macOS new clone case-insensitive
Summary:
The default filesystem on macOS (APFS) is case-insensitive, but EdenFS has so
far been case-sensitive except on Windows. Some of the native tools (Unity for
instance), expect macOS to always be case-insensitive, and is thus breaking due
to that.

The safe behavior would be to have EdenFS behave exactly the same as APFS: be
case insensitive. For now, to avoid breaking users this will be done on new
mounts only, and once fully validated, this will be made the default and forced
on.

Reviewed By: chadaustin

Differential Revision: D26356269

fbshipit-source-id: 96ca331d8c9726213520dff3e3563019d0400a95
2021-02-10 20:11:04 -08:00
Zeyi (Rice) Fan
dc22fd8777 add a wrapper to combine both Python & Rust EdenFS CLI
Reviewed By: xavierd

Differential Revision: D25792324

fbshipit-source-id: 2e54f27caa830076168b7f178b6a95718eeb9f92
2021-02-10 16:52:07 -08:00
Zeyi (Rice) Fan
f55a022f89 cli: introduce Rust wrapper
Summary:
This diff adds a Rust wrapper that will forward any command it fails to parse
to the companion binary `edenfsctl.real` at the same directory. This will allow
us to rewrite some of the subcommands in Rust while keeps the original
functionality.

With `EDENFSCTL_SKIP_RUST` environment variable set, it will skip the argument
parsing process in case of any emergency situation.

Reviewed By: xavierd

Differential Revision: D25758959

fbshipit-source-id: 0fbc69d0e0733ad2608622417be93dc7db2d6fa6
2021-02-10 16:52:06 -08:00
Xavier Deguillard
74a34dd8c4 fs: default initialize XdrVariant
Summary:
My understanding of C++ not being perfect, I thought that these 2 fields would
be default initialized, but it turns out this is wrong, and the values of these
would be whatever is on the stack at the time a non-initialized variant is
used. The XdrSerialize variant test exercise this case and fails when optimized
due to that, this change fixes it.

Reviewed By: chadaustin, fanzeyi

Differential Revision: D26371695

fbshipit-source-id: 489cac846b51508809783bb577c7a97c4e6c060a
2021-02-10 13:18:46 -08:00
Xavier Deguillard
62076b545e inodes: move dispatchers around
Summary:
Instead of having one "Dispatcher" type that the various backend overload,
let's simply have a per-mount type dispatcher type. The previous model worked
fine when EdenFS supported only one way of mounting a repository, but with NFS
coming, unix platform will support both FUSE and NFS, making the Dispatcher
overload nonsensical.

As a behavioral change, the dispatcher lifetime and ownership is changed a bit.
It used to live for the duration of the EdenMount object, but is now tied to
the channel lifetime, as it is now owned by it.

Reviewed By: kmancini

Differential Revision: D26329477

fbshipit-source-id: 3959b90a4909e3ab0898caa308f54686f59a943c
2021-02-10 11:52:06 -08:00
Xavier Deguillard
c41bf98c58 test: type-check cli_test
Summary:
As I'm modifying the definition for CheckoutConfig, I'm heavily relying on
`pyre` to tell me about the places I need to fix, but this test not being type
checked means that pyre misses it.

Reviewed By: chadaustin

Differential Revision: D26356268

fbshipit-source-id: 2139c0053b182e656074de3117ee1950e519f19a
2021-02-10 08:49:51 -08:00
Xavier Deguillard
c30d62253c nfs: implement PATHCONF
Summary: The PATHCONF call gather various POSIX attribute for the passed in file-handle.

Reviewed By: kmancini

Differential Revision: D26270239

fbshipit-source-id: 96a46c58402ce169cacc789c1df3f05f969dcd33
2021-02-09 12:47:14 -08:00
Xavier Deguillard
e28b909fa6 nfs: add various enums/structs for the PATHCONF call
Summary: This just adds them.

Reviewed By: kmancini

Differential Revision: D26270240

fbshipit-source-id: cae9ff0278ab9a542b5ad7a5c6c2e8c3cc26b1b0
2021-02-09 12:47:14 -08:00
Xavier Deguillard
578ceb1cf0 nfs: fill in the FSINFO procedure
Summary:
The FSINFO procedure is used to collect information about this mount point and
its limits. For now, I've just used random values for most of these, I'll come
back to it later to figure out the ones that makes sense.

Reviewed By: kmancini

Differential Revision: D26269947

fbshipit-source-id: e5fdd961ea7772926208916de0179721930daeab
2021-02-09 12:47:13 -08:00
Xavier Deguillard
25a1ebc16b nfs: store and use straceLogger
Summary: Instead of using a plan DBG7, let's use the strace logger to log the RPC calls.

Reviewed By: kmancini

Differential Revision: D26269946

fbshipit-source-id: e8ab7acc658463b9f0f1d4c420f63b2e0c88f46a
2021-02-09 12:47:13 -08:00
Xavier Deguillard
b8f628d344 nfs: add various enums/structs for the FSINFO call
Summary: These will be needed when implementing FSINFO.

Reviewed By: kmancini

Differential Revision: D26268588

fbshipit-source-id: 8160f00e988a088769ad682a6de062f6c0443c73
2021-02-09 12:47:12 -08:00
Xavier Deguillard
a7741ba0a3 nfs: add std::monostate to XdrVariant
Summary:
Variant are default constructed with the first variant alternative, which means
that when deserialization would not deserialize anything, the first variant
would be initialized. This would mean that deserialize(serialize(myVariant))
would be different from myVariant, which is unexpected.

Reviewed By: kmancini

Differential Revision: D26268586

fbshipit-source-id: ebfd7f9e473509b2a16acdbb6914e828c67c5005
2021-02-09 12:47:12 -08:00
Xavier Deguillard
2f754b2305 inodes: attempt to NFS mount
Summary:
With the PrivHelper now being able to try to NFS mount, we can just plug it in
the EdenMount code to actually attempt to mount EdenFS via NFS.

The mount will expectedly fail due to the FSINFO RPC not being implemented just
yet, but that will be the next step.

Reviewed By: kmancini

Differential Revision: D26266143

fbshipit-source-id: a44ae98af76b55a0c24c89e766c072c1a2e1b4fd
2021-02-09 12:47:11 -08:00
Xavier Deguillard
91336a090e nfs: add NfsServer class
Summary:
This will be the main entry point for everything related to the various NFS
programs. For now, it simply starts an nfsd program when registering a new
mount point and returns the ports that mount(2) should use to connect to it.

Reviewed By: kmancini

Differential Revision: D26204060

fbshipit-source-id: 115d2d206109499d5b49c529ebf1f739fc364c23
2021-02-09 12:47:11 -08:00
Xavier Deguillard
fcffed9226 nfs: explicitely pass the EventBase to run the RpcServer on
Summary:
Using the current EventBase can lead to unexpected behavior when the RpcServer
is created on the wrong thread. For instance, if it is created on a thread
pool, and another future is running on that same thread, the RpcServer won't be
able to accept and service new connections, potentially leading to deadlocks.

To avoid this, EdenFS's EventBase is excplicitely passed in, this will ensure
that the RpcServer is created on the proper thread.

Reviewed By: kmancini

Differential Revision: D26266145

fbshipit-source-id: 23211e3aa200c32d2f6fbbfd9ae6fb307896a873
2021-02-09 12:47:10 -08:00
Xavier Deguillard
235ccac7f3 nfs: ifdef it on Windows
Summary:
MSVC is broken as it doesn't understand the various macros used to generate
XdrTrait for specific types, and I can't figure out a way to make that work.
Even if I provide dummy version of these, the buck build breaks due to glog
trying to redefine the ERROR symbol that some Microsoft headers contain. For
now, let's just ifdef it out since it's unlikely that we're going to be using
NFS on Windows anytime soon.

Reviewed By: singhsrb

Differential Revision: D26293519

fbshipit-source-id: bbaf325c7d1f1688327708360244797a6d48179e
2021-02-05 21:22:56 -08:00
Xavier Deguillard
006989487c privhelper: add support for mounting NFS
Summary:
Since mounting EdenFS via NFS requires the same privilege as mounting EdenFS
with FUSE, let's re-use the PrivHelper infrastructure that FUSE already uses.

The macOS bit isn't yet implemented as developing on Linux is for now easier,
the mount args are also overly complicated on macOS and not well documented.

Reviewed By: fanzeyi

Differential Revision: D26255629

fbshipit-source-id: 295261dd40442fe7e0f9439c4f4c25e0d50211a3
2021-02-04 20:10:38 -08:00
Xavier Deguillard
17c99d69de cli: add a --nfs argument to eden clone
Summary: This enables the repository to be mounted via NFS, and not FUSE.

Reviewed By: chadaustin

Differential Revision: D26229827

fbshipit-source-id: 5af5a47ebe5f1dd54df7707bf57d9b7476921f29
2021-02-04 20:10:37 -08:00
Chad Austin
a887c14404 record all commit transitions in the journal
Summary:
Accumulate every commit transition in the journal, rather than
treating every merged range of journal deltas as having a "from"
commit and a "to" commit. This makes it possible for Watchman to
accurately report the set of changed files across an ABA situation or
rapid `hg next` and `hg prev` operations.

Reviewed By: genevievehelsel

Differential Revision: D26193478

fbshipit-source-id: 8b54b9d5bcefa1811008a3b6e9c3aa25a69471ca
2021-02-04 18:38:35 -08:00
Xavier Deguillard
efd291b3de nfs: add all the nfsv3 procedures and callbacks
Summary:
For now, they all pretend to not be available, except the null one which does
nothing as per the RFC.

Reviewed By: genevievehelsel

Differential Revision: D26159846

fbshipit-source-id: 8d0f43f6bacc5c5a93e883e527769cb7a3b6e22b
2021-02-04 12:38:22 -08:00
Xavier Deguillard
dde7b70712 nfs: make mountProcs an enum class
Summary: That way the NFS procedure won't clash with it.

Reviewed By: genevievehelsel

Differential Revision: D26159845

fbshipit-source-id: 22ce07326f9ec42aa9d44352ae5bb71368337c03
2021-02-04 12:38:21 -08:00
Xavier Deguillard
f7d3ef3596 nfs: add the skeleton of the nfsv3 program
Summary:
For now, this only registers itself against rpcbind and always reply that the
procedure is unavailable. In the future, this will service all the procedures
and forward them to a Dispatcher.

Reviewed By: genevievehelsel

Differential Revision: D26159844

fbshipit-source-id: 21908f1333ed41b3eea3fb5ce19c8e68391df103
2021-02-04 12:38:21 -08:00
Xavier Deguillard
33014208ca nfs: implement a dummy export procedure
Reviewed By: kmancini

Differential Revision: D26159847

fbshipit-source-id: d975ae37d79e095ec7a81fab00037df4c2c7afd4
2021-02-04 12:38:21 -08:00
Xavier Deguillard
5182b7f9b9 nfs: add some debug log for what is being replied
Summary:
We do have logs for what we receive, let's do the same for what we are sending
back.

Reviewed By: genevievehelsel

Differential Revision: D26152811

fbshipit-source-id: 8e605f78a8c849f3bd65b70be51617fc058330ff
2021-02-04 12:38:20 -08:00
Xavier Deguillard
82b7ea2033 nfs: fix InodeNumber serialization
Summary:
In the NFS spec, the fhandle3 is defined as an opaque byte array, and thus its
size must preceed its content. Let's also move it to an NfsdRpc.h as this type
will be predominantly used by the Nfsd RPC program.

Reviewed By: chadaustin

Differential Revision: D26152812

fbshipit-source-id: 0cc37325078a2c7b58551eaa5177436b21e03838
2021-02-04 12:38:20 -08:00
Xavier Deguillard
2bb4f7739f nfs: properly reply to MNT RPC call
Summary:
Now that we have the list of available mount points, we can properly reply to
the MNT RPC call.

Reviewed By: kmancini

Differential Revision: D26152810

fbshipit-source-id: f364292ead321689fb20f858aee45efdfbd7287d
2021-02-03 17:54:55 -08:00
Xavier Deguillard
ab0c780f52 nfs: controls whether Mountd should register itself with rpcbind
Summary:
For a proper NFS server, rpcbind is used to query and collect the port/protocol
of the mountd and nfs programs at mount time. In EdenFS, the mount.nfs command
will be run by EdenFS directly, against itself, and we can manually specify
what the ports are for both the mountd and nfs programs. Thus we can use these
directly to avoid polluting the rpcbind database, and potentially conflicting
with a real NFS server.

This will be particularly useful when testing EdenFS as this allows multiple
tests to run at the same time.

Reviewed By: kmancini

Differential Revision: D26140416

fbshipit-source-id: 6b8aa22e69f580a9d6f6edf775d268809a909118
2021-02-03 17:54:55 -08:00
Xavier Deguillard
22075c1159 inodes: start plumbing Mountd in the mount code.
Summary:
Once everything is plugged in, EdenFS will first register the mount point with
Mountd, and then execute the mount.nfs CLI against itself to mount the
repository with the OS.

For now, this does the first part by simply informing Mountd of a new mount
point during mount.

Reviewed By: kmancini

Differential Revision: D26139990

fbshipit-source-id: e5097b8e90c032c8c7bdd2cd03b69695074d7874
2021-02-03 17:54:54 -08:00
Xavier Deguillard
f20536cbaa inodes: add Mountd to the ServerState
Summary:
When NFS is enabled, we will need to have one mountd RPC program running to
be able to serve the mount requests, let's make sure that we have one by adding
it to the ServerState.

On top of the per-mount protocol setting added previously, I've also added a
global setting to make sure that we're not advertising ourself as an NFS server
before the code is more functional.

Reviewed By: genevievehelsel

Differential Revision: D26139991

fbshipit-source-id: 0d9e02618c931a0401394888ea8f3680974966b5
2021-02-03 17:54:54 -08:00
Xavier Deguillard
fc4b26c0ae nfs: make it compile with getdeps builds
Summary:
As the NFS bits are integrated into the rest of EdenFS, we need to make sure
the code compiles properly. The only major change was the removal of the
//common dependencies as these aren't available to OSS builds.

Reviewed By: genevievehelsel

Differential Revision: D26181750

fbshipit-source-id: 44f8ff335e543ab282f40fa7f8d28fc19cf4581c
2021-02-03 17:54:54 -08:00
Xavier Deguillard
990af745e2 config: add a per-repo mount protocol
Summary:
On macOS, EdenFS will soon be exposed as an NFS server. To ease the transition,
let's have a per-mount config to decide whether this repository should be
mounted via FUSE or NFS

Reviewed By: genevievehelsel

Differential Revision: D26139992

fbshipit-source-id: d28b0e2327c1101f3555ab0bbc9a5b03d82fd7ff
2021-02-03 16:45:37 -08:00
Xavier Deguillard
86114ab338 nfs: switch to the rpcbind protocol
Summary:
The portmap protocol is limited to IPv4, while the rpcbind not only does
support IPv4 and IPv6, but also unix sockets. While we still bind only to an
ipv4, this should allow us to support IPv6 in the future.

Reviewed By: kmancini

Differential Revision: D26114218

fbshipit-source-id: 46e4dfe60a9c1ddbccbb586bf4e3d24012fd26ee
2021-02-03 16:45:37 -08:00
Xavier Deguillard
c39674f372 nfs: use an XdrTrait instead of overloaded functions
Summary:
As I'm going through the various NFS specs, it becomes clear that variant are
widely used, and the macros to generate them is awkward and making working with
them harder than it should be. Instead writing their deserialization would be
more flexible.

While doing this, I also revamped how serialization/deserialization is done by
using a trait that contains 2 static function: serialize and deserialize, new
types are expected to specialize the XdrTrait with their own
serialization/deserialization.

Reviewed By: kmancini

Differential Revision: D26160026

fbshipit-source-id: 951bdd20620cc5715e780e99b64e15397688570d
2021-02-03 16:45:37 -08:00
Genevieve Helsel
a56153126b remove advice to run deprecated hg gc in eden du
Summary: `hg gc` is deprecated and does nothing anymore. Lets just remove this section talking about running `hg gc`

Reviewed By: chadaustin

Differential Revision: D26178391

fbshipit-source-id: 2bb16bbac38465a524ed50454d548564324d35bf
2021-02-03 15:32:08 -08:00
Xavier Deguillard
eec9a34e3f nfs: fix RPC server lifetime
Summary:
The folly::async bits are a bit complicated to get right in particular around
its lifetime management. The solution that is used in our codebase is to make
use of a folly::DelayedDestruction and the DestructorGuard. As long as a
DestructorGuard is alive, the object cannot be destroyed, and thus we can
simply hold a guard in the Reader, and make sure that a guard is held during
the future callbacks.

The only thing to be aware of is that the DestructorGuard is not thread safe,
but since all the callbacks and futures are running in the context of the
single threaded event base, this is not an issue.

Reviewed By: chadaustin

Differential Revision: D26105288

fbshipit-source-id: 4c7b91eca2bc1cae66d8d1724931b20340740574
2021-02-01 11:49:16 -08:00
Xavier Deguillard
9c46dd87b6 nfs: unregister self with portmap on destruction
Summary:
When the RPC server starts, it registers itself against the global rpcbind
daemon to allow RPC clients to reach it. However, it never unregisters itself
when it is destructed, leading to the rpcbind daemon having outdated
information. It also prevents a future RPC server for the same program and
version to register itself.

To fix this, we can simply unregister on destruction. The MountdUtil binary is
also fixed to be able to interrupt it with ctrl+c.

Reviewed By: chadaustin

Differential Revision: D26105289

fbshipit-source-id: c9c3d552ec04a78025d6ff715a425f9ec3aa1328
2021-02-01 09:28:41 -08:00
Xavier Deguillard
5fbeb13f82 nfs: add mountd scaffolding
Summary:
In NFSv3, mounting is not part of the NFS program but is done in a separate
program. This adds the basic scaffolding to reply to the NULL procedure for the
mount protocol. Later, this will be enhanced by having `eden mount` first
register a mount point to Mountd, then trigger a `mount.nfs` against localhost
where Mountd will be able to reply properly.

Similarly to PortMapUtil, I've added a small binary that allows for a "mountd"
process to be spawned. Note that since the code doesn't yet answer properly to
the mount procedure, nfusr closes the connection and retries, causing mountd to
crash due to RpcServer being unsafe on error, this will be fixed separately.

Reviewed By: chadaustin

Differential Revision: D26033504

fbshipit-source-id: 27f90d9072a93460a3a383aadde38e50801e3e87
2021-02-01 09:28:41 -08:00