Commit Graph

763 Commits

Author SHA1 Message Date
Xavier Deguillard
189cca1227 integration: enable passing update_tests
Summary:
Besides the 3 listed, all the other 13 are passing, let's make sure we run them
to not regress.

Reviewed By: chadaustin

Differential Revision: D22794164

fbshipit-source-id: 5660cc36365de96a2b9e62e3462c01b39904d2f3
2020-07-28 16:19:32 -07:00
Genevieve Helsel
247965ae33 fix flaky time test by rounding to nearest second
Summary:
we've seen flaky tests here on stress test runs, lets subtract time.time() by an epsilon of one to ensure that the comparison is only made within a second precision (time.time() worst case precision)

an example error: `AssertionError: 1595414015.5022793 not greater than or equal to 1595414015.5025299`
`AssertionError: 1595759609.439305 not greater than or equal to 1595759609.441682`

Reviewed By: chadaustin

Differential Revision: D22687496

fbshipit-source-id: 8e87148d620577e3198d2845d785a87a909cd1d3
2020-07-27 13:04:13 -07:00
Chad Austin
02c180b1db fix systemd tests on fedora 32
Summary:
Disregard two default systemd services on Fedora 32 that cause our
systemd tests to fail.

I believe genevievehelsel is planning on removing this code soon anyway.

Reviewed By: genevievehelsel

Differential Revision: D22713393

fbshipit-source-id: b703b23a3158cb007dc2e1cb53fae36be7282719
2020-07-24 10:21:35 -07:00
Victor Zverovich
e3f4a56f6b 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: yfeldblum

Differential Revision: D22631599

fbshipit-source-id: 9bfcaeb636f34a32fd871c7cd6a2db4a7ace30bf
2020-07-21 11:23:35 -07:00
generatedunixname89002005307016
6527db2809 suppress errors in eden - batch 1
Reviewed By: pradeep90

Differential Revision: D22628389

fbshipit-source-id: c109334243a92269a7fb9a9b0515565ac22ecfac
2020-07-20 13:29:51 -07:00
Jun Wu
b80966f93c revlog: turn on head-based-commit-transaction for tests
Summary:
Bypass truncation-based transaction if narrow-heads is on.

The transaction abort still works logically because commit references stay
unchanged on abort.

Related EdenFS and Mononoke tests are updated. Mononoke tests probably
shouldn't rely on revlog / fncache implementation details in hg.

Reviewed By: DurhamG

Differential Revision: D22240186

fbshipit-source-id: f97efd60855467b52c9fb83e7c794ded269e9617
2020-07-08 14:33:58 -07:00
Genevieve Helsel
da7b453306 fix AssertionError if a checkout is in the middle of a merge
Summary:
An assertion error is raised if `eden doctor` is in the middle of a merge. This is because we enter a specific "if" condition in the case that mercurial has two parent commits, and EdenFS only ever tracks `p0`, so EdenFS simply sets `p1` to the null commit in `_select_new_parents()`. Specifically, this is in the case in which both `_old_dirstate_parents` and `_old_snapshot` are not None.

Because `_old_dirstate_parents` has `p1` set to nonnull, and Eden thinks it is null , the check `self._new_parents != self._old_dirstate_parents` would be `True` even though there was actually no error.

Reviewed By: chadaustin

Differential Revision: D22048525

fbshipit-source-id: 9a19cc092e2bd80db0e01fb38533a1007640bee6
2020-06-30 13:58:21 -07:00
Xavier Deguillard
a935fc38b4 inodes: fix casing issue on Windows
Summary:
On Windows, paths are case insensitive (but the filesystem is case preserving),
and thus `open("FILE.TXT")` and `open("file.txt")` refer to the same file. When
that file is not materialized and its parent directory isn't yet enumerated,
PrjFS will call the PRJ_GET_PLACEHOLDER_INFO_CB with the file name passed in to
the `open` call. In this callback, if the passed in name refers to a valid
file, it needs to call PrjWritePlaceholderInfo to populate the directory entry.
Here is what the documentation for that function states:

"For example, if the PRJ_GET_PLACEHOLDER_INFO_CB callback specifies
dir1\dir1\FILE.TXT in callbackData->FilePathName, and the provider's backing
store contains a file called File.txt in the dir1\dir2 directory, and
PrjFileNameCompare returns 0 when comparing the names FILE.TXT and
File.txt, then the provider specifies dir1\dir2\File.txt as the value of
this parameter."

While the documentation doesn't state how that name is used internally, we can
infer (and test) that the returned case will be used as the canonical
representation of that file, ie: the one that a directory listing will see.

Since the PathMap code already does a case insensitive search, we just need to
make sure to use what it returns instead of re-using the name used for the search.

The only caveat to all of this is the original comment that describe that
`metadata.name` can't be used as it causes crashes. From what I can tell, this
was written in later 2018, and I believe is no longer relevant: the
`metadata.name` field was simply not populated.

Reviewed By: wez

Differential Revision: D21799627

fbshipit-source-id: aee877cc2d5f057944fcd39b1d59f0e97de6315c
2020-06-24 18:59:16 -07:00
Ailin Zhang
dde49c1c44 add a new column FUSE FETCH to eden top to display fetchCounts
Summary:
updated `eden top` to:
- obtain PID-fetchCounts data from the updated -`getAccessCounts` thrift call in the previous diff
- display that data in a new column `FUSE FETCH`

Reviewed By: kmancini

Differential Revision: D22101430

fbshipit-source-id: 6584e71ce3a4629c73469607ca0a4c6ffd63e46f
2020-06-24 15:56:14 -07:00
Xavier Deguillard
2e184e2a1a integration: rename blacklist.py
Summary: The word "disabled" better express the intent behind it.

Reviewed By: fanzeyi

Differential Revision: D21945736

fbshipit-source-id: a61a3df4f1b704224e7f4d4a7f1a43f4d2b5b2aa
2020-06-19 18:13:20 -07:00
Xavier Deguillard
8883532338 tests: enable unlink_test on Windows
Summary:
Removing a directory with unlink raises different errors on Windows: EACCES
instead of EISDIR.

Reviewed By: fanzeyi

Differential Revision: D21944455

fbshipit-source-id: 251ceb305a46c01ece78f45b0fa8000778c6c650
2020-06-19 18:13:20 -07:00
Xavier Deguillard
5d96bcae3c tests: enable some integration tests
Summary: These appear to be passing, let's enable them.

Reviewed By: genevievehelsel

Differential Revision: D21820196

fbshipit-source-id: bb36e48d02411b1dc94e3d1e499f892145cee6ae
2020-06-19 18:13:19 -07:00
Chad Austin
c13386ead4 fix test
Summary:
test_no_units_are_active was failing on CentOS 8. Presumably systemd
has some new default services. I believe genevievehelsel is planning on
replacing all of this code, so, rather than understand the failure,
just ignore the additional service names.

Reviewed By: genevievehelsel

Differential Revision: D22055992

fbshipit-source-id: b6f313350d0e1b107fe6ea3d7ed7f5b4eb025ef3
2020-06-15 18:37:01 -07:00
Xavier Deguillard
42fb95adc2 integration: write files to the repo in binary mode
Summary:
In text mode, Python will use '\r\n' as line endings instead of '\n' on
Windows. This has the negative side effect of making some tests fails due to
the file content not being exactly what is being written.

Reviewed By: fanzeyi

Differential Revision: D21944456

fbshipit-source-id: f7f271e2ef9e2f21bd78c76233e644ce411b63df
2020-06-15 15:10:20 -07:00
Genevieve Helsel
ca1da512bf store force restart action as its own flag
Summary: In its current state, FORCE is a restart mode that cannot be combined with other modes (specifically `graceful`). Removing this coupling from `force` will allow us to at first attempt a graceful restart, but if the daemon is not healthy, then do a force restart, all within one call.

Reviewed By: wez

Differential Revision: D21873166

fbshipit-source-id: 079a777ff6e7b219198cbef15335244b9865f5f3
2020-06-11 17:40:51 -07:00
Chad Austin
597c209fa1 disallow warnings in integration tests
Summary:
Unawaited coroutines are pernicious and not errors by default. In
advance of enabling asynchronous tests, fail our tests when Python
warnings are shown.

We record warnings and report them after the test body instead of
enabling an "error" warning filter because exceptions thrown by
finalizers are silently swallowed, and most important warnings occur
during finalization.

Reviewed By: genevievehelsel

Differential Revision: D21955210

fbshipit-source-id: b1fc52ddfa9f9befbde6800f85f090862af0ef15
2020-06-10 23:23:34 -07:00
Chad Austin
e1e4bdee40 add a (failing) test of binary blob contents over thrift
Summary:
Add a disabled test that illustrates that binary data fails to
serialize between edenfs and the CLI with the current Thrift
implementation.

Reviewed By: fanzeyi

Differential Revision: D21890379

fbshipit-source-id: 725e99751e1d62c39f4059ec0f1197857c47e3b4
2020-06-10 19:29:42 -07:00
Chad Austin
7e4835f677 rename eden.thrift Python module to eden.thrift.legacy
Summary:
The Python 2-and-3 Thrift API is sort of deprecated and does not
handle binary data in `binary` fields. In advance of migrating to the
modern Python 3 API, remane eden.thrift to eden.thrift.legacy.

Reviewed By: fanzeyi

Differential Revision: D21889697

fbshipit-source-id: a745ee8977999acbfb383a4edebe81d8deb1734e
2020-06-10 19:29:42 -07:00
Chad Austin
11d569b04d refactor EdenClient construction
Summary:
I am planning to start migrating Eden's CLI to the new Python 3 Thrift
implementation. In preparation, slightly clean up the interface and
implementation of our Python 2 Thrift wrapper.

Reviewed By: genevievehelsel

Differential Revision: D21854539

fbshipit-source-id: d398dd3f324c12288871cf0c9db41e64ed4cf7ed
2020-06-10 19:29:23 -07:00
Chad Austin
3b04c02b29 fix flaky integration tests
Summary:
Under heavy parallelism or system load, our tests could trigger
short-ish timeouts and cause tests to flake. The stats test in
particular often failed in continuous integration. It looks like
opening a unix domain Thrift socket early and holding onto it can
cause it to sometimes hit ThriftServer's default idle timeout of 60
seconds, which results in the test failing with BrokenPipeError
(EPIPE).

Reviewed By: simpkins

Differential Revision: D21780023

fbshipit-source-id: 7e8838429475c2a322d836b9a497411199948cce
2020-05-29 11:49:37 -07:00
Xavier Deguillard
0cb5ceedfe unify the EdenMain code on Windows
Summary:
Update EdenFS on Windows to use EdenMain.cpp, the same as on POSIX.

This reduces the amount of code divergence, and also brings several
improvements to Windows: exposing version information over fb303, support for
dynamically changing logging configuration over fb303, etc.

Reviewed By: simpkins

Differential Revision: D21332569

fbshipit-source-id: dd2da7c385e96f65fc3927511c9f84b96bec9e2b
2020-05-28 09:01:03 -07:00
generatedunixname89002005307016
f9358e566a suppress errors in eden - batch 1
Summary:
This diff is auto-generated to upgrade the Pyre version and suppress errors in eden. The upgrade will affect Pyre local configurations in the following directories:
```
eden
```

Differential Revision: D21687853

fbshipit-source-id: baf0d9bc33f86da63ea289690faca6cf4d566588
2020-05-21 19:32:35 -07:00
Xavier Deguillard
cd92c10363 integration: symlinks are not supported on Windows
Summary:
Now that regular users can create symlinks, a handful of tests were failing
due to the symlink call no longer raising an exception. For now, let's always
consider that symlinks aren't supported on Windows.

Reviewed By: fanzeyi

Differential Revision: D21664213

fbshipit-source-id: c55a99d1cb92e68b9861701b5517b1d5db2d40c6
2020-05-20 13:11:10 -07:00
Shannon Zhu
096b35c70b Convert type check targets in eden to use configuration
Summary:
Migrating buck integration to use configurations, which is more performant and is the primary supported way to run Pyre.
Mypy is no longer supported at Facebook, so mypy buck integration is covered in this migration as well.

Configuration target automatically expanded to include all subtargets, expanding type coverage while introducing no more than 2 fixmes per file.

Reviewed By: dkgi

Differential Revision: D21474723

fbshipit-source-id: 2501af8250b4998fe331350b80c9dc8b4ba2dd1a
2020-05-08 15:24:57 -07:00
Chad Austin
c4db2f39a9 remove some internal uses of the term 'client'
Summary:
Our use of the term "client" to refer to a checkout is
deprecated. Rename some internal functions that use the term client.

Reviewed By: simpkins

Differential Revision: D21395159

fbshipit-source-id: fa96ba593f53b493e5ae816fa686f333a132c232
2020-05-07 22:08:10 -07:00
Adam Simpkins
13a8f17325 de-blacklist most of the hg status related tests on Windows
Summary: All of the tests in hg/status_test.py pass except for these 3.

Reviewed By: genevievehelsel

Differential Revision: D21410570

fbshipit-source-id: cf9a87ce0f025860c1e95927a780757fda6801ad
2020-05-07 16:41:30 -07:00
Adam Simpkins
ccdbc2279b update most of the integration/basic_test.py tests to work on Windows
Summary:
- If we fail to create symlinks ignore this error on Windows
- Using a file as a directory produces an ENOENT error instead of ENOTDIR
  on Windows.
- Deal with some issues around CR -> CRLF translation when writing files in
  non-binary mode on Windows.
- Move several POSIX-specific tests out into a separate test class.

Reviewed By: wez

Differential Revision: D21214598

fbshipit-source-id: 587a755bd06990bf88d26017254a69ff8869edbc
2020-05-07 16:41:30 -07:00
Adam Simpkins
54af4a5770 update can_run_eden() to check for ProjectedFSLib.dll on Windows
Summary:
On Windows we can only run EdenFS if ProjectedFSLib.dll is available.  It
turns out that some Windows systems have ProjectedFSLib.lib available, so we
can build `edenfs.exe`, but are missing ProjectedFSLib.dll, so we cannot
actually run it.

Reviewed By: wez

Differential Revision: D21443255

fbshipit-source-id: 6396fce8bd71adc0695468a2df3fd5f584909138
2020-05-07 16:41:30 -07:00
Shannon Zhu
83dc7b9129 Custom pyre upgrade for eden
Summary:
Addressing issues simpkins brought up on D21207287 when we upgraded and introduced some pyre bugs.

Temporarily upgrading just this project, once we resolve some sandcastle capacity issues we'll release this via another global upgrade in fbcode.

Reviewed By: simpkins

Differential Revision: D21316793

fbshipit-source-id: f0c79f53d97f7182e7d8fe6e081c58ef53ce0c9a
2020-05-04 21:19:20 -07:00
Adam Simpkins
c0fb9cea2d enable all integration test sources in CMake builds
Summary:
Previously we only included `basic_test.py` and `hg/status_test.py` in the
integration tests during CMake-based builds.  This updates the code to now
include all of the test files, with just a few exclusions based on platform
type and what dependencies were available at build time.

