Commit Graph

2762 Commits

Author SHA1 Message Date
Blake Dixon
6bc3f2c8b2 Remove deprecated calls to value_unchecked
Summary: Remove deprecated calls to value_unchecked and slightly clear up existing code flow.

Reviewed By: xavierd

Differential Revision: D26666359

fbshipit-source-id: 3dbc621508b23745b232cad2c8cbe2d6d4751d0e
2021-02-25 12:13:33 -08:00
Chad Austin
a152fa4585 add C++ implementation of trace hg
Summary:
Migrate away from streaming Thrift Python, and instead implement `eden
trace hg` in C++, which will eventually let us support Windows.

This also fixes an unexplained crash in `eden trace hg` on macOS.

Reviewed By: xavierd

Differential Revision: D25515377

fbshipit-source-id: 1916aa7f09df37e9dee3479a858932c724f8aed4
2021-02-25 11:31:00 -08:00
Genevieve Helsel
8b057b96e2 use shared pointers in HgImportRequestQueue
Summary: This diff sets up the ability for us to track requests as they are shuffled around in the `std::vector<> queue`. Since the queue is a vector, and since it is sorted everytime a new element is added or removed, we cannot keep track of elements in the queue with indices or references. Instead, we will store the requests in a shared_ptr so we can maintain a pointer to the request no matter where the request is moved around to.

Reviewed By: kmancini

Differential Revision: D26355907

fbshipit-source-id: d714d689963106a4f495221dbcfcbab758ffc7b2
2021-02-25 09:19:49 -08:00
Chad Austin
735c031697 cli_rs: add the gc command
Reviewed By: xavierd

Differential Revision: D26412700

fbshipit-source-id: 0140250a2fa54a51fc1ef892cf20548807527615
2021-02-24 11:21:30 -08:00
Xavier Deguillard
7f3bf0dfe1 nfs: translate error to nfsstat3
Summary:
NFS clients will act differently depending on what kind of error is returned
from an RPC. A NFS3ERR_NOENT in response to a LOOKUP RPC may for instance
populate a negative lookup cache to avoid re-querying the same file again.
Thus, we need to translate the various errors with their corresponding
nfsstat3 values.

Reviewed By: genevievehelsel

Differential Revision: D26597788

fbshipit-source-id: d22a552196a378d6d7e9cd374e63bb8bcf436ce4
2021-02-24 08:30:01 -08:00
Chad Austin
68cf44a8d1 add eden glob command
Summary:
It's silly to use `eden prefetch --no-prefetch` to efficiently glob
for filenames. Introduce an `eden glob` command which resolves a glob
relative to the current working directory.

Reviewed By: genevievehelsel

Differential Revision: D25450358

fbshipit-source-id: 45d6dc870d21510e51d5662c75e80385886899fc
2021-02-23 19:58:03 -08:00
Chad Austin
7a3ac07f7f move EdenError to utils/
Summary:
I want to use EdenError from some code outside of service/, so move
EdenError into utils.

Reviewed By: genevievehelsel

Differential Revision: D25447438

fbshipit-source-id: 2d1ddfa379238369679e84708518a9ba106f76b9
2021-02-23 19:58:03 -08:00
Chad Austin
c6c871edb8 log returned inode numbers from lookup/create/mkdir
Summary:
As useful as `eden strace` can be, it's hard to correlate inode
numbers to their filenames via the mkdir/create/lookup request that
returned the inode. Add logging for result codes.

Reviewed By: kmancini

Differential Revision: D26287958

fbshipit-source-id: dae4b56513831185b038546f238938b0d21a6bad
2021-02-23 12:27:10 -08:00
Xavier Deguillard
8853701e91 path: forbid building non-utf8 paths
Summary:
The world has moved on utf-8 as the default encoding for files and data, but
EdenFS still accepts non utf-8 filenames to be written to it. In fact, most of
the time when a non utf-8 file is written to the working copy, and even though
EdenFS handles it properly, Mercurial ends up freaking out and crash. In all of
these cases, non-utf8 files were not intentional, and thus refusing to create
them wouldn't be a loss of functionality.

Note that this diff makes the asumption that Mercurial's manifest only accept
utf8 path, and thus we only have to protect against files being created in the
working copy that aren't utf8.

The unfortunate part of this diff is that it makes importing trees a bit more
expensive as testing that a path is utf8 valid is not free.

Reviewed By: chadaustin

Differential Revision: D25442975

fbshipit-source-id: 89341a004272736a61639751da43c2e9c673d5b3
2021-02-23 11:35:12 -08:00
Xavier Deguillard
f13657a519 nfs: add RPC types for LOOKUP
Summary:
LOOKUP is the next RPC that EdenFS needs to implement, let's start by adding
the RPC types.

Reviewed By: kmancini

Differential Revision: D26562919

fbshipit-source-id: 3a4ce1a039b6405df9ff94757963aa46acf56d92
2021-02-22 22:40:41 -08:00
Xavier Deguillard
f9207ae00c nfs: implement the ACCESS RPC
Summary:
The ACCESS RPC merely tries to see if a client can perform some action on a
file/directory. Until we have a better story around checking the RPC
credentials and passing it around, let's just return the requested access
rights as-is.

