Commit Graph

2451 Commits

Author SHA1 Message Date
Xavier Deguillard
2ff478ea62 utils: move win/utils/Stub.h to utils/NotImplemented.h
Summary:
Since the Stub.h now only contains NOT_IMPLEMENTED, let's move it to its own
header outside of the win directory.

Reviewed By: genevievehelsel

Differential Revision: D23696244

fbshipit-source-id: 2dfc3204707e043ee6c89595668c484e0fa8c0d0
2020-09-16 12:31:46 -07:00
Xavier Deguillard
18084befa0 win: remove fuse_init_out from Stub.h
Summary:
With this gone, we will be able to rename and move Stub.h outside of the win
directory.

Reviewed By: genevievehelsel

Differential Revision: D23696243

fbshipit-source-id: ea05b10951fa38a77ce38cd6a09a293364dbeec9
2020-09-16 12:31:46 -07:00
Xavier Deguillard
d48209e3ed build: compile takeover/ on Windows
Summary:
While the code isn't compiled, this makes the thrift definition available to
the rest of the code, eliminating the need for having a stub for
SerializedInodeMap on Windows.

Reviewed By: genevievehelsel

Differential Revision: D23696242

fbshipit-source-id: 8a42dd2ed16887f3b7d161511e07aaa35fd1b968
2020-09-16 12:31:46 -07:00
Xavier Deguillard
3b11bc9096 portability: define uid_t and gid_t
Summary:
The getuid and getgid are defined as returning uid_t and gid_t. Defining these
types here will prevent downstream consumer from having to redefine these
types for Windows.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum, Orvid

Differential Revision: D23693492

fbshipit-source-id: 1ec9221509bffdd5f6d241c4bc08d7809cdb6162
2020-09-16 11:13:54 -07:00
Chad Austin
ecf88cd4a2 Back out "indicate to coreutils that edenfs is a remote filesystem"
Summary:
Original commit changeset: f4816b303e19

The newer version of Watchman that understands the new mount type name
won't release in time, so back this out for now.

Reviewed By: fanzeyi

Differential Revision: D23720167

fbshipit-source-id: 588541e1d9093533611d1f32b319d2562318506a
2020-09-15 20:57:15 -07:00
Chad Austin
62f06c645a introduce a py3 client
Summary: Introduce a py3 replacement for EdenClient.

Reviewed By: wez

Differential Revision: D22060644

fbshipit-source-id: 535a1f1addf3ac79de0471a688cef55567802d26
2020-09-15 17:37:50 -07:00
Katie Mancini
903532758e teach eden to resolve THRIFT_TLS_CL_CERT_PATH in configs
Summary:
This stack updates eden to be able to check all of the locations that able
users certificate may reside.

THRIFT_TLS_CL_CERT_PATH is usally set with the location for the users x509
certs. So it seems best to check this location. In order to be able to check
this location, we need to be able to resolve the enviroment variable in our
parsing.

Reviewed By: wez, genevievehelsel

Differential Revision: D23359815

fbshipit-source-id: 2008cc52ab64d23dbcfda41292a60a4bf77a80df
2020-09-15 10:28:38 -07:00
Zeyi (Rice) Fan
7f6479f790 fix eden redirect fixup properly now
Summary:
ghostbooleans

Apparently I didn't test for the positive case in my previous diff that introduces this check :(

Reviewed By: xavierd

Differential Revision: D23698179