Reviewed By: wez

Differential Revision: D21239912

fbshipit-source-id: b8826d249a6323ac3bcc555c9ceba54a4cbcfde9
2020-05-04 11:46:09 -07:00
Adam Simpkins
a755d9e979 blacklist some integration tests on non-RedHat Linux distributions
Summary:
10 of the integration tests fail on Ubuntu.  For now simply blacklist them
from running on non-RedHat-based distributions.

Reviewed By: wez

Differential Revision: D21332629

fbshipit-source-id: 3fadb74bb31e89092177afaa01ddc7f6bcd0f9de
2020-05-04 11:46:09 -07:00
Adam Simpkins
ea7460f2d3 apply the integration test case blacklist to some more tests
Summary:
Add a new IntegrationTestCase base class that checks the test blacklist during
`setUp()`, and update a few remaining test classes that did not derive from
`EdenTestCase` to derive from this.

Also drop the method name argument from the `skip_test_if_blacklisted()`
function, since we can get this from the existing test case argument.

Reviewed By: genevievehelsel

Differential Revision: D21340539

fbshipit-source-id: d4fc125f119d74ab923c2cc3c9070b86c582c87e
2020-05-04 11:46:09 -07:00
Adam Simpkins
f390948707 fix the UserInfoTest on Ubuntu
Summary:
Run `env` as `/usr/bin/env` instead of `/bin/env`
This command is typically installed in `/usr/bin`.  Recent RedHat releases
replaced `/bin/ with a symlink to `/usr/bin`, allowing this command to work
when invoked as `/bin/env`, but this isn't true on all distributions, such as
Ubuntu.

Reviewed By: chadaustin

Differential Revision: D21340540

fbshipit-source-id: d7588f8c90e9a86a0cb31fd3ab3a9067aa6e79ea
2020-05-04 11:46:08 -07:00
Shannon Zhu
0b93429dc1 Convert type check targets in eden to use configuration
Summary:
D21316793 is blocked from landing because there are a few targets in eden that are running pyre via buck targets integration.

We can't do custom version overrides for projects that are using a mix of local configurations and buck integration, because buck doesn't provide an interface for setting the equivalent pyre version override.

We're moving away from buck targets integration for pyre across the board, and I've run a codemod over the project to clean up all of the buck typing integration (including some residual mypy) as well as updated type ignores / fixmes accordingly.

Let me know if you have any concerns; upon skimming it looks like most changes are either converting `type: ignore`s into fixmes, or removing `type: ignores`.

Reviewed By: dkgi

Differential Revision: D21343093

fbshipit-source-id: 5ee1436377eb526c0a679fb821c42e07cbca52a5
2020-05-02 21:16:55 -07:00
Chad Austin
ec00e91309 disallow setting suid, sgid, and sticky bits
Summary:
FUSE_HANDLE_KILLPRIV expects that any write() call is handled by
clearing the setuid and setgid bits in the userspace. To avoid
implementing that behavior, disallow setting setuid or setgid in the
first place.

Reviewed By: xavierd

Differential Revision: D21333703

fbshipit-source-id: eb084ee8b00afe74c0da26e41c32c2cb742723da
2020-04-30 15:18:35 -07:00
Adam Simpkins
8392001e38 update the systemd-related integration tests to work on Ubuntu
Summary:
The systemd binary is installed in a different location on Debian-based
distributions (e.g., Ubuntu) from RedHat-based distributions.  Update the
integration tests to look in both places.

Reviewed By: wez

Differential Revision: D21297591

fbshipit-source-id: 67e5a698080205b8624c1f38aa49e75c20b6a28c
2020-04-29 23:12:37 -07:00
Adam Simpkins
0400e99d09 update the integration tests to guess at CMAKE_SOURCE_DIR
Summary:
Our CMakeLists.txt file requests `ctest` to pass in a `CMAKE_SOURCE_DIR`
environment variable when running our integration tests via `ctest`.  However
if a developer manually invokes the test binary this environment variable may
not be set.

For convenience, this updates the code to try looking at the default location
where getdeps will have put the source relative to the build directory (at
least for internal builds using shipit-converted fbsource sources).

Reviewed By: wez

Differential Revision: D21307807

fbshipit-source-id: d747c50d79d2d378721b68b18c256d5363e41f26
2020-04-29 18:50:34 -07:00
Adam Simpkins
ea59a68521 improve finding the system hgrc during CMake-based integration tests
Summary:
Update the integration tests to attempt to find the Mercurial config files
from the source directory even in CMake-based builds.  This directory will be
available when doing an internal build from fbsource via getdeps.py

If this directory isn't present (e.g., on a build from the github repository)
we will still fall back to using the Mercurial configuration files installed
on the system.  In that case I did update the code to use the correct system
configuration path on Windows.

Reviewed By: wez

Differential Revision: D21307808

fbshipit-source-id: 917ba5e8548fed999fb06a29324be125cec83cac
2020-04-29 18:50:34 -07:00
Adam Simpkins
1c3eb54e21 remove the requirement that edenfs must be invoked with --edenfs
Summary:
Remove the requirement that the `--edenfs` argument flag must be passed in
when invoking the `edenfs` daemon.

This flag was added in D12927803 to help provide a better error message if
users accidentally ran `edenfs` when they really mean to run `edenfsctl`.
However, this shouldn't really be a major problem any more: on Linux and Mac
we now install `edenfs` in a `libexec` subdirectory instead of `bin`, so it
should not be in most user's `$PATH` by default any more.  Additionally we
also verify that no other unexpected arguments have been supplied.  Prior to
D12927803 the `edenfs` binary would ignore unexpected arguments, making the
error messages more confusing when users tried to run it with `edenfsctl`
subcommand arguments.

One motivation for changing this now is that the Windows version of `edenfs`
does not require this flag, and it is desirable to remove this behavior
discrepancy.  Rather than making this flag required on Windows it seems fine
to just drop the requirement on Mac & Linux.

Reviewed By: wez

Differential Revision: D21297159

fbshipit-source-id: e24bd694dadc036cd31dead287ae2c1184747822
2020-04-29 17:55:34 -07:00
Adam Simpkins
f48674b1df update the service test cases to skip when appropriate
Summary:
Update the tests that derive from `ServiceTestCaseBase` to honor the test
blacklist, and to also skip if we cannot run the `fake_edenfs` utility.  This
latter check primarily fails when we cannot run `sudo` non-interactively
without a password prompt.

Most of the other tests were already honoring blacklist through the
`EdenTestCase` base class, but `ServiceTestCaseBase` does not derive from
`EdenTestCase`.

Reviewed By: wez

Differential Revision: D21297160

fbshipit-source-id: 5044e9939bbe487c09aa96021166c95f02fb376e
2020-04-29 17:55:34 -07:00
Adam Simpkins
c55781c666 move UserInfo to eden/fs/utils/
Summary:
Move the `UserInfo` code from `fuse/privhelper` to `utils`, and also unify the
POSIX and Windows implementations of this class.

This code was originally put in the `fuse/privhelper` directory since it was
written at the same time as the privhelper.  However, it's really a
lower-level library that doesn't depend on FUSE or any of the other code in
the `fuse/` subdirectory.

Reviewed By: wez

Differential Revision: D21296594

fbshipit-source-id: f58682f6ce86bba0328472c491bb4c0dc3370319
2020-04-29 17:21:12 -07:00
Katie Mancini
48804631f7 expose number pending fuse requests
Summary:
This sets up the counters that will allow us to expose the number
of pending FUSE requests in Eden top.

As D20846826 mentions adding metrics for FUSE request gives
visibility into fuse requests and overall health of eden.

This provides more insight beyond the metrics for live FUSE requests
since it shows the kernels view of FUSE requests. Looking at the difference
between the number of pending and live request, can identify issues
that arise at the interface between eden and FUSE and monitor how
quickly fuse workers are processing requests.

**note**: this is only for linux since macos has no equivalent to
`/sys/fs/fuse/connections`

Reviewed By: chadaustin

Differential Revision: D21074489

fbshipit-source-id: c0951f0dfd4fa764be28d8686d08cd0dd807db37
2020-04-28 13:28:01 -07:00
Genevieve Helsel
cfb64a0a2d clean up EdenMount destruction process
Summary:
In the past, if an EdenMount got stuck while shutting down (inodes still referenced), the EdenMount would already be removed from the server's `mounPoint's` map while stuck. This resulted in `eden list` showing that the mount was not mounted, and then if we tried to remount the mount, we'd get a confusing error message about the not being able to grab the overlay lock. This also made it so if we tried to attach with gdb, or if we core dumped and tried to look at the data, we wouldn't be able to examine the object.

Instead, we should only remove the mount from the `mounPoints_` map after it has completely been shutdown. This will allow us to get better signal on the state of the mount (it will be in the `SHUTTING_DOWN` state in `eden list` instead of `(not mounted)`) and it will allow us to better debug these situations (where a mount is stuck shutting down) since we can get more information about the mount that is in this state.

Reviewed By: simpkins

Differential Revision: D21211544

fbshipit-source-id: 97ff11df67d0a80f47cf6b9f563876e17bd76622
2020-04-28 12:44:12 -07:00
Adam Simpkins
e193085594 some ctypes-related portability improvements in the integration tests
Summary:
Update `integration/lib/linux.py` to use `ctypes` to call `statfs`, instead of
running `/bin/stat` and parsing the output.  This allows this test code to
work even on systems that do not have `/bin/stat` (e.g., on Ubuntu this is
installed at `/usr/bin/stat`).

Also update the usage of ctypes in the `mmap.py` test file to allow this file
to be imported successfully on Mac OS X.

Reviewed By: xavierd

Differential Revision: D21273385

fbshipit-source-id: c2173758f8ea67cde2a68e57827acc5f73b63179
2020-04-28 12:11:51 -07:00
Adam Simpkins
5470190bf3 update one of the rebase tests to explicitly use non-in-memory update
Summary:
Update the `test_rebase_commit_with_independent_folder()` test to explicitly
disable in-memory updates.  The in-memory update code ends up changing the
number of update operations performed (it skips the initial and final update),
causing one of the assertions in this test to fail.

Reviewed By: xavierd

Differential Revision: D21271902

fbshipit-source-id: 3e40adce5fac1c851c8f277d2209d48a19deed55
2020-04-28 12:11:51 -07:00
Adam Simpkins
c13f0ac5f7 update the usage of pexpect to work on Windows
Summary:
Update the integration test code that uses pexpect to use the more modern
pexpect APIs.  The top-level `pexpect.spawn()` function is considered legacy
now, and is only provided for backwards compatibility on Unix platforms.

Reviewed By: wez

Differential Revision: D21214640

fbshipit-source-id: 941da5435c4f8afaf22e8053f4c344175d7b1a7f
2020-04-24 14:48:05 -07:00
Adam Simpkins
cadcd0ab39 enable building the integration helper tools in the CMake build
Summary:
Enable building fake_edenfs.cpp and TakeoverTool.cpp in the CMake build.

This includes a few changes to get `fake_edenfs.cpp` closer to building on
Windows, but at the moment it still does not fully build since the
`StartupLogger` is currently not compiled on Windows.

TakeoverTool.cpp is specific to the graceful restart tests, and doesn't make
sense to ever build on Windows.

Reviewed By: wez

Differential Revision: D21214614

fbshipit-source-id: a7a8306ea3f69579fa02bd3753a66d3095ea004a
2020-04-24 14:48:05 -07:00
Adam Simpkins
cb5b9fefd7 tweaks to update the integration tests to allow running on Windows
Summary:
Previously none of the integration tests ran on Windows, as they checked for
the presence of `/dev/fuse` first, and would skip the test if it was not
present.

This updates the tests to allow running on Windows, and updates the
`find_executables.py` code to find the executables properly on Windows.

Reviewed By: wez

Differential Revision: D17733621

fbshipit-source-id: a8bf4e5138f9ea6c9b040814dd68fc64228961de
2020-04-24 14:14:15 -07:00
Adam Simpkins
6500f94127 avoid running systemd-related tests when systemd is not supported
Summary:
systemd is Linux-specific, so it does not make sense to try and run these
tests on Linux and Mac.  Additionally, the pystemd module currently used by
the edenfsctl CLI is not currently open source, and therefore only works in
our internal Linux builds.

This updates the integration test code to only include systemd-related tests
if we are actually in an environment where we support systemd.

Reviewed By: wez

Differential Revision: D21084095

fbshipit-source-id: fb6c9a066d9dcb741bddf3cdcf9decdb763a1d05
2020-04-23 15:06:32 -07:00
Shannon Zhu
6ec7546cab Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D21207287

fbshipit-source-id: ab82cf81690cb847bd130ff3448345f5a0ea19af
2020-04-23 12:09:39 -07:00
Adam Simpkins
1e8e8b05de clean up parts of the start and clone integration tests
Summary:
Several of the tests started edenfs of fake_edenfs processes and didn't kill
them at the end of the test.  This adds proper cleanup functions to try and
kill these processes when the test exits.

This also eliminates using pexpect in these tests, since it isn't actually
necessary here.

Reviewed By: wez

Differential Revision: D21084096

fbshipit-source-id: 4e92a99a5c398d4a78830ac51507ba34d7a6c0b1
2020-04-22 15:02:42 -07:00
Adam Simpkins
c763e922a2 kill off some of the integration test mixin classes
Summary:
This updates the various systemd-related tests to use EdenTestCaseBase,
and allows us to delete the EnvironmentVariableMixin and
SystemdUserServiceManagerMixin classes.

The main goal of this clean-up is to make it easier to consolidate most of the
systemd-related code into just a few locations, so that we can more easily
disable the systemd-related tests in build environments where systemd is not
supported.

Reviewed By: wez

Differential Revision: D21084098

fbshipit-source-id: d5e05254c689c28751fe48d2dc38d722c7e77ed3
2020-04-22 15:02:42 -07:00
Adam Simpkins
72f6ada7c2 add a new EdenTestCaseBase class
Summary:
This adds a new `EdenTestCaseBase` class to serve as the base class across a
number of our integration tests and some of our CLI tests.

The main goal of this is to allow eliminating many of the annoying `*Mixin`
classes used in a lot of our integration tests.  These mixin classes are
annoying since they result in complicated multiple inheritance, and it can be
tricky to ensure that the method resolution order behaves the way you want.
The systemd tests in particular use a lot of mixins, which gets complicated.
These mixin classes are also awkward from a Python typing perspective, and the
systemd tests end up resorting to just declaring different APIs in several
places when `typing.TYPE_CHECKING` is True.

The fact that `EdenTestCaseBase` has a `contextlib.ExitStack` member variable
should make it easier for us to eliminate these mixins moving forward: rather
than using mixins that use inheritance and assume a `self.cleanUp()` method
exists, we can transition this code to standalone functions or context
managers, and they can take the `ExitStack` variable as an argument if
necessary.

Reviewed By: wez

Differential Revision: D21084097