Reviewed By: kmancini

Differential Revision: D26562918

fbshipit-source-id: 468e038cc063c289b5554f3faa6a7f99be2731e4
2021-02-22 22:40:40 -08:00
Xavier Deguillard
d364f91b71 nfs: add RPC types for ACCESS
Summary: This merely add the types necessary to implement the ACCESS RPC

Reviewed By: kmancini

Differential Revision: D26562920

fbshipit-source-id: 2f3238e723e97a54896fabb026adf9b92ab4fcd3
2021-02-22 22:40:40 -08:00
Xavier Deguillard
206d0ced85 nfs: fix RpcServer lifetime
Summary:
Take 2 of fixing the lifetime issues of the RpcServer, this time, the
RpcAcceptCallback needs to live for longer than RpcServer itself. This is due
to the acceptStopped callback being called after RpcServer is being destroyed.
Since the RpcServer needs to be destroyed in the EventBase thread, the
acceptStopped callback is delayed, causing it to be invoked after the RpcServer
has freed its memory.

To solve this, we simply need to make the RpcAcceptCallback a delayed
destructor, and hold a reference to itself that goes away once the
acceptStopped callback is called.

Reviewed By: kmancini

Differential Revision: D26556644

fbshipit-source-id: 32cd80f1664649c1ad96f88c4eec6dd2ed6e8c12
2021-02-22 22:40:40 -08:00
Xavier Deguillard
52f2984156 inodes: call nfsUnmount when unmounting
Summary:
Now that the privhelper has the necessary code to unmount an NFS mount, let's
do it. With this in place, this enables `eden mount` and `eden unmount` for NFS
mounts. Unfortunately, it appears that during unmount, releasing the Nfsd3
object triggers a use-after-free in the rpc code

Reviewed By: kmancini

Differential Revision: D26500109

fbshipit-source-id: a210761f818b28b1eb0044f7314a0e2b9017848c
2021-02-22 22:40:39 -08:00
Xavier Deguillard
9f172f672a privhelper: add an nfsUnmount command
Summary: This merely unmount the repo.

Reviewed By: kmancini

Differential Revision: D26500108

fbshipit-source-id: 24b236eee734df02043449d49ece49f421d0e826
2021-02-22 22:40:39 -08:00
Xavier Deguillard
c9bfb4b2f7 fs: use an nfs request timeout confir
Summary:
This is merely fixing a typo that I made previous where I reused the prjfs
request timeout instead of adding a new one.

Reviewed By: kmancini

Differential Revision: D26500110