fbshipit-source-id: 95a28cc13bff5e325214b6a398e19c821b5ae17f
2020-09-15 10:28:38 -07:00
Genevieve Helsel
d1601bdd86 ensure we only record files while recording fetches
Summary: We only care about the files we need when recording prefetch profiles (since we don't want to fetch top level directories). So let's skip recording `Tree` object types.

Reviewed By: kmancini

Differential Revision: D23693533

fbshipit-source-id: 9af5437ff6571a34597425ca5f657e7126671ba9
2020-09-15 10:28:38 -07:00
Xavier Deguillard
7d230956b7 win: remove unecessary headers from Stub.h
Summary: These headers aren't needed, and are slowing compile time at best, remove them.

Reviewed By: chadaustin

Differential Revision: D23693491

fbshipit-source-id: 4aebdfbbe56897623f62017bd498dc5c90ea6532
2020-09-14 19:25:49 -07:00
Xavier Deguillard
f95066e4ca win: remove FuseChannelData from Stub.h
Summary:
This was only used in EdenMount.h, to declare a method that was not compiled on
Windows, let's ifdef that method instead.

Reviewed By: chadaustin

Differential Revision: D23693494

fbshipit-source-id: 1eda62f2ae3a38a30aa0b517911635ef3d3896c2
2020-09-14 19:25:49 -07:00
Xavier Deguillard
601eab97f8 win: remove SerializedFileHandleMap and unlink from Stub.h
Summary: These 2 are unused, remove them.

Reviewed By: chadaustin

Differential Revision: D23693495

fbshipit-source-id: 9835de857d103c7079eda53d7e5f1914ad025fca
2020-09-14 19:25:48 -07:00
Xavier Deguillard
88c748e3b9 win: remove ProcessNameCache from Stub.h
Summary:
The ProcessNameCache code is compiled on Windows now, this definiton could
cause issues with different cpp files compiling different version of the
ProcessNameCache. To avoid this, let's remove it from Stub.h, this also removes
a bunch of #ifdef.

Reviewed By: chadaustin

Differential Revision: D23693490

fbshipit-source-id: 8f3f7b1128235b9a60f850e688b9e98910c202fc
2020-09-14 19:25:48 -07:00
Xavier Deguillard
8498760bf0 win: remove fuse_in_header from Stub.h
Summary: This is not needed, remove it.

Reviewed By: chadaustin

Differential Revision: D23693489

fbshipit-source-id: 0d7674f3001410b2d9ff02ef95049c5391d8528c
2020-09-14 19:25:48 -07:00
Xavier Deguillard
38bc544f7e win: remove win/service/main.cpp
Summary: This code is the same as the service/oss/main.cpp, no need to keep this one around.

Reviewed By: chadaustin

Differential Revision: D23689607

fbshipit-source-id: bb72a0623dcdb36beca40c3766e8d6817b99dea2
2020-09-14 18:03:07 -07:00
Katie Mancini
9c0be6c7c8 teach eden to parse arrays in configs
Summary:
This stack updates eden to be able to check all of the locations that able
users certificate may reside.

There can be multiple places where a cert may reside (we cant always
definitively choose one place to look based on the platform). Thus we
need to be able to configure multiple locations for certs in our eden
config.

Thus we need to be able to parse a list of options for a key in our config
parsing.

**Disclaimer this is really icky**

Our `FieldConverter` interface takes a string to parse. So this means
that after parsing the config file for each value we have to re-serialize it
into a string to pass it in here. Previously we only supported string and
bool values so this re-serialization was not too terrible. Now that we want
to support arrays this re-serialization is extra gross. To minimize the grossness,
I am reusing cpptoml for serializing / deserializing around the `FieldConverter`
interface.

Long term it would be better if FieldConverter took a cpptoml::base or
something more generic instead of a string so we dont have to do this.
But that will be a big refactor, and I don't currently have bandwidth for it :(

Reviewed By: wez

Differential Revision: D23359928

fbshipit-source-id: 7c89de485706dd13a05adf19df28425d2c1756a8
2020-09-14 17:40:13 -07:00
generatedunixname89002005307016
827498fc82 suppress errors in eden - batch 1
Differential Revision: D23685952

fbshipit-source-id: e545fd2625c36a8f811179091b3043c95281ff7a
2020-09-14 15:56:35 -07:00
Genevieve Helsel
2965c5f74c remove extra printed lines and sort result in prefetch profile finish
Summary: For ease of consumption, remove the descriptive line and the extra newline at the bottom of the generated prefetch profile. Also, sort the files for smaller generated diffs upon iteration.

Reviewed By: kmancini

Differential Revision: D23683153

fbshipit-source-id: e2bd510d5fbd7095f199e70b2556b84e0984a914
2020-09-14 12:59:28 -07:00
Chad Austin
d58f0d9451 prevent spurious configuration reloads when a config file doesn't exist
Summary:
getConfigStat had a bug where it, instead of clearing the bits of
*configStat, cleared the bits of the pointer itself. This caused the
stat struct for missing files to be uninitialized memory, causing
configs to reload. Write a test and fix the bug.

Reviewed By: xavierd

Differential Revision: D23645087

fbshipit-source-id: ad42f7ec1b313f668604e3a7f6c8200f6b94b23d
2020-09-13 01:37:14 -07:00
Chad Austin
be7a6b5cb3 introduce an assertZeroBits function to double-check the compiler
Summary:
While hacking on some code, I ran into a situation where some
zero-initialized stat structs weren't actually being zeroed. This was
either a compiler bug or a situation where the build system was not
correctly rebuilding everything after my changes, and I did not have
enough disassembly available to investigate.

Either way, since this code assumes zero bits in some nonobvious ways,
explicitly assert they are.

Reviewed By: xavierd

Differential Revision: D23644819

fbshipit-source-id: eb6bff9ff997379113db1e1bf9d6a0a538f10f0b
2020-09-13 01:37:14 -07:00
Chad Austin
e392eca46e log the path that caused configs to be reloaded
Summary:
We noticed spurious config file reloads, so add some logging to help
track that down.

Reviewed By: xavierd

Differential Revision: D23644447

fbshipit-source-id: 9953a17de402660c7f6491fb9abd8d702fa290e8
2020-09-11 16:53:49 -07:00
Chad Austin
2d86a960ad indicate to coreutils that edenfs is a remote filesystem
Summary:
GNU `df` (and any other coreutil that relies on gnulib's ME_REMOTE
flag) detects remote filesystems with some heuristics. One of which is
whether the device type contains a colon. Since edenfs is a remote
filesystem, include a colon, so it's properly detected as such.

Reviewed By: genevievehelsel

Differential Revision: D23520233

fbshipit-source-id: f4816b303e198d4e2a446efdcc5b49a593e09a05
2020-09-11 13:35:03 -07:00
Chad Austin
850999df92 handle mounts with device type starting with edenfs:
Summary:
We intend to rename the edenfs device type to include a colon (and
possibly the backing repo basename). In preparation, update code that
detects edenfs mounts to include anything that starts with "edenfs:".

Reviewed By: genevievehelsel

Differential Revision: D23520008

fbshipit-source-id: 280f7617d5c96e23d548041b3482bca388076a7b
2020-09-11 13:35:03 -07:00
Xavier Deguillard
c957d40ff7 cli: properly pass --edenfsctlPath on Windows
Summary:
For some unknown reason, we weren't setting this on Windows, which meant that
whenever edenfs would need to call edenfsctl (like at mount time when fixing up
redirections), it would always use the binary found in the PATH. While in most
cases this is OK, this is not the intended behavior for tests that are expected
to use the just compiled binary, not the one in the PATH.

Reviewed By: genevievehelsel

Differential Revision: D23653027

fbshipit-source-id: f1cc977e44b10c379d2b90bc7972bfec1fccad23
2020-09-11 11:57:12 -07:00
Xavier Deguillard
f2cd32ea4e win: add PrjfsRequestContext class
Summary:
Similarly to FuseRequestContext, this will be allocated whenever ProjectedFS
calls onto EdenFS to keep track of timing, stats, etc.

For now, this just holds the callback data passed in, we need to copy it as
ProjectedFS will deallocate it when the EdenFS callback returns, but since we
intend to complete these asynchronously, the callback data needs to outlive the
callback, hence the copy. It's likely that this is copying too much, and only
part of it actually needs to be copied, this will be tackled later.

Reviewed By: wez

Differential Revision: D23505511

fbshipit-source-id: ece00183e3194611d3d63465878470d6e53b790c
2020-09-11 09:19:09 -07:00
Xavier Deguillard
e9da08d4d3 win: pass the PrjfsChannel to ProjectedFS callbacks
Summary: A following diff will make use of the channel.

Reviewed By: wez

Differential Revision: D23505510

fbshipit-source-id: c044fff51c8771b1ead86333317e5c617184075c
2020-09-11 09:19:09 -07:00
Xavier Deguillard
45854b5ba0 cli: fix eden top
Summary:
The AccessCount fields were recently renamed to start with fsChannel instead of
fuse to be more platform independant. This broke edenfsctl due to it using the
old names.

Reviewed By: wez

Differential Revision: D23633574

fbshipit-source-id: 2a5fc73c47d2f0a6db407ecfeaf85992b7932c10
2020-09-10 16:07:30 -07:00
Katie Mancini
2d6fd038e9 Make TreeInode::prefetch metadata prefetching aware
Summary:
Readdir tries to be smart and prefetch the metadata for each of the children.
But this uses the old path to read metadata for files which can cause eden to
download the blob. When metadata prefetching is turned on in the backing store
it is better to leave this to metadata prefetching to the backing store.

Reviewed By: wez

Differential Revision: D23476876

fbshipit-source-id: 41cc5e6f423f19adb18581564c069c12621b6c1b
2020-09-10 13:29:36 -07:00
Zeyi (Rice) Fan
dec1cc3fb2 handle non-empty directory when creating redirections
Summary:
This diff fixes a bug on Windows when the redirection target is a non-empty directory. As seen in P141872812

This doesn't make the exception go away but generate a more meaningful error message so the user can act on it.

Reviewed By: xavierd

Differential Revision: D23605233

fbshipit-source-id: 2d2bde0e9cd94323a6537ebcec29a4c15868806d
2020-09-10 09:20:03 -07:00
Xavier Deguillard
99a1771351 notifications: compile on Windows
Summary:
While it's unlikely to work properly (it uses /bin/sh), it compiles properly on
Windows, so let's include it in the build.

Reviewed By: wez

Differential Revision: D23520368

fbshipit-source-id: 267ba04f98f5dacc81e1772f86f5ad43c846815d
2020-09-09 09:33:35 -07:00
Xavier Deguillard
1392af4423 service: do not special case WSAEADDRINUSE on bind
Summary:
In some very rare scenario, we're seeing bind fail due to WSAEADDRINUSE, and
I'm suspecting that a connect race is going on, where connect creates the file
on disk while a bind is ongoing. Since at this point there is no way for
another EdenFS process to be alive due to the fs lock being held, there is no
way for the socket to be already bound to another EdenFS process. Thus, we can
remove the special case.

Reviewed By: genevievehelsel

Differential Revision: D23591009

fbshipit-source-id: 094a7926aa9ac45ea9dea5646000aa287a9b5b7a
2020-09-08 21:18:04 -07:00
Genevieve Helsel
6a9395dff2 fix command line parsing tests on mac
Summary: These are now not working on mac due to the Catalina upgrade, so fixing here to be multi platform compatible by just following our same steps for path resolution.

Reviewed By: wez

Differential Revision: D23582015

fbshipit-source-id: e813986f5523bb721a4f01679559380c2348b98c
2020-09-08 18:43:05 -07:00
Zeyi (Rice) Fan
01315a9bbc fix SpawnedProcess ERROR_BAD_LENGTH
Summary: This fixes the `The program issued a command but the command length is incorrect` error we have been seeing in EdenFS Windows.

Reviewed By: wez

Differential Revision: D23589264

fbshipit-source-id: 72478a653ff07fca81c163bab12c0fd33f6a0a67
2020-09-08 18:25:04 -07:00
Xavier Deguillard
1f94f8d652 win: add eden.exe to the package
Summary:
One of the difference between linux/macOS and Windows is that `edenfsctl` needs
to be used while `eden` works on the other platforms. This forces both users to
change their habit, and all the scripts at FB to be changed to take edenfsctl
into consideration.

Reviewed By: chadaustin

Differential Revision: D23550567

fbshipit-source-id: de2b0853137409e595a0012ca9286c37208b98a1
2020-09-08 16:33:55 -07:00
Genevieve Helsel
51c7e04e04 implement get_process_start_time for mac
Summary:
Top of the stack, last process to implement for full implementation on the `edenfs_restarter` code path. Again, we don't have `/proc/pid/stat`, so instead we use datetimes to calculate the start time of the process since epoch in seconds.

Note here that none of these manual runs look at the versions installed/running, and that is because that kind of manual testing only works if I build and manually deploy an rpm.

Reviewed By: fanzeyi

Differential Revision: D23443268

fbshipit-source-id: 370426f2cc0d5209b96615f2c017ac08acf266fc
2020-09-08 11:13:44 -07:00
Genevieve Helsel
e19198ded6 implement get_build_info_from_pid for mac
Summary: Implementation for making a getExportedValues() thrift call to the process if `get_build_info_from_pid()` is unavailable (which is the case on mac).

Reviewed By: fanzeyi

Differential Revision: D23442884

fbshipit-source-id: 011bcb63832226e2dabd5be60dd30e13f2481dcc
2020-09-08 11:13:44 -07:00
Genevieve Helsel
4a900d2df4 implement get_edenfs_processes for mac
Summary: Since mac does not have `/proc/`, instead here we call `ps` commands and parse the output. This mirrors the same logic used up for linux.

Reviewed By: wez

Differential Revision: D23442710

fbshipit-source-id: ed5160e4dd52884e5752949a4fb2077690906ac4
2020-09-08 11:13:44 -07:00
Wez Furlong
26eb8f0c29 eden: buck kill if appropriate when removing/unmounting a redirect
Summary:
We recently switched fbsource from using `.eden-redirections`
to manage some common buck-out redirections to relying on buck's
`eden redirect add PATH bind` invocation.

As part of this, a few users have run into an issue where buck hasn't
realized that the buck-out directory was unmounted and proceeds to
try to build.  It assumes the `eden redirect add PATH bind` will
restore a missing mount, but that command skips doing any real work
in the case that the mount is configured even if it is unmounted.

This commit aims to improve the UX around this situation by:

* When removing a redirection, test to see if buckd is running for
  the containing path and stop it.
* When running `eden redirect add PATH bind`, if the path is configured
  but not mounted then fixup the mount.  (Previously we'd just print
  that we're skipping it)

Reviewed By: genevievehelsel

Differential Revision: D23502306

fbshipit-source-id: 56e823f0b59981c19d0c44723948bd84d6d9008a
2020-09-08 09:59:16 -07:00
Wez Furlong
2a184e5744 eden: fixup buck kill invocation on macos
Summary:
I ran into a couple of problems with this as part of
looking at some improvements to `eden redirect` later in this
stack:

* There's currently an issue with the BUCKVERSION=last handling
  in our internal version of buck on macos, so sidestep it for now.
* We have a bad interaction between the environment set up to
  run edenfsctl.par and a different par file used by the FB internal
  buck wrapper script that causes it to fail on startup.

This commit cleans up the environment to compensate for these issues.

Reviewed By: genevievehelsel

Differential Revision: D23502307

fbshipit-source-id: 34b5099529dcc5f2b2d638bcb333e4dd00211766
2020-09-08 09:59:15 -07:00
Xavier Deguillard
cd0af7689a utils: compile ProcessAccessLog and ProcessNameCache on Windows
Summary:
Even though these might not be fully ported on Windows, they do compile and
tests are passing, so let's compile them.

Reviewed By: chadaustin

Differential Revision: D23505509

fbshipit-source-id: 567e8668ca489daf89c1c6576973bbaaabbb6c88
2020-09-04 16:14:25 -07:00
Xavier Deguillard
a5c85ec822 fuse: move and rename RequestData
Summary:
Most of the RequestData code is platform generic, but bits of it are currently
strongly tied to FUSE. By splitting these 2 parts, we will be able to use the
RequestContext class in Windows too and not having to re-implement all the
logic there.

Reviewed By: chadaustin

Differential Revision: D23482072

fbshipit-source-id: 857fd9ca4264d0f308ec10cc487e9ff3eeb5ee16
2020-09-04 16:14:24 -07:00
Zeyi (Rice) Fan
8be3e1940a change default configuration path
Summary:
`C:/tools/eden` will be overriden whenever a new EdenFS package is installed, therefore making it  unsuitable to be managed by Chef.

Changing the default configuration directory to `C:\ProgramData\eden` that aligns with other programs.

Reviewed By: xavierd

Differential Revision: D23484626

fbshipit-source-id: 763518c608b24caa08e089a738f5c3577a0d6483
2020-09-03 17:18:51 -07:00
Xavier Deguillard
5c6ab8afac utils: rename ProcessAccessLog::AccessType enum
Summary:
Removing Fuse from the enum name makes it non tied to Fuse and thus makes it
more portable. This also eliminates the last platform specific bit from
RequestData.

Reviewed By: chadaustin

Differential Revision: D23467773

fbshipit-source-id: 52515522c8ac51d0c4b56dc5e42d4b6593df6623
2020-09-03 17:00:07 -07:00
Wez Furlong
950c81858c eden: fix buffer advance in FileDescriptor::wrapFull
Summary:
The loop took care to advance `b` to match the amount
of data that it had processed, but was still passing `buf`
(the unadjusted start of the buffer) to the syscalls.

This meant that in situations where a `readFull` might
encounter a partial read, it would scribble over the start
of the buffer and leave junk at the end.

For example:

write("hell");
write("o");

could produce "oell?" in the buffer when `readFull` consumes
the other end of the pipe.

Reviewed By: xavierd

Differential Revision: D23486270

fbshipit-source-id: 0848f6789b44421b609b91fe08890768ff59f7f5
2020-09-02 23:38:18 -07:00
Katie Mancini
76df592222 allow multiple prefixes for paths to be logged
Summary:
Currently we use a single path prefix to configure data fetch logging in eden
(i.e if the path of a file which we fetch is an extension of our configured
path, then we log that data fetch. )

There is some interest in extending this to multiple path prefixes, so that we
can log separate parts repo.

Reviewed By: StanislavGlebik

Differential Revision: D22877942

fbshipit-source-id: f6eb3dcb4fa460b4acab09677e972caf9421ddff
2020-09-02 22:54:23 -07:00
Genevieve Helsel
eb97eeedd4 move is_system_idle to UnixProcUtils
Summary: This code can be used on Mac as well, so I can just move it to `UnixProcUtils` to be shared. I think to start it we can just try using this before trying to add special idleness detection with looking for active screensavers etc.

Reviewed By: fanzeyi

Differential Revision: D23183163

fbshipit-source-id: fffad8314e70f8726836c482f7a5e30e57a75c0d
2020-09-02 20:19:49 -07:00
Genevieve Helsel
4cc9a3b6de skip restarting if the installed version is the same as the running version
Summary: We don't need to restart users if their running version is the same as their installed version, so we should check that when deciding if we should restart. This will give us more freedom in restarts since we won't have to play with `min_uptime`. I will add a flag to skip this check in case for some reason we need to do so on the fly.

Reviewed By: wez

Differential Revision: D23438306

fbshipit-source-id: b17c0e13789071b8b7c1b15ac5a8deb74a4fd091
2020-09-02 20:19:48 -07:00
Genevieve Helsel
cca2991b75 add ability to construct EdenInstance from cmdline args
Summary: I want to be able to reverse engineer an EdenInstance in the `edenfs_restarter` given the cmdline of the process. I think this best lives in the `config.py` file.

Reviewed By: fanzeyi

Differential Revision: D23438318

fbshipit-source-id: b3d9ac3981d3fb2bb8045b07b8d949cd601f6898
2020-09-02 20:19:48 -07:00
Xavier Deguillard
34821976e0 utils: use makeWin32ErrorExplicit instead of system_error
Summary: The latter will not strip new lines from the system error message, while the former does.

Reviewed By: genevievehelsel

Differential Revision: D23480435

fbshipit-source-id: 44742b960935552fa1781ed19f38ff446a8c9403
2020-09-02 19:47:00 -07:00
Victor Zverovich
a2524040e0 Migrate to field_ref Thrift API
Summary:
We are unifying C++ APIs for accessing optional and unqualified fields:
https://fb.workplace.com/groups/1730279463893632/permalink/2541675446087359/.

This diff migrates code from accessing data members generated from unqualified
Thrift fields directly to the `field_ref` API, i.e. replacing

```
thrift_obj.field
```

with

```
*thrift_obj.field_ref()
```

The `_ref` suffixes will be removed in the future once data members are private
and names can be reclaimed.

The output of this codemod has been reviewed in D20039637.

The new API is documented in
https://our.intern.facebook.com/intern/wiki/Thrift/FieldAccess/.

drop-conflicts

Reviewed By: simpkins

Differential Revision: D23465292

fbshipit-source-id: bb9df3ad183685fae28173da7275e6ecd34df048
2020-09-02 18:05:47 -07:00