fbshipit-source-id: 77ee457b7debe6f584f630e3e30f79fe634a2026
2020-04-22 15:02:41 -07:00
Adam Simpkins
62a463ea76 only run the git integration tests when built with git support
Summary:
Update the integration tests to only run git integration tests if EdenFS was
built with git support.

Reviewed By: genevievehelsel

Differential Revision: D21000162

fbshipit-source-id: 0a015ae93a9420f040be702096e0b378fe138e4c
2020-04-22 12:48:49 -07:00
Adam Simpkins
5917c8e097 address some pyre-fixme issues in find_executables.py
Summary:
Update the code to work around the fact that Pyre refuses to unwrap Optional
member variables.  Store the data in local variables so that Pyre will allow
unwrapping these objects after we check against None.

Reviewed By: genevievehelsel

Differential Revision: D21000165

fbshipit-source-id: 59e8430de30ec35213a53b06670b16c34be85593
2020-04-22 12:48:48 -07:00
Adam Simpkins
ba949fa2cf update some of the integration test code to use the eden.config module
Summary:
Update some of the eden integration tests to use the `eden.config` module
instead of trying to import the `__manifest__` module, which is only present
in Buck-based builds.

Reviewed By: wez

Differential Revision: D21000167

fbshipit-source-id: 347082a32e842752e5539a8e6c8addde97a16eee
2020-04-22 12:48:48 -07:00
Adam Simpkins
a26b8e9930 update edenfsctl to report the compile-time version
Summary:
Update most locations in edenfsctl to report the version number that was built
into the edenfsctl binary at build time, rather than querying the RPM database
for the installed RPM version.  The RPM behavior only works on to RedHat-based
Linux systems, and the currently running process doesn't necessarily have to
have come from the RPM.

The one place where we do still attempt to print the RPM version is in the
`edenfsctl rage` report, when running on Linux.

Reviewed By: wez

Differential Revision: D21000168

fbshipit-source-id: 0fb747e71b6950d74f22c458efa0dfcbd45270bd
2020-04-22 12:48:48 -07:00
Katie Mancini
d850667e19 expose live FUSE requests
Summary:
This exposes metrics for the live FUSE requests (the duration
of the longest outstanding request and the number of outstanding
requests).

Because FUSE is the interface through which the user mostly interacts
with the file system they provide good metrics to judge if the perfomance
of eden is normal, or there may be an issue.

Exposing these counters this way will send them to ods, so it will not only
allow for debuging current issues, but can be used to look back at previous
problems. This data could also be used for alerting or more proactive
remediation.

Metrics are exposed per checkout to allow seeing which checkout was
having issues. This data will aggregated in `eden top` to be used as
an overall health indicator, but should more information be needed it
will be logged in ods.

Reviewed By: chadaustin

Differential Revision: D20922194

fbshipit-source-id: 16208883417acb77b62bf712cfdd9068c5420303
2020-04-22 12:33:34 -07:00
Adam Simpkins
15dd55fb80 add a framework for per-platform blacklists of integration tests
Summary:
Many of our integration tests do not yet work on Windows.  In order to allow
us to start running some integration tests on Windows while not getting lots
of failure reports, this adds a framework for blacklisting specific tests on a
per-platform basis.

Reviewed By: genevievehelsel

Differential Revision: D21084150

fbshipit-source-id: 141cd11f7e8113fcbbb2416d518864fca9179554
2020-04-21 20:37:20 -07:00
Genevieve Helsel
87bd70f0b0 restructure ThriftServer stop code in takeover case
Summary:
This restructures the `ThriftServer server_` stopping logic in the graceful restart case. Instead of stopping the server, we stop listening then explicitly stop the server. This refactor should exhibit the same behavior as today since we block on `stopListening()`, but this will allow for simpler refactoring of thrift call queueing logic in the future (by removing the `stopListening()` call and replacing it with a `startQueueingAndWaitForOutstandingCallsToFinish()` type of call).

In terms of layout, this consolidates all the stopping code into one function `startTakeoverShutdown()`. This function now returns the `TakeoverData` itself instead returning a future that is fulfilled after stopping the Thrift server. The TakeoverServer still communicates via `takeoverComplete`, but now that future is stored during `startTakeoverShutdown()` instead of being the return value of `performTakeoverShutdown()`. This also generally eliminates `TakeoverPromise`.

Reviewed By: simpkins

Differential Revision: D20744151

fbshipit-source-id: 60f0c273b4f3889b53586d79efd95bfb27256e1b
2020-04-20 12:28:36 -07:00
Adam Simpkins
80a150fb53 improve a failure message in the rebase tests
Summary:
Improve some failure messages to include the full command output that we are
checking.

Reviewed By: genevievehelsel

Differential Revision: D21084135

fbshipit-source-id: 65be3adce7bf54bab6beccf5d0c463a749d585d2
2020-04-20 12:16:53 -07:00
Adam Simpkins
94c52753d1 relax checking of C++ type formatting in an integration tests
Summary:
One of the thrift tests was checking an error string that was produced from
`folly::exceptionStr()`, which includes the exception type name.  However, in
some build environments this name does not always get demangled (the folly
demangling code may not have been included in the build, or there may be some
other issue).  For instance, in some environments using the CMake-based build
I was seeing the exception type reported as `St12domain_error` instead of
`std::domain_error`.

Reviewed By: genevievehelsel

Differential Revision: D21004345

fbshipit-source-id: 8e6a4ee4d93b1aabbe9c9816c43db803e6e12798
2020-04-15 17:58:12 -07:00
Adam Simpkins
d18ce1082e split edenfsctl start into foreground vs service logic
Summary:
This refactors the `edenfsctl start` command so that we more clearly split the
functionality into two pieces:
* Starting EdenFS as a service
* Running EdenFS in the foreground

In most normal situations in production the `start`, `restart`, and `stop`
commands are used to manage running EdenFS as a service.  In the future I
believe our service management logic will start to diverge a bit more on Linux
vs Mac vs Windows, and this should help isolate the service-management code a
bit more cleanly.

The foreground behavior is mainly only used by developers during testing and
during the integration tests.  Several options like `--gdb` and `--strace` are
only allowed in foreground mode, and this refactoring makes that clearer.  In
the future we may also want to further restrict this, to allow only
specifying additional custom arguments and a custom binary path when running
in foreground mode.  However, for now I have not updated that as I believe
some of our integration tests may be exercising this behavior today.

This change also cleans up some of the platform-specific code, and lets them
share more of the logic to construct arguments for edenfs.  With this change
`edenfsctl start --foreground` now works on Windows.

Reviewed By: pkaush

Differential Revision: D20833244

fbshipit-source-id: 0f09d59702d8b64ca8f4fedccbc30da1c858afb4
2020-04-15 15:46:25 -07:00
Adam Simpkins
772369731c implement our own temporary file management during integration tests
Summary:
Unfortunately the Python standard library's `tempfile.NamedTemporaryFile`
class does not work very well on Windows: even though the temporary files are
named, they cannot actually be opened by other processes.  Attempting to open
the file fails with a permission denied error.

This code extends our existing temporary directory management logic to also
add APIs for creating individual temporary files.  This has the advantage of
better grouping all temporary files for a given test in the same directory.  I
also updated the code to include the test function name in the temporary
directory prefix.  This should make it a little easier to identify which test
is at fault when there are temporary files left behind after a test.  (This
can happen if the test gets killed or if it leaves behind files or mount
points that cannot be removed normally).

Reviewed By: wez

Differential Revision: D20885160

fbshipit-source-id: 7267b2352e51214354eab7ead839bf166d690974
2020-04-13 13:12:04 -07:00
Adam Simpkins
c5e6e40888 remove support for repo configs from edenfsctl clone
Summary:
Update the `edenfsctl clone` command to require that an explicit repository
path be passed in.  Using the name of a repository listed in an EdenFS config
file is no longer supported.

Reviewed By: wez

Differential Revision: D20876459

fbshipit-source-id: 5e9fef11a2afa4cc48cb8a9bb5b874d2e7923f25
2020-04-10 13:57:52 -07:00
Adam Simpkins
ef8c3435c4 remove the "edenfsctl repository" subcommand
Summary:
We no longer use repository configs, so remove the `repository` subcommand
that supported adding and listing these configurations.

The main information that used to be included in the repository configuration
was the bind mount settings.  This has since been replaced with the
`.eden-redirections` file that is placed directly in each repository.

Reviewed By: wez

Differential Revision: D20876462

fbshipit-source-id: cc7d8e6f0a6a2e04fbf3159417af41a44908b3a8
2020-04-10 13:57:52 -07:00
Adam Simpkins
4910c924a8 fix some failures in the systemd integration tests on devservers
Summary:
When running the systemd integration tests on devservers, the edenfs process
will be started as root, but the test will be running as non-root.  Therefore
the test will not have permission to send SIGINT to the edenfs process to stop
it.  Update the tests to call `edenfsctl stop` instead of directly trying to
send `SIGINT` to the edenfs process.

Reviewed By: genevievehelsel

Differential Revision: D20939015

fbshipit-source-id: 5bcf0e58fdf532084fa1273254b3d81fd20de23e
2020-04-10 13:48:11 -07:00
Adam Simpkins
baeac18ef3 add a --current-edenfs-only flag to edenfsctl doctor
Summary:
Add a command line argument to `edenfsctl doctor` to cause it to only report
problems with the current EdenFS instance, and to skip checks for system-wide
problems or other running EdenFS processes.

This does refactor a fair amount of the top-level doctor logic to encapsulate
most of the state into an `EdenDoctor` class.

This also updates the integration tests to use this flag when invoking
`edenfsctl doctor`.  Previously the integration tests could spuriously fail
due to other pre-existing problems on the system, or due to other EdenFS
instances that are currently being started or shut down by other tests running
in parallel.

Reviewed By: wez

Differential Revision: D20357521

fbshipit-source-id: 36640cc21e7bd79fbd300c4d2c7dbba127ec9170
2020-04-10 13:48:11 -07:00
Adam Simpkins
34275429fe remove all CLI code dealing with the old legacy bind-mounts config
Summary:
The bind-mounts configuration has been ignored by EdenFS since D17236366.
This removes all CLI code for dealing with this config section.

Reviewed By: wez

Differential Revision: D20876460

fbshipit-source-id: 6b3f3552de25ee28fc0418a6aaec14446520203c
2020-04-09 17:31:03 -07:00
Katie Mancini
e299b71988 Explicitly track current/pending imports -- refactor and expose current metrics
Summary:
As mentioned in D20629833, adding metrics for live
imports in `eden top` gives more transparency to the
imports process and makes identifying import related
issues easier. This is set up to expose metrics for live
imports like those for pending imports in `eden top`.

Similar to D20611728 exposing this via these counters
will log this data. Having this data persisted will allow
tracking the performance of imports, and does the set
up for more pro-active fixing of issues. Further we can
look back to see issues that are no longer occurring, but
still of interest.

This also refactors the registration code so that it requires
no copy pasting to add a new counter. Avoiding copy paste
errors when adding more counters and making it easier to
maintain.

Reviewed By: chadaustin

Differential Revision: D20630813

fbshipit-source-id: 8a7a2a0135c7b7a5cde960b84dcb434c6c99eaeb
2020-04-09 12:35:22 -07:00
Genevieve Helsel
9944a5dff5 add EdenServer recovery step and recover after failed takeover data send handshake
Summary:
* This adds a `EdenServer::recover()` method to start back up on unsuccessful takeover data send.
    * On an unsuccessful ping, filfill the `shutdownPromise` with a `TakeoverSendError` continaing the constructed `TakeoverData`. After this `recover` function is called, `takeoverPromise_` is reset, `takeoverShutdown` is set to `false`, and the `runningState_` is set to `RUNNING`.
With taking over from the returned `TakeoverData`, the user will not encounter `Transport not connected` errors on recovery.

* This adds a `EdenServer::closeStorage()` method to defer closing the `backingStore_` and `localStore_` until after our ready handshake is successful.
* This defers the shutdown of the `PrivHelper` until a successful ready handshake.

I also update the takeover documentation here with the new logic (and fix some formatting issues)

Reviewed By: simpkins

Differential Revision: D20433433

fbshipit-source-id: f59e660922674d281957e80aee5049735b901a2c
2020-04-07 09:52:21 -07:00
Genevieve Helsel
003bdfe7a5 add additional takeover "ready" handshake
Summary:
For graceful restart takeovers, we would like to implement an additional handshake. This handshake will occur right after the takeover data is ready to be sent to the client, but before actually sending it. This is to make sure the old daemon can recover in case of the client not being responsive (the client replies back to the server, and if no response is recieved in 5 seconds, the server will recover).

There are a few cases here:
* **Server sends ping (two cases discussed below)**
I introduced a new ProtocolVersion. Daemons with this change will now have ProtocolVersion4. The Server checks the max version of the client, and if this version is ProtocolVersion4, we know the client can listen for pings. So we will send the ping. Otherwise, we don't send a ping. With this, we will only send pings if we know the client will be listening for one. The case in which a client isn't listening is if we adopt this change and we downgrade past the change.

* **Server does not send ping and Client knows to listen for ping**
This will be a common case immediately after this change. The client will parse the sent data and check if it matches the "ready" ping, and if it doesn't, the client assumes the server simply sent the Takeover Data.

* **Server does not sends ping and Client doesn't know to listen for ping**
This is the case before this change.

Reviewed By: simpkins

Differential Revision: D20290271

fbshipit-source-id: b68e4df6264fb071d770671a80e28c90ddb0d3f2
2020-04-07 09:52:21 -07:00
Adam Simpkins
c0d6deaae1 remove the deprecated debugSetLogLevel() thrift API
Summary:
Using `setOption("logging", config)` is the preferred way to update the
logging configuration.  This older API is no longer needed, and I don't
believe anything should be using it any more.

Reviewed By: genevievehelsel

Differential Revision: D20876083

fbshipit-source-id: c0b40c61535bee2363f273345cbce818389de6b7
2020-04-06 18:53:00 -07:00
Adam Simpkins
8be1175931 fix several pyre-fixme comments in the integration test code
Summary:
Fix pyre-fixme comments in eden/integration/lib/edenclient.py

These are mostly due to the fact that pyre refuses to allow Optional member
variables to be unwrapped into non-Optional types even if you explicitly check
them for None.  Pyre requires these variables be copied to local variables
first.

Reviewed By: fanzeyi

Differential Revision: D20875615

fbshipit-source-id: e15236966d17ed5bce8c2c2c698d089d5b8f5e0e
2020-04-06 15:02:39 -07:00
Adam Simpkins
76577bfafb add is_process_alive() and is_edenfs_process() methods to ProcUtils
Summary:
Add methods to check if a process ID is alive, and if it looks like an EdenFS
process.

This also adds an initial version of ProcUtils for Windows, and implements
these two methods on Windows.  I have moved parts of the `winproc.py` module
to the new `proc_utils_win.py` module, to help better manage dependencies
between our modules.  This keeps all of the Windows-specific `ctypes` code
together in `proc_utils_win.py`.  The functionality that is still left on
`winproc.py` depends on `config.py`, and the `proc_utils` code should not
depend on `config.py` to help avoid circular dependencies.