fbshipit-source-id: b9bf0cbc0d74866cdc2471f126751d6d8e514e21
2021-02-22 22:40:39 -08:00
Xavier Deguillard
79888e20b4 inodes: mount plumbing
Summary:
Now that `mount(2)` complete, we can start plumbing the rest of the mount code
to accomodate for NFS. Trying to find a common ground between Prjfs, FUSE and
Prjfs is harder than I wish it would be and thus I wasn't able to find a
satisfatory solution. For now, I went with a std::variant that stores either a
FuseChannel, or the Nfsd3. In the future once Nfs is stabilized and we have a
good understanding of how it differs (and where it doesn't), EdenMount would
probably need a good refactoring.

Reviewed By: kmancini

Differential Revision: D26500111

fbshipit-source-id: f02a2eaf8890261f150d7cdd2cdfd134aa62c2aa
2021-02-22 22:40:38 -08:00
Chad Austin
2e0e5ee0ea cli_rs: explicit annotation of subcommand help text
Summary:
Comments affecting runtime behavior disturbs me, so use explicit
structopt annotations on help text. And move those annotations to the
command implementations.

Reviewed By: fanzeyi

Differential Revision: D26412452

fbshipit-source-id: 066dfdd1c54254bae4bd2af65031487b7a1094da
2021-02-22 14:11:37 -08:00
Chad Austin
89ab1a37b7 cli_rs: enable help for subcommands and disable version flags
Summary: clap/structopt adds a -V flag to every subcommand by default. Disable that.

Reviewed By: fanzeyi

Differential Revision: D26412093

fbshipit-source-id: 03a0320fd15444f700b359f5ed0ca8c40b10ae1c
2021-02-22 14:11:37 -08:00
Chad Austin
02b024899e cli_rs: add an environment variable to avoid Python CLI bypass
Summary:
I don't want the fallback when testing, so add an environment variable
for bypassing it.

Reviewed By: fanzeyi

Differential Revision: D26411754

fbshipit-source-id: f2aea82bf3e79db11e72ad5f5ce33513cfc2f05b
2021-02-22 14:11:37 -08:00
Chad Austin
4c278e3278 cli_rs: allow returning errors from subcommands
Summary:
Rather than offloading dealing with unexpected errors to each
subcommand, allow them to propogate out. Subcommands can still be
responsible for handling expected "errors" like EdenFS not running.

Reviewed By: fanzeyi

Differential Revision: D26411186

fbshipit-source-id: 4e1c5fb1d7bed495e3e22cca44d3f84f7f4c7f14
2021-02-22 14:11:36 -08:00
Chad Austin
c039664a55 log the creation mode as octal
Summary:
We should be consistent about how we render mode_t across all of the
FUSE requests.

Reviewed By: singhsrb

Differential Revision: D26286527

fbshipit-source-id: aadf247c0621be79525c4df2da2940c02ee27719
2021-02-22 12:53:56 -08:00
Xavier Deguillard
dab46d37c6 inodes: pass caseSensitive to channel constructor
Summary:
By passing the argument to the channel, we can make it so that the NFS code
correctly replies to whether it is case sensitive or not.

Reviewed By: kmancini

Differential Revision: D26500112

fbshipit-source-id: 2988eae403ff3648b50a1a8f0c978be2828ba568
2021-02-22 08:43:48 -08:00
generatedunixname89002005307016
c590205cc3 Add annotations to eden/fs/cli/prefetch_profile.py
Reviewed By: xavierd

Differential Revision: D26570975

fbshipit-source-id: 673f9f608212b1d6fa40034496e81ca7a59988ca
2021-02-22 08:19:38 -08:00
Yair Gottdenker
807191cc2e changing AsyncServerSocket::acceptError to receive exception_wrapper
Reviewed By: yfeldblum

Differential Revision: D25514804

fbshipit-source-id: 7e6ad5c6063d2cf5047f656c0f2336b34576c60b
2021-02-20 08:01:53 -08:00
Xavier Deguillard
b23e4be65f inodes: remove EdenMount::channelType
Summary:
By moving the createChannel outside of the EdenMount class, we no longer need
the channelType alias, so let's do it.

Reviewed By: kmancini

Differential Revision: D26500113

fbshipit-source-id: f992ed2aaac5d692d316d06340bf9b219a2d7006
2021-02-19 22:38:23 -08:00
Xavier Deguillard
1cfe49b873 nfs: implement the getattr RPC
Summary: The RPC just translate the various `struct stat` fields into the fattr3 ones.

Reviewed By: kmancini

Differential Revision: D26389793

fbshipit-source-id: 48c6e109d5d2cb62cab096114c37314d7833035f
2021-02-19 22:38:23 -08:00
generatedunixname89002005307016
3af3b05745 Add annotations to eden/fs/cli/redirect.py
Reviewed By: xavierd

Differential Revision: D26546081

fbshipit-source-id: 59bcbfba1285521346f77ca3f749175a7cd59ca5
2021-02-19 11:55:08 -08:00
Xavier Deguillard
ce50d2e34c fs: add an NfsDispatcher
Summary:
Similarly to what is done for FUSE and ProjectedFS, the dispatcher is the glue
that sits in between the protocol specific bits and the inodes layer.

For now, this only implements "getattr" but it will be filled overtime as more
RPC can be answered properly.

Reviewed By: kmancini

Differential Revision: D26389795

fbshipit-source-id: 19cf3457feec2ebc100e632cb28c20b11fdde26d
2021-02-17 23:32:38 -08:00
Xavier Deguillard
992d17bd2d nfs: add getattr RPC datastructures
Summary: This merely adds the various datastructures needed to implement GETATTR.

Reviewed By: kmancini

Differential Revision: D26389794

fbshipit-source-id: bda557a21386483449c18aa9e52f4f626b73e69f
2021-02-17 23:32:38 -08:00
generatedunixname89002005307016
2c850edda0 Add annotations to eden/fs/cli/debug.py
Reviewed By: xavierd

Differential Revision: D26462568

fbshipit-source-id: aa295b0d13f078e4018f28875e85ab65f5d449c5
2021-02-16 10:15:55 -08:00
Saurabh Singh
cfe084d02f telemetry: switch to using quantile stats instead of timeseries
Summary:
Timeseries is memory intensive and not really required in the current context
it is being used.

Reviewed By: chadaustin

Differential Revision: D26315632

fbshipit-source-id: ee51c3ad8bef6fce152aa787c8c4602f0b499f92
2021-02-14 16:37:08 -08:00
Saurabh Singh
0b9c2fb148 telemetry: switch to using quantile stats instead of histograms
Summary:
Histograms are memory intensive and require specifying fixed buckets for
instantiation.

Reviewed By: chadaustin

Differential Revision: D26315631

fbshipit-source-id: 6ce5459b8c1c6c25d84285baf96df55ce9119b1a
2021-02-14 16:37:08 -08:00
generatedunixname89002005307016
c83d9f746b Add annotations to eden/fs/cli/redirect.py
Reviewed By: xavierd

Differential Revision: D26445498

fbshipit-source-id: b77940cd7ed34b077ac0a8888268ee00ac01e043
2021-02-14 12:05:09 -08:00
generatedunixname89002005307016
4250ca4932 Add annotations to eden/fs/cli/redirect.py
Reviewed By: xavierd

Differential Revision: D26442089

fbshipit-source-id: 9e96362545bf0d558aefae29b0472c5c8502240f
2021-02-13 17:39:12 -08:00
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