Reviewed By: wez

Differential Revision: D20833245

fbshipit-source-id: 43e9b6dd1b520dcb6b2da7701de885058f0f7ea2
2020-04-03 20:05:35 -07:00
Katie Mancini
944a471065 expose the longest outstanding import
Summary:
The primary purpose of exposing counters for the maximum length of duration is to add this to `eden top`.

As discussed in D20611704, the duration of time that imports are queued for is a strong indicator of the health of the import process. Adding it to `eden top` will help give users insight into what eden is doing when it hangs for a long time or when there is an issue, indicate whether that issue is due to the import process.

Additionally we choose to use these counters to expose this data because we want to log this data. This data can be used to measure performance of the queueing and import process. In the future this data could be used to set up alerting for regressions and allow more proactive fixes.

Reviewed By: chadaustin

Differential Revision: D20611728

fbshipit-source-id: 9307c1ad749ac5fe356ba9eaf868de41b1a8a3a7
2020-04-01 09:54:30 -07:00
Jun Wu
7af4ada776 load system hgrc for hg commands without HGRCPATH
Summary:
It turns out that eden integration tests do not always set HGRCPATH for hg
commands it executes.  The testing library (integration/lib/hgrepo.py) sets
HGRCPATH for hg commands it runs.  However there are other code paths that
bypass the HGRCPATH setting.  For example:

- hg debugimporthelper started by edenfs does not have HGRCPATH set.
- hg log -r . -T{node} started by fs/cli/util.py does not have HGRCPATH set.

That caused issues. For example, without HGRCPATH, the real system hgrc is
loaded, and that can be different from the in-repo hgrc, causing issues like
migrating "narrow-heads" down and up, which pollutes stderr and fails tests.

Increase test robustness by adding an `%include $HGRCPATH` in the repo hgrc
so commands without HGRCPATH still load the desired system hgrc.

Reviewed By: chadaustin

Differential Revision: D20769184

fbshipit-source-id: 8992bfb95250b6cccb9ebcf4bbaa0a76d50480dd
2020-03-31 13:04:22 -07:00
Adam Simpkins
53f9eb0e0a replace explicit casts with pyre-ignore comments for T38947910
Summary:
Replace explicit casts working around T38947910 (Pyre not understanding
decorators) with `pyre-ignore` comments.  This will hopefully help ensure that
these are tracked more visibly, and are removed when this task is fixed.

Reviewed By: wez

Differential Revision: D20434082

fbshipit-source-id: da4e4d11e4e029a11984c0efcad2aecd0d3094bf
2020-03-30 21:23:02 -07:00
Adam Simpkins
92825c4863 exit if the EdenFS lock file ever becomes invalid
Summary:
In rare situations users end up manually deleting or removing their `.eden`
state directory without ever killing their running `edenfs` process.  This can
leave this old process running indefinitely despite the fact that it's state
directory is no longer present (or has perhaps even been replaced with new
data).

This updates edenfs to periodically check if its lock file is still valid, and
quit if it isn't.  This will help prevent old `edenfs` processes from running
indefinitely after their state directory is no longer valid.

Reviewed By: wez

Differential Revision: D20613841

fbshipit-source-id: d9a3a1e7e9b05806e086e794ebbc36e1cc71831a
2020-03-26 20:17:12 -07:00
Ratnadeep Joshi
9ce47b3031 Move eden.cli namespace to eden.fs.cli
Summary: [edenfs] Move eden.cli namespace to eden.fs.cli

Reviewed By: simpkins

Differential Revision: D20520952

fbshipit-source-id: 182793867404dcb0753363282640f8fd4d2ff496
2020-03-25 11:46:56 -07:00
Ratnadeep Joshi
6447950e1a Move cli/ directory from eden/ to eden/fs (Without changing namespace)
Summary:
[edenfs] Move cli/ directory from eden/ to eden/fs (Without changing
namespace)

Reviewed By: simpkins

Differential Revision: D20505093

fbshipit-source-id: 1975afac2ca1cd70ca407dde485c97254f4cc1e9
2020-03-25 11:18:30 -07:00
Adam Simpkins
91f4fbc5b7 improve behavior of stopping EdenFS in the integration tests
Summary:
Fix `EdenFS.shutdown()` to call `edenfsctl stop` with a timeout of 0 seconds,
telling it not to wait for EdenFS to exit.  This code then performs its own
wait with a timeout.

Previously the code called `edenfsctl stop` asking it to wait for EdenFS to
exit with a 30 second timeout.  However, since the integration test could be
the immediate parent process of EdenFS the `edenfs` process may not actually
go away until the test called `wait()` on this process, which wouldn't happen
until `edenfsctl stop` returned.  This only caused problems for cases where
the test could run `edenfs` directly without needing to run it through `sudo`:
when run through `sudo` the edenfs process would get cleaned up since `sudo`
was the immediate parent and it would wait on the process.

Reviewed By: genevievehelsel

Differential Revision: D20434081

fbshipit-source-id: 513fd2ebb5fc24a54c546a76e94827c81a4ab754
2020-03-19 20:10:06 -07:00
Durham Goode
da9aa40c43 unicode: skip binary filenames coming from Eden
Summary:
Mercurial can't handle these. Let's skip them instead of throwing an
exception.

Reviewed By: quark-zju

Differential Revision: D20016007

fbshipit-source-id: dbf37b9e315d29bcfa1e12f51bc96ed543ff6d84
2020-03-17 09:14:35 -07:00
Chad Austin
b2a8809a8b fix hg revert on conflicted file during conflict resolution
Summary: Fix a ValueError when reverting conflicted files during conflict resolution.

Reviewed By: simpkins

Differential Revision: D20254088

fbshipit-source-id: 0c121e8b4b7a3d97ce138a824a44e0d258019d0d
2020-03-16 18:35:20 -07:00
Adam Simpkins
e1490e631c add a counter to report the number of mount failures during startup
Summary:
Add a counter to report the number of mounts that we failed to remount during
startup.  Mount failures do not prevent EdenFS startup from proceeding.  It is
useful to have a metric to report if these errors did occur even though the
start-up as a whole still proceeded otherwise.

Reviewed By: chadaustin

Differential Revision: D20319512

fbshipit-source-id: fd503a1ccc91b476cc9dc2bc6323501bbbeaf2c5
2020-03-09 17:41:34 -07:00
Katie Mancini
b0a5ffb100 Expose number of imports queued
Summary: expose the counters for number of pending imports (blobs, trees, prefetches) to allow use in tooling

Reviewed By: chadaustin

Differential Revision: D20269853

fbshipit-source-id: d2b7e2110520290751699c4a891d41ebd5b374cf
2020-03-06 09:28:55 -08:00
Adam Simpkins
a0358352da remove an integration test for handling SIGKILL after SIGSTOP
Summary:
Remove a failing integration test that was testing behavior we don't really
care about.

My changes in D20210708 made this test start failing.  This integration test
was initially added to exercise the code I reverted in D20210708.

This test fails when EdenFS is invoked in the foreground and under sudo.  If
you send SIGSTOP to the EdenFS process sudo happens to notice this and send
the same signal to itself too.  This results in a state where the `sudo`
command is stopped and is never resumed so it never wakes up to reap its child
EdenFS process when EdenFS exits.  The behavior I reverted in D20210708 caused
the edenfsctl CLI code to simply ignore the fact that EdenFS was stuck in a
zombie state, and proceed anyway.  This allowed EdenFS to at least restart,
but it left old zombies stuck forever on the system.

This problem is arguably an issue with how sudo operates, and it's sort of
hard for us to work around.  To solve the problem you need to send SIGCONT to
the sudo process, but since it is running with root privileges you don't
normally have permission to send a signal to it.  It is understandable why
sudo behaves this way, since normally it is desirable for sudo to background
itself when the child is stopped.

In practice this isn't really ever a situation that we care much about
handling.  Normal users shouldn't ever get into this situation (they don't run
EdenFS in the foreground, and they generally don't run it under sudo either).

Reviewed By: genevievehelsel

Differential Revision: D20268924

fbshipit-source-id: d61d0a10ee1e132f00dbd2e4dc135808b7c79345
2020-03-04 22:15:49 -08:00
Adam Simpkins
09bf63eca1 update some of the systemd tests to wait on subprocess properly
Summary:
Update some of the systemd tests that were using
`eden.cli.daemon.wait_for_process_exit()` and were relying on it to return for
zombie processes that had not been reaped.  This test would spawn a subprocess
and then wait for it using `wait_for_process_exit()` instead of actually just
using `subprocess.Popen.wait()`.

The `wait_for_process_exit()` function is only intended to be used for
non-child processes.  For immediate children processes it is always better to
simply use `wait()`.

This refactors the code so that it uses `subprocess.Popen.wait()` where
appropriate.  This is needed to make these tests work even after D20210708
lands.

Reviewed By: wez

Differential Revision: D20242891

fbshipit-source-id: 0afd3d3d7ee1d733099ea74f7b9b19cbe48b22d4
2020-03-04 10:29:52 -08:00
Genevieve Helsel
93d6f0a3e9 use a NullTelemetryLogger during integration tests
Summary: I was looking in the `edenfs_events` table and saw that sandcastle was logging to this table. Rice was able to identify that the reason was because the integration tests were logging. So if we're on running integration tests, we should return a `NullTelemetryLogger`. The daemon currently does not log on sandcastle AFAIK.

Reviewed By: simpkins

Differential Revision: D20203556

fbshipit-source-id: e09175347631478cb366d4fa2c6092d976504dd8
2020-03-03 14:56:49 -08:00
Katie Mancini
52e211fe8e Record Mercurial file import time
Summary:
- added logging only around the import blob call to capture non-queue related wait time
- added to `test_reading_file_gets_file_from_hg` in `integration.stats_test.HgBackingStoreStatsTest`  to test import blob logging in addition to the get blob loging

(not yet done for importing trees, will do in next diff)

Reviewed By: chadaustin

Differential Revision: D20201215

fbshipit-source-id: c89281fe7d3d6e89d111ac8cce9014adff44ac40
2020-03-03 11:44:27 -08:00
Adam Simpkins
ef04ccf546 replace a bunch of pyre-fixme comments with pyre-ignoree
Summary:
D17135557 added a bunch of `pyre-fixme` comments to the EdenFS integration
tests for cases where Pyre cannot detect that some attributes are initialized
by the test case `setUp()` method.

It looks like Pyre's handling of `setUp()` is somewhat incorrect: it looks
like if a class has a `setUp()` method this currently suppresses all
uninitialized attribute errors (even if some attributes really are never
initialized).  However, Pyre does not detect `setUp()` methods inherited from
parent classes, and always warns about uninitialized attributes in this case
even they are initialized.

Lets change these comments from `pyre-fixme` to `pyre-ignore` since this
appears to be an issue with Pyre rather than with this code.  T62487924 is
open to track adding support for annotating custom constructor methods, which
might help here.  I've also posted in Pyre Q&A about incorrect handling of
`setUp()` in derived classes.

Reviewed By: grievejia

Differential Revision: D19963118

fbshipit-source-id: 9fd13fc8665367e0780f871a5a0d9a8fe50cc687
2020-02-24 18:55:19 -08:00
generatedunixname89002005287564
d801a85055 eden/integration/persistence_test.py
Reviewed By: simpkins

Differential Revision: D19995899

fbshipit-source-id: 28cf25cb5a4cde8b15f8a4f3199aaa249aade2a3
2020-02-24 15:42:45 -08:00
generatedunixname89002005307016
04bbfebc23 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Differential Revision: D20052048

fbshipit-source-id: 4319676bbb36b5772371970ddaf7dc18ef9b1295
2020-02-23 15:25:23 -08:00
Zeyi (Rice) Fan
d58863bde2 make hgcache direct read as default
Summary: It seems to be stable and not causing issues. Let's make it default everywhere.

Reviewed By: wez

Differential Revision: D19896738

fbshipit-source-id: cf6abe8f536e570017742b3a0674213a932a6a4d
2020-02-20 16:58:10 -08:00
Jia Chen
671ca89de0 Upgrade Pyre version for eden to 2927613de6d20ee2d66e98124f3834812475e122
Summary: This should get rid of the extraneous uninitialized attribute errors related to `setUp` and abstract classes.

Reviewed By: simpkins

Differential Revision: D19964487

fbshipit-source-id: 52d5a6496e372d99d4398473f9ed7672228a76f5
2020-02-19 15:05:25 -08:00
Genevieve Helsel
d90506bfb5 fork in cli daemon_exec
Summary: fork exec wait in `daemon.dameon_exec` so we can get exit code of child process in order to log.

Reviewed By: simpkins

Differential Revision: D19861810

fbshipit-source-id: 85fce52b2e2d252bb4dec779f5f975e3712b6bb5
2020-02-19 08:08:08 -08:00
Adam Simpkins
4bd038dd5c fix eden doctor's check for commit validity to handle corrupt checkouts
Summary:
When checking if a commit is valid explicitly check against the backing
repository rather than the Eden checkout.  This makes the commit work
correctly if the Eden checkout's `.hg` directory has been corrupted but the
backing repository is still fine.

Reviewed By: genevievehelsel

Differential Revision: D19629959

fbshipit-source-id: 57992260332cbc1d6868813263fb3768b50db07e
2020-01-30 11:15:37 -08:00
Jia Chen
c717ef0d7d Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Differential Revision: D19548623

fbshipit-source-id: 12d5e8ec6450de42107d07b230e4b2d0824f7c9d
2020-01-24 12:32:43 -08:00
Wez Furlong
43af241301 eden: remove hypothesis test bits
Summary:
Sadly, we didn't derive as much value from these as we would
have liked, and now they are a source of flakeyness in our tests.

Reviewed By: genevievehelsel

Differential Revision: D19460792

fbshipit-source-id: 48c82cc2d1fdbd81bece4057e93799fbcc4f4725
2020-01-23 11:37:27 -08:00
Chad Austin
f7491f7741 add independent cache size limits per object type
Summary:
Instead of clearing every single cached object when the total size
exceeds the ephemeral storage limit, keep a limit per object type and
only clear those that exceed their quota.

Reviewed By: simpkins

Differential Revision: D19358312

fbshipit-source-id: 6918d6f4cc2931aed79a9025d0e0f357ede515e0
2020-01-21 19:41:47 -08:00
Genevieve Helsel
a03dac0a83 reactivate test_abort_split_with_pending_add
Reviewed By: chadaustin

Differential Revision: D19167578

fbshipit-source-id: fa2c848a4e157bcf9c466b4b65132168201e4d97
2020-01-06 08:52:27 -08:00
Genevieve Helsel
26f4427200 add eden debug parents
Summary: adds a cli debug command to inspect the working copy parent. by default just returns eden's snapshot contents, but adds optional --hg flag to print Mercurial's dirstate information

Reviewed By: chadaustin

Differential Revision: D19167518

fbshipit-source-id: b65e112df6abe4e0e7a8a528a90b2e3d17297e66
2020-01-06 08:52:27 -08:00
Chad Austin
3d3c2a9f32 stop storing sizes in their own local store column
Summary:
Remove some half-baked, unnecessary logic for caching sizes separately
from SHA-1. Eden's backing stores do not support chunking large files
yet, so there's no value in caching content SHA-1 and size
separately. This fixes a scenario where fetching blob size and then
SHA-1 would result in two backing store imports.

Reviewed By: fanzeyi

Differential Revision: D19169096

fbshipit-source-id: dc32f3313e5f4230c06a5bbaa67da7bf0febaba8
2019-12-20 16:14:23 -08:00
Genevieve Helsel
f6cfa5f229 remove use of getScmStatusBetweenRevisions in eden doctor
Summary: There is one instace of `getScmStatusBetweenRevisions` in use - it is used in the eden cli in a hacky way to check if a commit hash is valid. Since this is not used anywhere else in a meaningful way, this replaces that use case with a hg call and depreciates `getScmStatusBetweenRevisions`

Reviewed By: simpkins

Differential Revision: D18690026

fbshipit-source-id: 02bd2c20a0f631ec41116f9fd4e18d14369298ef
2019-12-20 16:14:22 -08:00
Jia Chen
a731c7518d Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Differential Revision: D19143864

fbshipit-source-id: 0d2d4ed32423b740a67aae670b7f10691e4f4800
2019-12-20 16:14:21 -08:00
Chad Austin
d0ce25afba log to scuba upon automatic gc
Summary:
A spike in automatic GCs usually implies something has gone wrong. Log
an event for each one, recording the cache size prior to the GC and
the cache size after.

Reviewed By: simpkins

Differential Revision: D18902580

fbshipit-source-id: 158b2635733a415a9fcc7c412b2c0f44ed04aa01
2019-12-10 16:16:35 -08:00
Chad Austin
b47bf0289e ensure fuse capability flags survive graceful restart
Summary:
Two bugs conspired to cause edenfs after a graceful restart to think
the kernel supported FUSE_NO_OPENDIR_SUPPORT when it didn't: the
connection info struct wasn't zeroed, and FUSE connection capabilities
weren't properly mirrored into the Dispatcher upon graceful
restart. Fix both and add an integration test.

Reviewed By: simpkins

Differential Revision: D18903761

fbshipit-source-id: 23f4db3e240ee7d035f707820072c606a45f1138
2019-12-10 10:25:30 -08:00
Genevieve Helsel
b86b78fa14 update hg and telemetry wrapper callsites to use getScmStatusV2
Summary: This updates the hg and telemetry wrapper callsites of getScmStatus to first try running getScmStatusV2() with fallback option. This does not retry `hg status` while a checkout is in progress.

Reviewed By: simpkins

Differential Revision: D18209899

fbshipit-source-id: e7a77b902f5a0ee624e4ea3185a1901bdac090e6
2019-12-04 15:46:46 -08:00
Wez Furlong
c03af477eb eden: remove legacy bind mount concept from redirections
Summary:
Now that we've transitioned to the newer redirections
configuration we can remove the older bind mounts configuration
parsing, and that is what this diff does.

This is helpful because in situations where the user has run
`hg co null` as part of some troubleshooting advice, the legacy
bind mounts would remain mounted and obstruct some of the
steps that would have fixed up the users repo.

Reviewed By: pkaush

Differential Revision: D18337246

fbshipit-source-id: 23f27787d609e1c38a9c98b8b6596bb40743b9ca
2019-12-04 10:47:14 -08:00
Wez Furlong
34636666ac eden: cli: add redirect unmount command
Summary:
The purpose of this command is to unmount/unlink any configured
redirections without removing their configuration.

The intent is to call this for a mount when we are unmounting; I'll do
that bit in a follow on diff.

Reviewed By: pkaush

Differential Revision: D18801872

fbshipit-source-id: 096d9595091da72aa85f4259cbab022a1fe0c01f
2019-12-04 08:45:26 -08:00
Genevieve Helsel
aae83490c9 compare blob contents sha1 in Diff.cpp
Summary: Even if blobs have different hashes, they could have the same contents. For example, if between the two revisions being compared, if a file was changed and then later reverted. In that case, the contents would be the same but the blobs would have different hashes. Currently, `getScmStatusBetweenRevisions()` would report false positives in this case. This is also needed so we do not report false positives in `getScmStatus()` when hit this code path

Reviewed By: simpkins

Differential Revision: D18647086

fbshipit-source-id: 66e12648a24fd7e5612eee5e599a5b81c7c5f2d1
2019-11-22 08:09:37 -08:00
Genevieve Helsel
3807e751ca make enforceParents configurable for getScmStatusV2
Summary: This reads `enforceParents` from a config instead of always assuming true for `getScmStatusV2()`. This will allow a easy kill switch in case throwing errors from this thrift call causes issues with something that calls hg status

Reviewed By: simpkins

Differential Revision: D18258164

fbshipit-source-id: 1ae421a941c01a678d25d5453c771262b03558d0
2019-11-20 17:51:21 -08:00
Genevieve Helsel
5d2c5ae60a more helpful error message when calling status with out of date parent.
Summary: make the error message returned in the case of out of date parents during a new status call more user friendly and provide possible remediation instructions

Reviewed By: simpkins

Differential Revision: D18328835

fbshipit-source-id: b214f45bb055d008db8b233ddd2a1843332db838
2019-11-14 16:46:15 -08:00
Adam Simpkins
46890ae1ec Merge fb-mercurial sources into the eden repository
Summary:
Merge the fb-mercurial code into the Eden repository, under the
`eden/scm` subdirectory.

Reviewed By: quark-zju

Differential Revision: D18445774

fbshipit-source-id: fc3307f9937e0c7e1c8f7d03c5102c4fe5dedb10
2019-11-13 20:20:32 -08:00
generatedunixname89002005307016
3f46bd1142 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: shannonzhu

Differential Revision: D18250419

fbshipit-source-id: b4ab494552f8ad6601224c03eab6ee5904b83255
2019-10-31 15:31:07 -07:00
Genevieve Helsel
495b4394b8 add a new getScmStatusV2() API to replace getScmStatus()
Summary:
Add a new thrift API for computing the difference between the working
directory and a given source control commit.

This has the following differences from the old getScmStatus() commit:

- The parameters are accepted in a GetScmStatusParams structure now.
  This makes it easier for the server-side C++ implementation to tell which
  parameters have actually been specified by the caller.  This will make it
  easier to extend this API in the future without having to replace it with a
  new function call again.

- The return value is a GetScmStatusResult, which includes both the ScmStatus
  and the EdenFS version number.  This will allow code like `hg status` to get
  both the status results and the EdenFS version in a single call, without
  needing to make multiple separate thrift calls.

- This new call will return an error if the caller requests the status against
  a commit that disagrees with EdenFS's view of the current commit.  Because
  the individual `hg` command line processes do not perform any
  synchronization of their own when reading the working directory parent,
  they can often call EdenFS with stale parent information, or while a
  checkout is currently in progress.  This new behavior will reject the
  request with an error, rather than having EdenFS perform a potentially very
  expensive status computation when the results probably aren't actually
  useful to the caller anyway.

Reviewed By: chadaustin

Differential Revision: D15110218

fbshipit-source-id: ebc2f74dafc090d4fd245de8e4d62e2b086500dd
2019-10-29 09:56:31 -07:00
Genevieve Helsel
894416f20a add EdenErrorType to EdenError
Summary: Adds a non-optional EdenErrorType struct for EdenError, this can be used in case of special error case handling of errors without error message parsing. Currently this is just passed along and not consumed anywhere in the client, but later in the stack is used for specific retry of checkout if "CHECKOUT_IN_PROGRESS" on the consuming side.

Reviewed By: chadaustin

Differential Revision: D18139917

fbshipit-source-id: b3f2ec4c480fc5246ff2f46d09c436021bad8b61
2019-10-29 09:23:03 -07:00
Xavier Deguillard
bf08af091a tests: remove fastmanifest requirement
Summary: Fastmanifest is going away, remove it from the test.

Reviewed By: chadaustin

Differential Revision: D18145000

fbshipit-source-id: ee75ebe4eda19caca92fd0a84bf0ae9f48112167
2019-10-28 11:38:49 -07:00
Chad Austin
4f360eafd2 clang-format
Summary: Formatting had diverged in a few places. Fix that up.

Reviewed By: fanzeyi

Differential Revision: D18123219

fbshipit-source-id: 832cdd70789642f665a029196998928a9173be81
2019-10-24 14:56:43 -07:00
Wez Furlong
cb49bbbbf5 eden: improve readability for failed tests.
Summary:
transforms this horrendous mess:

```
> stderr=b"==2460594==AddressSanitizer: libc interceptors initialized\n|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||\n|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||\n|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||\n|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||\n|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||\nMemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff\nredzone=16\nmax_redzone=2048\nquarantine_size_mb=256M\nthread_local_quarantine_size_kb=1024K\nmalloc_context_size=30\nSHADOW_SCALE: 3\nSHADOW_GRANULARITY: 8\nSHADOW_OFFSET: 0x7fff8000\n==2460594==Installed the sigaction for signal 11\n==2460594==Installed the sigaction for signal 7\n==2460594==Installed the sigaction for signal 8\n==2460594==T0: FakeStack created:
0x7f524432c000 -- 0x7f5244e35000 stack_size_log: 20; mmapped 11300K, noreserve=0 \n==2460594==T0: stack [0x7ffe4480f000,0x7ffe4500f000) size 0x800000; local=0x7ffe4500bcc8\n==2460594==AddressSanitizer Init done\n==2460674==AddressSanitizer: failed to intercept '__cxa_throw'\n==2460674==AddressSanitizer: libc interceptors initialized\n|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||\n|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||\n|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||\n|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||\n|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||\nMemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff\nredzone=16\nmax_redzone=2048\nquarantine_size_mb=256M\nthread_local_quarantine_size_kb=1024K\nmalloc_context_size=30\nSHADOW_SCALE: 3\nSHADOW_GRANULARITY: 8\nSHADOW_OFFSET: 0x7fff8000\n==2460674==Installed the sigaction for signal 11\n==2460674==Installed the sigaction for signal 7\n==2460674==Installed the sigaction for signal 8\n==2460674==T0: FakeStack created: 0x7fa4b4315000 -- 0x7fa4b4e1e000 stack_size_log: 20; mmapped 11300K, noreserve=0 \n==2460674==T0: stack [0x7ffd70040000,0x7ffd70840000) size 0x800000; local=0x7ffd7083f7c8\n==2460674==AddressSanitizer Init done\nAddressSanitizer ignores mlock/mlockall/munlock/munlockall\n==2460732==AddressSanitizer: libc interceptors initialized\n|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||\n|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||\n|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||\n|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||\n|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||\nMemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff\nredzone=16\nmax_redzone=2048\nquarantine_size_mb=256M\nthread_local_quarantine_size_kb=1024K\nmalloc_context_size=30\nSHADOW_SCALE: 3\nSHADOW_GRANULARITY: 8\nSHADOW_OFFSET: 0x7fff8000\n==2460732==Installed the sigaction for signal 11\n==2460732==Installed the sigaction for signal 7\n==2460732==Installed the sigaction for signal 8\n==2460732==T0: FakeStack created: 0x7fd43d241000 -- 0x7fd43dd4a000 stack_size_log: 20; mmapped 11300K, noreserve=0 \n==2460732==T0: stack [0x7ffe73d21000,0x7ffe74521000) size 0x800000; local=0x7ffe74520c28\n==2460732==AddressSanitizer Init done\n==2461383==AddressSanitizer: failed to intercept '__cxa_throw'\n==2461383==AddressSanitizer: libc interceptors initialized\n|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||\n|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||\n|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||\n|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||\n|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||\nMemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff\nredzone=16\nmax_redzone=2048\nquarantine_size_mb=256M\nthread_local_quarantine_size_kb=1024K\nmalloc_context_size=30\nSHADOW_SCALE: 3\nSHADOW_GRANULARITY: 8\nSHADOW_OFFSET: 0x7fff8000\n==2461383==Installed the sigaction for signal 11\n==2461383==Installed the sigaction for signal 7\n==2461383==Installed the sigaction for signal 8\n==2461383==T0: FakeStack created: 0x7feb8e014000 -- 0x7feb8eb1d000 stack_size_log: 20; mmapped 11300K, noreserve=0 \n==2461383==T0: stack [0x7ffce3772000,0x7ffce3f72000) size 0x800000; local=0x7ffce3f71778\n==2461383==AddressSanitizer Init done\nAddressSanitizer ignores mlock/mlockall/munlock/munlockall\n==2461393==AddressSanitizer: libc interceptors initialized\n|| `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||\n|| `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||\n|| `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||\n|| `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||\n|| `[0x000000000000, 0x00007fff7fff]` || LowMem     ||\nMemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff\nredzone=16\nmax_redzone=2048\nquarantine_size_mb=256M\nthread_local_quarantine_size_kb=1024K\nmalloc_context_size=30\nSHADOW_SCALE: 3\nSHADOW_GRANULARITY: 8\nSHADOW_OFFSET: 0x7fff8000\n==2461393==Installed the sigaction for signal 11\n==2461393==Installed the sigaction for signal 7\n==2461393==Installed the sigaction for signal 8\n==2461393==T0: FakeStack created: 0x7f884e0d9000 -- 0x7f884ebe2000 stack_size_log: 20; mmapped 11300K, noreserve=0 \n==2461393==T0: stack [0x7fff4b1c2000,0x7fff4b9c2000) size 0x800000; local=0x7fff4b9c1878\n==2461393==AddressSanitizer Init done\nabort: No module named toml!\nerror: Command '['/data/users/wez/fbsource/fbcode/buck-out/dev/gen/scm/hg#binary/hg', 'debugedenrunpostupdatehook', '-R', PosixPath('/var/tmp/eden_test.wahpn1vx/mounts/main')]' returned non-zero exit status 255.\n"
```

into this:

```
...
> AddressSanitizer ignores mlock/mlockall/munlock/munlockall
> ==2492882==AddressSanitizer: libc interceptors initialized
> === How to use this, how to get the raw stack trace, and more: fburl.com/ASAN ===
> || `[0x10007fff8000, 0x7fffffffffff]` || HighMem    ||
> || `[0x02008fff7000, 0x10007fff7fff]` || HighShadow ||
> || `[0x00008fff7000, 0x02008fff6fff]` || ShadowGap  ||
> || `[0x00007fff8000, 0x00008fff6fff]` || LowShadow  ||
> || `[0x000000000000, 0x00007fff7fff]` || LowMem     ||
> MemToShadow(shadow): 0x00008fff7000 0x000091ff6dff 0x004091ff6e00 0x02008fff6fff
> redzone=16
> max_redzone=2048
> quarantine_size_mb=256M
> thread_local_quarantine_size_kb=1024K
> malloc_context_size=30
> SHADOW_SCALE: 3
> SHADOW_GRANULARITY: 8
> SHADOW_OFFSET: 0x7fff8000
> ==2492882==Installed the sigaction for signal 11
> ==2492882==Installed the sigaction for signal 7
> ==2492882==Installed the sigaction for signal 8
> ==2492882==T0: FakeStack created: 0x7fb0a02d5000 -- 0x7fb0a0dde000 stack_size_log: 20; mmapped 11300K, noreserve=0
> ==2492882==T0: stack [0x7ffc2f49a000,0x7ffc2fc9a000) size 0x800000; local=0x7ffc2fc99588
> ==2492882==AddressSanitizer Init done
> abort: No module named toml!
> error: Command '['/data/users/wez/fbsource/fbcode/buck-out/dev/gen/scm/hg#binary/hg', 'debugedenrunpostupdatehook', '-R', PosixPath('/var/tmp/eden_test.5v9750_4/mounts/main')]' returned non-zero exit status 255.
```

Reviewed By: genevievehelsel

Differential Revision: D18038964

fbshipit-source-id: cb93229ca37e7e9d08fa3335830782b8f9f69f99
2019-10-21 10:39:53 -07:00
generatedunixname89002005307016
4c76d686a8 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D17956249

fbshipit-source-id: d5c8b5aa73151b3fea67aec35d70f332030da2c9
2019-10-16 16:56:29 -07:00
Xavier Deguillard
245d568520 fix rebase_test.py
Summary:
A recent change removed the revision number from the rebase output, fix the
EdenFS test to not have it too.

Reviewed By: genevievehelsel

Differential Revision: D17954310

fbshipit-source-id: 6c1db48086af4b7b138e6c3f4ef0bb362d2256f8
2019-10-16 10:38:28 -07:00
Joseph Friesen
3e0241fc87 add permission mask check to mknod unit test
Summary: add permission mask check to mknod unit test

Reviewed By: chadaustin

Differential Revision: D17880601

fbshipit-source-id: 484d05a4c4dc424504da77d0b37a4739c15f2579
2019-10-11 21:11:02 -07:00
Chad Austin
4b47257165 remove EdenConfig accessors
Summary:
Instead of having accessors for every config setting in EdenConfig,
just expose the ConfigSettings directly.

Reviewed By: fanzeyi

Differential Revision: D17847805

fbshipit-source-id: 8c6c1010c010113cf859677449797ea916f2a2a5
2019-10-11 17:55:19 -07:00
Chad Austin
8cac2bfe6a Remove dead includes in eden
Reviewed By: wez

Differential Revision: D17877514

fbshipit-source-id: e7f8ed8364bdb7a77f293cbdf4b48e8f15e64c30
2019-10-11 16:45:01 -07:00
Andres Suarez
fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00
Joseph Friesen
df6c7804d1 enhance mknod to support regular files
Summary:
Some Unix applications (notably, nfsd) create regular files using vfs_create, which ends up invoking the `mknod` system call rather than `open`, which for historical reasons only supported socket creation with Eden. However, since Eden supports regular files, we can broaden the FUSE mknod handler to support regular files as well.

For context, see https://github.com/GoogleCloudPlatform/gcsfuse/issues/137#issuecomment-155273363

Reviewed By: chadaustin

Differential Revision: D17792424

fbshipit-source-id: 466fcbcb3bcb587e731bc8b2a3e0f1508ff1f4e4
2019-10-10 17:17:19 -07:00
Jun Wu
dcc1c59270 Update hg tests for new update --merge state
Summary: D17766371 added an `update --merge` state. Teach eden tests about it.

Reviewed By: wez

Differential Revision: D17837836

fbshipit-source-id: a95ed326bf435f7340d7910307c8c5c761812514
2019-10-09 18:22:19 -07:00
Ken Yong Quan Oung
b80e719c81 Fix type annotation for ExpectedFileSet
Summary:
## Backstory
Pyre was throwing errors in my diff (D17747558) regarding an extraneous fixme. Turns out PyreBot has been adding and removing these fixmes during version updates (see D17135557 and D16183608), so I suspect it's something to do with the Pyre version. Anyways, I figured it'd be easier to do the annotation than to remove the fixme and risk Pyre throwing the same error in a later diff.

## What I did
I added the Key type (Path) and Value type(ExpectedFileBase). mypy then started throwing an error regarding __iter__ returning the wrong type because it wanted an iterator over keys rather than values. Fixed that and added .values() to the for loop.

Reviewed By: genevievehelsel

Differential Revision: D17806135

fbshipit-source-id: c07feee33db78a9bff19ba9856a7047657b8c63e
2019-10-08 11:18:51 -07:00
Adam Simpkins
0b5a1295fc support running the hg status integration tests in CMake builds
Summary:
Update the CMakeLists.txt files to support building the hg integration tests.
At the moment this only includes one of the test files (`status_test.py`).
I have not verified if tests from the other modules pass yet or if they need
any additional tweaks to work in CMake-based builds.

Reviewed By: pkaush, fanzeyi

Differential Revision: D17678991

fbshipit-source-id: 4a5ee5a8d6039d9d2a635c7027897bbeed14f8c0
2019-10-04 08:56:38 -07:00
Adam Simpkins
8ce111ef53 support building the integration tests with CMake
Summary:
Add initial support for building and running some of the integration tests
with CMake.  For now this just runs the tests from basic_test.py, just to
confirm that most of the framework code works in CMake-based builds.

Many of the other tests should also work as well, but a few of them we may
want to disable for CMake-based builds.  e.g., a couple of the tests depend on
hypothesis, and we would need to include hypothesis as a dependency.  Some of
the tests that use systemd might also require a little more work to get
working.

Reviewed By: fanzeyi

Differential Revision: D17659026

fbshipit-source-id: 67420fda9e1021a0cddee2d385fd21e34fb2fd70
2019-10-04 08:56:38 -07:00
Genevieve Helsel
3137b65fb1 pyre-eden typing fix
Summary:
pyre-eden is mad at some diffs (D17531102, D17459971, D17252083, D17694987, D17633671, ...). I tried actually fixing this but couldn't come up with something immediately.

error here: https://our.intern.facebook.com/intern/sandcastle/log/?instance_id=36028797165385523&step_id=36028798422194913&step_index=14&name=Pyre+found+errors.

Reviewed By: wez

Differential Revision: D17703291

fbshipit-source-id: c53cde2226409ea3d7e381056a047da3da7084c6
2019-10-02 18:02:18 -07:00
Wez Furlong
fed51ee453 eden: fixup fake_edenfs tests when compiled in @mode/opt
Summary:
Force a reference to the edenfsctlPath flag, otherwise the
linker will discard it and a large number of tests will fail.

Reviewed By: simpkins

Differential Revision: D17683222

fbshipit-source-id: b7cb29e74af85b544f45a228770ad2613c8e6efc
2019-10-01 08:17:29 -07:00
Wez Furlong
d58a3c96d8 eden: remove legacy bind mount code
Summary:
This diff removes the logic that consumes the legacy bind
mount list and mounts them on startup.  That functionality has been
replaced with the eden redirect command.

Instead of performing the bind mounts in the server, the server will
now run `eden redirect fixup` to apply that configuration.

This diff also changes the behavior of performBindMounts: previously, if the
bind mount setup failed, we would tear down the entire repo mount.  Since we're
now spawning an external process, it is much more likely that something might
fail and result in a bad experience, so we no longer bail out in that case:
we'll continue and leave the bind mounts as-is.  The user can then use `eden
doctor` or `eden redirect fixup` to sort things out.

Reviewed By: simpkins

Differential Revision: D17236366

fbshipit-source-id: 8b004551a076216f0e5448942f00b5195ee18803
2019-09-30 18:57:14 -07:00
Adam Simpkins
19f2d16c33 change the scm/hg:hg target to use a sh_binary() rule
Summary:
Change the `//scm/hg:hg` target to use an `sh_binary()` rule that invokes the
`:hg_rust` binary with the proper environment so it can find its dependencies,
rather than copying the binary and all of its dependencies into a new
subdirectory.

In dev mode builds the `hg_rust` binary isn't guaranteed to work anywhere
other than its original location, due to the way that dev mode builds use
`$ORIGIN` in the binary's `RPATH` setting.  This happened to work up until now
as the hg_rust binary did not have any separate libraries, but I plan to add
one on the `chg` library.

Reviewed By: quark-zju

Differential Revision: D17109104

fbshipit-source-id: ae8bb1126969f012d1d2fb7d04e80867a310b9a8
2019-09-26 20:15:04 -07:00
Adam Simpkins
814792d584 add an --if-not-running flag to eden start
Summary:
Add a flag to cause `eden start` to exit successfully without doing anything
if EdenFS is already running.  This flag makes it slightly easier for
automation to ensure that EdenFS is running, without logging warnings if
EdenFS was already running.

I also cleaned up the error message slightly when `eden start` is used
without this flag and fails if EdenFS was already running.  Previously the
exception thrown was unhandled so it also printed a python backtrace.  Now the
code throws an exception that is caught by the higher level command line code,
so it is printed in a more user-friendly way.

Reviewed By: wez

Differential Revision: D17440486

fbshipit-source-id: d7661ef7be7159bf5542b20e99a0b5495690e5a2
2019-09-19 15:21:28 -07:00
Wez Furlong
51eaad1918 eden: chown now accepts user and group names (not just ids)
Summary: This makes it a bit more human friendly

Reviewed By: chadaustin

Differential Revision: D17249465

fbshipit-source-id: 40d5afc77ded34237e1860d5b91e9257a732e480
2019-09-17 07:29:40 -07:00
Wez Furlong
b2d7ab7fec eden: teach chown to use redirection data
Summary:
D17236366 will disable the getBindsMount thrift call and
remove the internal source of data about bind mounts.  We instead
have a more current set of data from the `redirect` command, so
tech `eden chown` to use that data.

Reviewed By: chadaustin

Differential Revision: D17249433

fbshipit-source-id: 853f24e729814c501768e9834765e1be283d6aac
2019-09-17 07:29:39 -07:00
Chad Austin
a4311562e4 build integration test helpers with open source gflags
Summary:
Integration test helpers relied on an implicit gflags include. Make
that explicit so they compile against open source gflags and glog.

Reviewed By: wez

Differential Revision: D17264335

fbshipit-source-id: e336423b71c0f15e29b0e4ad604328b7624080a8
2019-09-16 13:32:15 -07:00
Adam Simpkins
c6de7c47ee always ensure that the contents of the .eden/ directory are correct
Summary:
Make sure the contents of the special `.eden/` subdirectory are correct each
time we mount a checkout.  Before we would generally only set up the contents
of this directory if it didn't previously exist.

Now the code verifies that the contents of each symlink in this directory are
correct, and recreates the symlink if needed.

This allows EdenFS to automatically repair the contents of this directory even
if the checkout or its `clients` directory has been manually moved.

Reviewed By: wez

Differential Revision: D17279413

fbshipit-source-id: e24e7530f44fff94ebb6f67174aaf78c9b498d6b
2019-09-11 22:02:16 -07:00
generatedunixname89002005289445
9b9015c137 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D17255059

fbshipit-source-id: 4eb207bcefb699c1886d1f0c1511b6d26100ff0e
2019-09-09 07:41:21 -07:00
Adam Simpkins
92b770a40e fsck: extract orphaned symlink inodes as symlinks
Summary:
Update the fsck code to save any orphaned symlink inodes that it finds as
symlinks in the repair archive directory, rather than saving the contents as a
regular file.

Reviewed By: wez

Differential Revision: D17170346

fbshipit-source-id: 4cba8b27233b728114a80a327ab519b039297aea
2019-09-04 11:08:10 -07:00
Adam Simpkins
3f7e72dc3e automatically perform an fsck scan when needed
Summary:
Use the new `OverlayChecker` class to automatically scan for errors and
attempt to repair them if the overlay was not shutdown cleanly the previous
time it was used.

Reviewed By: wez

Differential Revision: D16596601

fbshipit-source-id: 9923565b101ba953e92909e502be6ef5895c5cbd
2019-09-04 11:08:10 -07:00
Wez Furlong
f09c488a03 eden: stop reporting user.sha1 in listxattr
Summary:
This was causing problems on macos where various tools
would enumerate and helpfully try to preserve attributes across
copies.  On macos this would result in appledouble metadata files
being created to track the metadata in the destination file,
which clutters up the repo and has surprising secondary effects
such as being picked up by glob operations in cmake build rules.

This diff simply stops enumerating the extended attribute.

Reviewed By: fanzeyi

Differential Revision: D17140414

fbshipit-source-id: 2924657dc75b900baf70595edfa72e5d0521a697
2019-09-03 08:04:15 -07:00
generatedunixname89002005289445
13e683608d Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: sinancepel

Differential Revision: D17135557

fbshipit-source-id: 07afef940271a277c75834892733901d070bfa5f
2019-08-30 13:37:34 -07:00
Chad Austin
e6d22284ae create treemanifest repositories in HgRepository
Summary:
The snapshot generation code and many integration tests create
repositories. By default, they were creating flatmanifest
repositories, which are on their way out. Instead, create tree-only
repos.

Reviewed By: strager

Differential Revision: D17066151

fbshipit-source-id: f99a9543440da6fd7cce0065c3cd7f91a59a02d5
2019-08-28 17:06:22 -07:00
Chad Austin
b7caa4fb5a remove flatmanifest integration tests
Summary:
Flatmanifest support is going away. Remove over 100 integration tests
for flatmanifest-only repos.

Reviewed By: fanzeyi

Differential Revision: D17064019

fbshipit-source-id: b578ca14a231f0ee1f2fee8b464038c7e2201392
2019-08-26 18:50:29 -07:00
generatedunixname89002005289445
01d06886cb Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: sinancepel

Differential Revision: D16863919

fbshipit-source-id: c76f41992b9a1a57080eed932724b65c1fd846f5
2019-08-16 14:44:25 -07:00
Adam Simpkins
2c7f65c021 fix handling of errors that occur early during mount initialization
Summary:
Update `EdenServer::mount()` to correctly handle errors that occur during the
mount `INITIALIZING` phase.  Previously the code did not add error callbacks
to the `Future` result to handle errors during initialization.  As a result we
would propagate the exception back to the thrift caller, but the `EdenMount`
object would remain in our mount point list, stuck forever in the
`INITIALIZING` state.

Reviewed By: strager

Differential Revision: D16590032

fbshipit-source-id: 9adbdf05441dad815096b195ece36f3d958c96a9
2019-07-31 20:09:46 -07:00
Chad Austin
fe64ec3874 use fb303 repo in open source build
Summary: Add a dependency from the eden open source build to the fb303 open source build and switch EdenServiceHandler to BaseService.

Reviewed By: simpkins

Differential Revision: D15528156

fbshipit-source-id: 2ca5c31dd9fcc9bac43fd399b27f33b6f2c5ebfc
2019-07-24 21:07:04 -07:00
Chad Austin
ae35e76c9c add a getDaemonInfo() thrift method
Summary:
Open source fb303 will not have getPid() or getCommandLine(), so
introduce a new method for Eden's tests.

Reviewed By: fanzeyi

Differential Revision: D16292993

fbshipit-source-id: 5cdc006ec0ee15f50a3e1cebe9b46a3ea275ff78
2019-07-17 13:47:02 -07:00
Jake Crouch
a253e8045b Fix flaky counter mount/unmount test
Summary: The CountersTest would previously fail if by chance the counters prefixed by "thrift" and "thrift_client" were accounted for between getting "counters" and "counters2", since these counters should not be modified when mounting/unmounting mounts we will just filter them out.

Reviewed By: chadaustin

Differential Revision: D16265511

fbshipit-source-id: 21af0dff345977692785136ca0333d23d5c77e0d
2019-07-17 12:16:18 -07:00
Jake Crouch
277da58973 Unregister journal stats callbacks
Summary: I found out that the journal stats callbacks that were getting registered were not getting unregistered, this diff fixes that.

Reviewed By: chadaustin

Differential Revision: D16187569

fbshipit-source-id: 8c84e1515e376ccd7036a22c06e2e6b98dc62342
2019-07-12 12:27:28 -07:00
generatedunixname89002005289445
1be6e4d957 Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: grievejia

Differential Revision: D16183608

fbshipit-source-id: 529a893a021c8101e6ad28b8d88d22d4d05aa732
2019-07-10 14:48:04 -07:00
Zeyi (Rice) Fan
312c383a9b enable logview by default
Summary: Turn on logview collecting by default. Also disable logview for Eden integration tests.

Reviewed By: chadaustin

Differential Revision: D15978960

fbshipit-source-id: 623c3be7a461e0bb9bc44924fccfdb006565fad6
2019-07-01 15:59:44 -07:00
Brian Strauch
3986ddb614 ObjectStore stats
Summary: Added the cli command `eden stats object-store` for querying the counts on what part of the object store was responsible for finding the blob or blob size (local store or backing store). This will tell us how well local and in-memory caching works for different workflows.

Reviewed By: chadaustin

Differential Revision: D15934535

fbshipit-source-id: 70345f11a51c3c6996dc001d4101744395a3d182
2019-07-01 12:49:57 -07:00
Wez Furlong
482f18c982 eden: add .eden-redirections configuration
Summary:
This diff adds a single repo-wide `.eden-redirections` file that is used to
record the redirection configuration for the repo.

The redirection configuration code knows to look at this file and fold it in to
the effective configuration; the legacy bind mounts are applied first, then the
repo redirection configuration and then the user specified redirections.

The intent is that a `post-update` hook will invoke `eden redirect fixup` to
apply the configuration from the repo, and to have the eden daemon also
trigger that after (re-)mounting the repo.

In the future we can extend this to allow different profiles to be enabled
or disabled, but for now this is the minimum viable product.

Reviewed By: strager

Differential Revision: D15867225

fbshipit-source-id: b0a95936dd28283de6c7439ca8e503caef4e7247
2019-06-25 18:42:38 -07:00
Wez Furlong
66eb606372 eden: add eden redirect subcommand
Summary:
This is part of the effort to make our bind-mount configuration more
visible and easier to change.

The idea is to generalize the concept of redirection and add a command to help
manage it.

The `eden redirect add` subcommand allows creating one of two different kinds
of redirection:

* `bind` - allocate some space using `mkscratch` and mount it into the repo
* `symlink` - allocate some space using `mkscratch` and create a symlink
  that points to it from the repo

On Linux we use bind mounts to implement `bind` but on macOS, which doesn't
have a bind mount concept, we create a sparse disk image file that can grow
to match the size of the disk on which it is created (in practice these are a
7-15MB in size to start and grow as the user stores data into them).

The `eden redirect del` subcommand allows removing a redirection, including
the legacy `bind-mounts` configuration from `.eden/client/config.toml`.

The `eden redirect list` subcommand lists the effective set of redirections,
both from the new redirections configuration and the legacy `bind-mounts`
configuration, along with their state.

The `eden redirect fixup` subcommand iterates over the effective set of
redirections and can remove and reinstate any that are in a broken state.

Reviewed By: strager

Differential Revision: D15707319

fbshipit-source-id: a5dd8c44c9f748482d7b48855b1305d44267885c
2019-06-25 18:42:38 -07:00
Zeyi (Rice) Fan
a38b05612d concurrently importing blobs from Mercurial and Mononoke
Summary: This diff takes care of importing blob from Mononoke and Mercurial at the same time, also improves the name situation in the statistics counters.

Reviewed By: strager

Differential Revision: D15768557

fbshipit-source-id: 10cf831b1ae6dc9e6b91f1e96508c4fa92583743
2019-06-24 13:45:02 -07:00
Adam Simpkins
73509a87f8 restore the $USER environment variable when dropping privileges
Summary:
If edenfs was started using `sudo`, the `$USER` environment variable will be
set to `root` rather than the actual user.  When we drop privileges make sure
we restore the value of `$USER` as well.

The `$USER` variable isn't checked anywhere else in edenfs itself, but it
matters for subprocesses we spawn, like `hg debugedenimporthelper`.

I also changed the code to clear the `SUDO_*` variables as well, mostly
just for good measure.

Reviewed By: kulshrax

Differential Revision: D15929539

fbshipit-source-id: e022c7ae762e2a5e86d0227058bb476aff17cf55
2019-06-20 21:01:36 -07:00
Adam Simpkins
eba5659ac4 enable automatic garbage collection for RocksDBLocalStore
Summary:
Add a periodic task for performing LocalStore management tasks.  For now only
the RocksDBLocalStore class implements this management task.

When this periodic task runs the RocksDBLocalStore object computes how much
space each of the column families are using and publishes this as fb303
counters.  If the total size of the ephemeral column families exceeds a
configurable limit it then triggers a background garbage collection task.

I also added a new `edenfsctl stats local_store` command that reports the new
counters added by this diff.

Reviewed By: chadaustin, strager

Differential Revision: D15798505

fbshipit-source-id: 25ca4ba80f5a9c4a1a09dc08633c7b3af363d7ff
2019-06-20 20:57:04 -07:00
Adam Simpkins
9bfb48c921 update license headers in .py files
Summary:
Update the copyright & license headers in Python files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487088

fbshipit-source-id: 9f2138dff41048d2c35f15e09a04ae5a9c9c80dd
2019-06-19 17:02:46 -07:00
Adam Simpkins
aa5e6c7295 update license headers in C++ files
Summary:
Update the copyright & license headers in C++ files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487078

fbshipit-source-id: 19f24c933a64ecad0d3a692d0f8d2a38b4194b1d
2019-06-19 17:02:45 -07:00
Kostia Balytskyi
36f4698c5a entrypoint: introduce buck-buildable hg.rust
Reviewed By: farnz

Differential Revision: D15844921

fbshipit-source-id: 16ef18915b82344a553fec92af9ec9fc445e3ccb
2019-06-17 11:32:16 -07:00
Adam Simpkins
aa45fa2cb7 periodically reload the config files
Summary:
Add a periodic task to reload the configuration file from disk.  By default
this runs once every 5 minutes, but this interval can be controlled from the
config file.

At the moment reloading the config file does not do much other than update the
interval for how frequently the config file is reloaded.  However, I plan to
add additional periodic tasks shortly that are controlled by this config
setting.

This will also make it possible for other parts of the code to
access the config settings in the `ServerState` and use them as-is without
checking to see if they reloaded.  Currently all of the code that accesses
config values performs a check to see if the config needs to be reloaded.  If
we want to switch to Mercurial-style configs in the future that check will be
substantially more expensive.

This diff also includes a new thrift call to force the config file to be
reloaded immediately.  This can be used to restart automatic config reloading
if it is ever disabled in the config file.

Reviewed By: wez

Differential Revision: D15756357

fbshipit-source-id: 1999f4730903633ce838842932a6ae6a65eda4e6
2019-06-14 18:14:43 -07:00
Adam Simpkins
90f48a3105 fix a few additional python lint issues
Summary: Fix a few more issues raised by our Python lint checks.

Reviewed By: wez

Differential Revision: D15776717

fbshipit-source-id: 621960579c4567c4fb9395ae14cd7a8666726c1c
2019-06-12 14:00:57 -07:00
Adam Simpkins
20f211acb8 remove unused python imports
Summary: Remove a number of unused imports detected by the linter.

Reviewed By: wez

Differential Revision: D15776268

fbshipit-source-id: 221f45d275664d037bbabcac9858b40266b4833e
2019-06-12 14:00:57 -07:00
Matt Glazar
5d8e8a5fcd Improve error message if systemd is not running
Summary:
If the systemd user manager is not running (e.g. it crashed or was manually stopped), 'eden stop' fails with an unhelpful error message:

> pystemd.dbusexc.DBusConnectionRefusedError: [err -111]: Could not open a bus to DBus

or

> pystemd.dbusexc.DBusBaseError: [err -2]: Could not open a bus to DBus

Provide a better experience: tell the user the most likely cause, and suggest a solution:

> error: The systemd user manager is not running. Run the following command to start it, then try again:
> sudo systemctl start user@strager.service

Reviewed By: wez

Differential Revision: D13791023

fbshipit-source-id: 5172df0a52d21c311b27b8a527cad934f9882154
2019-06-12 13:32:54 -07:00
Adam Simpkins
232c3b2e2b update the ConfigTest class to run without a repository
Summary:
Summary
Change `ConfigTest` to derive directly from `EdenTestCase` rather than using
the `eden_repo_test` decorator.  The configuration test code doesn't really
need a repository, and so we don't need to run it twice (for both Mercurial
and Git repositories).

Reviewed By: wez

Differential Revision: D15756359

fbshipit-source-id: 90d5011ae1ff7d2a251c9e7bb776045fbe2fdfe1
2019-06-11 18:27:21 -07:00
Adam Simpkins
53a6513e14 clean up arguments to the EdenFS class in the integration tests
Summary:
Clean up the `EdenFS` class construction.

Previously it accepted the `eden_dir`, `etc_eden_dir`, and `home_dir`
arguments as separate parameters.  If `etc_eden_dir` or `home_dir` were not
specified it would not pass these arguments to `edenfs`, allowing the default
values to be used.  This is undesirable for most tests.

Now it accepts a `base_dir` argument.  Explicit values for the `eden_dir`,
`etc_eden_dir`, and `home_dir` parameters can still be specified (this is used
for the snapshot tests), but if they aren't specified, default locations
inside the `base_dir` will be used instead.

This also cleans up some of the code to use `pathlib.Path` values instead of
plain `str` objects in more places.

Reviewed By: strager

Differential Revision: D15756358

fbshipit-source-id: 3e87ddc98d15fcb7f60c6c3116d4fcc8e49432ea
2019-06-11 18:27:21 -07:00
Adam Simpkins
7309869981 add a thrift call for getting config values
Summary:
Add a thrift call to get the current config settings.

My primary use case for this method at the moment is to make it possible to
build integration tests that check the config behavior.  However in the future
this will probably also be useful for building CLI commands to report the
current config values to allow debugging if there are ever issues.  This API
can also be used to force EdenFS to immediately reload the config from disk.

Reviewed By: strager

Differential Revision: D15572124

fbshipit-source-id: da3bc982f9c419b3314a8b0560c9bd327760d429
2019-06-11 13:08:28 -07:00
Matt Glazar
fa4e4cf78e Make 'edenfsctl start' fail if already running (systemd)
Summary:
With systemd integration enabled, if edenfs is running, or if edenfs' systemd service is active, `edenfsctl start` does nothing. This behavior differs from `edenfsctl start` with systemd integration disabled, and can cause `edenfsctl restart` to think that it successfully started edenfs.

Make `edenfsctl start` fail if edenfs is running and healthy, or if edenfs' systemd service is active (yet edenfs is unhealthy).

Reviewed By: chadaustin

Differential Revision: D15703310

fbshipit-source-id: ce0a13780ee03de1f896a938d002901023e5bdd3
2019-06-11 11:02:13 -07:00
Matt Glazar
c9b0e09c82 Use pystemd for 'eden start'; improve error messages
Summary:
systemctl has some problems for Eden. For example:

* With Restart=on-failure, 'systemctl start' reports that the job failed when the first failure occurs. 'systemctl start' does not wait for retries to finish. This means 'eden start' can fail despite edenfs starting successfully.
* If the service fails to start, 'systemctl start' prints a suggestion to use journalctl, even though journalctl is broken and is not even used by fb-edenfs@.service.
* If 'systemctl' can't connect to systemd, it prints a generic message such as "Failed to connect to bus: Connection refused" which the Eden CLI can't easily detect and customize.

For 'eden start', instead of using systemctl, talk to systemd using its D-Bus API (via pystemd [1]). This automatically solves the journalctl message problem, makes it trivial to customize certain errors, and will let us solve the Restart=on-failure problem in the future.

Aside from changing some error messages, this diff should not change behavior.

[1] https://github.com/facebookincubator/pystemd

Reviewed By: simpkins

Differential Revision: D13533184

fbshipit-source-id: 7fedc8ad4a094a2d04b14c2f6e82b51a0ed348a6
2019-06-10 14:05:55 -07:00
Kostia Balytskyi
5b4667e061 bring back the hg python entry point
Summary:
Back out "[hg] entrypoint: remove hg python script"

Original commit changeset: f3c8cfe4beb7

Reviewed By: mitrandir77

Differential Revision: D15739595

fbshipit-source-id: d13dd5a8cf7c645de622a2dd18960eba6561d131
2019-06-10 10:44:24 -07:00
Jake Crouch
0dc6812f33 Print out Journal Info with edenfsctl
Summary: Print out memory usage and entry counts with edenfsctl stats

Reviewed By: chadaustin

Differential Revision: D15607015

fbshipit-source-id: 866960ea1d3b5e9fdbe24df3b57fba419795ec76
2019-06-07 13:37:02 -07:00
Kostia Balytskyi
2e89766403 entrypoint: remove hg python script
Summary: We want to have just one entry point to Mercurial, namely the Rust binary. Getting rid of the `hg` Python script means that we finally can do things that only exist in Rust and not in Python.

Reviewed By: simpkins

Differential Revision: D13186374

fbshipit-source-id: f3c8cfe4beb7bf764172a8af04fd25202eca9af2
2019-06-06 14:26:21 -07:00
Matt Glazar
1ec3027f1e Fix flakiness in FUSE stats tests
Summary:
test_reading_committed_file_bumps_read_counter is flaky with optimized builds of edenfs. I think it's flaky because FuseChannel bumps counters *after* responding to the kernel, so the test can call get_counters before the counters are bumped.

Fix the flakiness by making the test wait a while for the counters to change.

Reviewed By: chadaustin

Differential Revision: D15550972

fbshipit-source-id: 891e5d0a9748b43eb0ef1089ef6bc0a547c47d4d
2019-05-30 18:13:24 -07:00
Matt Glazar
db710ae045 Fix flaky systemd test_no_units_are_active test
Summary:
In the past few months, test_no_units_are_active started failing. It looks like 'systemctl list-units' is now listing devices. For example:

```
$ systemctl list-units --all --full --no-pager
  UNIT                                                                                                 LOAD      ACTIVE     SUB       JOB   DESCRIPTION
● boot.automount                                                                                       not-found inactive   dead            boot.automount
  proc-sys-fs-binfmt_misc.automount                                                                    loaded    active     running         Arbitrary Executable File Formats File System Automount Point
  dev-disk-by\x2dlabel-\x5cx2f.device                                                                  loaded    active     plugged         /dev/disk/by-label/\x2f
[snip]
  dev-getty.device                                                                                     loaded    inactive   dead            /dev/getty
  dev-loop0.device                                                                                     loaded    active     plugged         /dev/loop0
  dev-ram0.device                                                                                      loaded    active     plugged         /dev/ram0
  dev-ram1.device                                                                                      loaded    active     plugged         /dev/ram1
[snip]
```

I don't know if systemctl changed or if systemd changed or if my machine's configuration changed. Either way, the test is failing now due to these systemd units.

Teach test_no_units_are_active to ignore these unimportant device units, since they don't represent running services or timers. This causes the test to pass on my machine.

Reviewed By: wez

Differential Revision: D15548072

fbshipit-source-id: 4f49c72d88b836aba37ec5ea7b5ee5b7cb8172f6
2019-05-30 18:07:37 -07:00
Matt Glazar
b4620e01ca Fix systemd tests on Sandcastle
Summary:
EdenFS' systemd tests detect if the running system is managed by systemd, and chooses different strategies for creating a sandboxed systemd user manager depending on this detection. Sandcastle (Facebook's continuous integration system) recently started running systemd as the container's init system.

EdenFS' systemd tests correctly detect that Sandcastle's container is managed by systemd. Unfortunately, the tests cannot communicate with systemd. For example, `XDG_RUNTIME_DIR=/run systemctl --user status` in a Sandcastle job reports the following error:

> Failed to connect to bus: No data available

This error happens because systemd and the EdenFS' tests are running in a different process namespace. The filesystem shows that the system is managed by systemd, but the process table shows otherwise! This causes all of EdenFS' systemd tests to fail.

Work around this issue making Sandcastle use the old "unmanaged" code path. (The unmanaged code path is run if the system is not managed by systemd. Before Sandcastle started running systemd in its container, Sandcastle used this code path when running EdenFS's tests.)

(Ideally we would figure out why we need both the "managed" code path in the first place. This diff is just meant to fix tests on Sandcastle for now, not implement a long-term solution.)

Possibly related upstream systemd issue: https://github.com/systemd/systemd/issues/11300

Reviewed By: wez

Differential Revision: D15530685

fbshipit-source-id: b65b568e660310c50a4e25e0aa143f9388f1ad45
2019-05-30 18:02:39 -07:00
Matt Glazar
1775680391 Test FUSE and HgBackingStore stat collection
Summary:
I am refactoring edenfs' EdenStats class. In doing so, I accidentally removed a call to `aggregate`, causing `flushStatsNow` to not expose accurate counters. This wasn't caught by any existing tests, only by manual testing.

Add some tests to prevent FUSE and HgBackingStore statistics collection from completely regressing.

Reviewed By: simpkins

Differential Revision: D15274275

fbshipit-source-id: c8a9c9848dd60aee7f252a93f10ddce6d7560799
2019-05-28 15:43:19 -07:00
Matt Glazar
9e6a39e951 Factor duplicate code into EdenTestCase.get_counters
Summary:
In another diff, Adam Simpkins noticed that HgImporterStatsTest.get_counters was clunky and that the logic belongs in the EdenTestCase base class.

Hoist HgImporterStatsTest.get_counters into EdenTestCase. Also avoid reusing the Thrift client between calls to get_counters because edenfs might restart between calls (in which case the old Thrift client won't work).

Reviewed By: wez

Differential Revision: D15514537

fbshipit-source-id: 0ae25106baa0e5b2d857b0bb2552d884b9b270ef
2019-05-28 15:43:18 -07:00
Matt Glazar
1cf18f6e56 Fix misplaced pyre-fixme directives
Summary: Some pyre-fixme directives are on the wrong line. Move them to the line to fix "Unused ignore" errors from Pyre.

Reviewed By: wez

Differential Revision: D15507418

fbshipit-source-id: b8d1163080b1c64868c37e7581411be31f495141
2019-05-28 15:37:38 -07:00
Matt Glazar
ef5a29b32a Delete dead code
Summary: This function isn't used anywhere. Delete it.

Reviewed By: pkaush

Differential Revision: D9695388

fbshipit-source-id: 1ac702c98ee63d09c15c8a7b8a9c8d44fcec630d
2019-05-27 22:35:29 -07:00
Matt Glazar
55e9a48cd9 Improve error message if systemd-run fails in tests
Summary:
In EdenFS' tests, when systemd-run fails, subprocess.check_output raises an exception and causes the test to fail. The exception's message does not include any output of systemd-run, so systemd-run's error messages are hidden. This makes it hard to debug systemd-run failures.

When systemd-run fails, print the captured output. This surfaces error messages printed by systemd-run, improving the debugging experience.

In the normal case where systemd-run succeeds, this diff should not change behavior.

Reviewed By: wez

Differential Revision: D15466610

fbshipit-source-id: 2b2db80b989308967e13499fcfadd37b44ca878f
2019-05-24 12:49:05 -07:00
Sinan Cepel
4547deafca Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: dkgi

Differential Revision: D15283973

fbshipit-source-id: b1451da50dbbee0f71260d50caece21799f008f2
2019-05-09 18:17:36 -07:00
Adam Simpkins
b0decd09f8 update the integration tests to stop using hg_import_helper.py
Summary:
Update the integration tests to avoid explicitly using the old
`hg_import_helper.py` script.

Reviewed By: pkaush

Differential Revision: D15223982

fbshipit-source-id: 6e2310d5a9e6e0b95690a07d61d295cc3b1bca92
2019-05-06 16:47:35 -07:00
Chad Austin
8ec4c11d3e remove flatmanifest fallback when importing trees fails
Summary: Flatmanifest is on its way out. Remove support for falling back to it if a tree import fails.

Reviewed By: pkaush

Differential Revision: D15056459

fbshipit-source-id: a4df820322ee354d77f50a0ec92e9705d0f152ec
2019-05-02 12:35:20 -07:00
Adam Simpkins
336d41616f refactor some of the argument parsing and config setup logic
Summary:
Move some of the argument parsing and config setup code out into a new
EdenInit.h header file.  This makes it possible to re-use this logic for other
standalone utilities that want to be able to find the Eden state directory and
config information.

For now I have updated the `fake_edenfs` helper tool used by the integration
tests to use this.  This may also be useful for writing standalone tools that
can perform garbage collection of the LocalStore or checking of the overlay
state.

Reviewed By: chadaustin

Differential Revision: D14889616

fbshipit-source-id: b0b193a42cb2f52177d0c44592426b42e27242aa
2019-04-16 21:17:10 -07:00
Adam Simpkins
308213108c fix a failure in test_eden_start_reports_error_if_systemd_is_not_running
Summary:
On my system this test was failing because the `systemctl start exit.target`
command was exiting with an error.  It looks like this command exits because
systemd closes its D-Bus connection as it is shutting down.  This modifies the
test to ignore the return code from this systemctl command.

I also updated the log message when shutting down systemd to no longer include
the exception backtrace.  This message is always logged when running this test
(since systemd is not actually running), and the backtrace information simply
makes the test logs harder to read.

Reviewed By: wez

Differential Revision: D14886191

fbshipit-source-id: 87c996b2579a9920a72ee5b57608c263ca080d6e
2019-04-15 11:04:46 -07:00
Joshua Kehn
08b96e33b3 ununderscore eden
Summary: Manually ran `black` with P62353677 applied to ununderscore numbers. Re-ran `arc f` to preserve other lint changes.

Reviewed By: zsol

Differential Revision: D14880800

fbshipit-source-id: d03437208ac10c67701c1dc1d5b38be7bb40acc9
2019-04-12 03:02:10 -07:00
Matt Glazar
37a993bf42 Track how many HgImporter requests are made
Summary:
Sometimes, EdenFS goes bonkers and talks to 'hg debugedenimporthelper' a lot for seemingly no reason.

Make these situations easier to debug by counting how many requests EdenFS makes to 'hg debugedenimporthelper'. These counters let us answer questions such as the following:

* When performance sucks, is EdenFS is making a lot of requests or only a few requests? I.e. is Hg slow at responding or is EdenFS very demanding?
* Does a recent performance issue correlate with EdenFS communicating with 'hg debugedenimporthelper'?
* Which engineers are outliers having orders of magnitude more 'hg debugedenimporthelper' requests than p50 engineers?

We could get fancier with these counters and include the number of bytes received, the duration of the request, etc. For now, just having a request count is useful.

Reviewed By: simpkins

Differential Revision: D14677339

fbshipit-source-id: 7f8f394fb0096aef65d6a8a45d7da5936db539a0
2019-04-10 19:58:16 -07:00
Chad Austin
a9d9689d3d invalidate directory inodes properly on checkout
Summary:
After the kernel added readdir caching, my testing uncovered that Eden
was invalidating TreeInode entries incorrectly when new entries were
added. Change TreeInode to distinguish between directory entry changes
and removals (FUSE_NOTIFY_INVAL_ENTRY) and additions
(FUSE_NOTIFY_INVAL_INODE).

Reviewed By: strager

Differential Revision: D13870422

fbshipit-source-id: 2a6f25bfd9e77436a5aae639fedbfd8a445b2e05
2019-03-22 15:57:33 -07:00
generatedunixname89002005289445
1f369ed67b Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: shannonzhu

Differential Revision: D14525100

fbshipit-source-id: ca27023b89da9eb8f983caaceb78e9fb4fea7bfe
2019-03-19 13:15:29 -07:00
Adam Simpkins
981952749d attempt to repair the RocksDB if we fail to open it
Summary:
Update `RocksHandles` to call `RepairDB()` if we get an error opening the
database.

We have seen errors opening the DB in some cases after hard server reboots.
In every case so far `ldb repair` has been able to repair it with no adverse
effects.  This simply makes `edenfs` automatically attempt to perform this DB
repair step.

Reviewed By: chadaustin, strager

Differential Revision: D14452216

fbshipit-source-id: 10c0cb0ff9cea3c3bbe485a4e489e4a6df640803
2019-03-18 11:36:42 -07:00
Matt Glazar
d65aa6ad8b Infer XDG_RUNTIME_DIR if unset
Summary:
Sometimes, the XDG_RUNTIME_DIR environment variable isn't set. If this happens, 'eden start' fails because systemctl uses XDG_RUNTIME_DIR to talk to systemd. We still want 'eden start' to work in these cases, so guess what XDG_RUNTIME_DIR should be and use that guess if the variable isn't set.

If XDG_RUNTIME_DIR is set in the environment, its value should still be used.

Reviewed By: chadaustin

Differential Revision: D13811813

fbshipit-source-id: bb44d99e585bbe7a4341087c5cb4644c606fc441
2019-03-14 18:19:41 -07:00
Matt Glazar
9cbf2baf9b Fix systemd tests on CI servers
Summary:
Sometimes, Facebook's CI servers might not have a /run/systemd directory. This causes EdenFS' systemd tests to fail, because daemon-respawn can't access that directory [1].

Fix the tests on CI by creating /run/systemd.

Why did the tests only start failing recently? I'm not sure. I think we were just lucky in the past; tests in other projects seem to create /run/systemd (e.g. using the systemd-nspawn command), and it looks like this state persists across CI jobs.

[1] https://github.com/systemd/systemd/blob/v239/src/core/dbus-manager.c#L1277

Reviewed By: simpkins

Differential Revision: D14436098

fbshipit-source-id: eb48abeb1ce38ea4ae760192db37bb1910efff99
2019-03-14 13:48:20 -07:00
Matt Glazar
5e3e446aa6 Fix error message in tests
Summary:
If sanity_check_enabled_unit_fragment fails, the error message is unhelpful:

```
Exception: Enabled unit's FragmentPath does not match unit file
Expected: {repr(expected_unit_file)}
Actual:   {repr(actual_unit_file)}
```

Use format strings as was originally intended, and drop repr to make the paths easier to read:

```
Exception: Enabled unit's FragmentPath does not match unit file
Expected: /data/users/strager/fbsource/fbcode/eden/fs/service/fb-edenfs@.service
Actual:   /usr/lib/systemd/user/fb-edenfs@.service
```

Reviewed By: simpkins

Differential Revision: D13372758

fbshipit-source-id: 0f12cc7a6f63fc53d72ce92b265e0ccbcc26d394
2019-03-14 13:41:17 -07:00
Kostia Balytskyi
9cdaa234b6 chg: remove the ability to produce an actual binary
Summary: We don't run this binary anymore, no reason to build and ship it.

Reviewed By: quark-zju

Differential Revision: D14437317

fbshipit-source-id: dd6da521783f18a2a518a7aa042be98950894e89
2019-03-14 06:35:40 -07:00
Matt Glazar
3b9a0310a1 Fix deadlock when restarting during RocksDbLocalStore::get()
Summary:
If TreeInode::startLoadingInode() is in progress, and EdenServer::startTakeoverShutdown() is called, edenfs can deadlock:

1. Thread A: A FUSE request calls TreeInode::readdir() -> TreeInode::prefetch() -> TreeInode::startLoadingInode() on the children TreeInode-s -> RocksDbLocalStore::getFuture().
2. Thread B: A takeover request calls EdenServer::performTakeoverShutdown() -> InodeMap::shutdown().
3. Thread C: RocksDbLocalStore::getFuture() (called in step 1) completes -> TreeInode::inodeLoadComplete(). (The inodeLoadComplete continuation was registered by TreeInode::registerInodeLoadComplete().)
4. Thread C: After TreeInode::inodeLoadComplete() returns, the TreeInode's InodePtr is destructed, dropping the reference count to 0.
5. Thread C: InodeMap::onInodeUnreferenced() -> InodeMap::shutdownComplete() -> EdenMount::shutdown() (called in step 2) completes -> EdenServer::performTakeoverShutdown().
6. Thread C: EdenServer::performTakeoverShutdown() -> localStore_.reset() -> RocksDbLocalStore::~RocksDbLocalStore().
7. Thread C: RocksDbLocalStore::~RocksDbLocalStore() signals the thread pool to exit and waits for the pool's threads to exit. Because thread C is one of the threads managed by RocksDbLocalStore's thread pool, the signal is never handled and RocksDbLocalStore::~RocksDbLocalStore() never finishes.

Fix this deadlock by executing EdenServer::shutdown()'s callback (in EdenServer::performTakeoverShutdown()) on a different thread.

Reviewed By: simpkins

Differential Revision: D14337058

fbshipit-source-id: 1d63b4e7d8f5103a2dde31e329150bf763be3db7
2019-03-12 19:29:35 -07:00
generatedunixname89002005289445
519fbabc9b Update pyre version for eden
Summary: Automatic upgrade to remove `version` override and silence errors.

Reviewed By: shannonzhu

Differential Revision: D14426843

fbshipit-source-id: bda3fa62d5af6d4c6c5120e793e0da79c4a145f0
2019-03-12 13:56:33 -07:00