Commit Graph

84 Commits

Author SHA1 Message Date
Michael Bolin
b79ba4876c Add a --stdout option to eden rage.
Summary:
Using this option prints the rage report to stdout rather than to the default
reporter. Sometimes it's easier to get the report on stdout so you can pipe it
to other commands.

Reviewed By: simpkins

Differential Revision: D6195684

fbshipit-source-id: 59e1ae6b19b951eac67377cdd5f8c0560e0d181a
2017-10-31 17:06:08 -07:00
Michael Bolin
e07ef44b1c Print a sensible error message when the user tries to mount an existing mount.
Summary:
This was an error that an end-user ran into. Previously, we did not fail
gracefully and the user was faced with an intimidating stacktrace.

Reviewed By: simpkins

Differential Revision: D6195529

fbshipit-source-id: bde3c2a3e6f49457a4c6ac5c87103cf52cd227c2
2017-10-31 17:06:08 -07:00
Michael Bolin
1d7bdf0d0b Ensure all the fields of StdoutPrinter are str.
Reviewed By: simpkins

Differential Revision: D6180343

fbshipit-source-id: 8036300174991a5225de5f8c28deec4ff638b894
2017-10-30 21:38:14 -07:00
Michael Bolin
9ead3fe4f3 Print an appropriate error message if an invalid repo is passed to eden clone.
Summary:
Previous to this change, the user got an inscrutable error message. It turns out
that it is easy to make this mistake, typing `eden clone fbsource/` instead of
`eden clone fbsource` if you accidentally use tab completion.

Reviewed By: simpkins

Differential Revision: D6153889

fbshipit-source-id: 3642fdd207d6abf896d6a12891d5eb68ad984acc
2017-10-25 22:36:06 -07:00
Michael Bolin
a286ad53e5 Introduce eden debug hg_dirstate command.
Summary:
Add an `eden debug hg_dirstate` command to dump the contents of the Hg dirstate.
This data is stored in a binary format, so we need a custom command to view it
easily.

Reviewed By: simpkins

Differential Revision: D6139172

fbshipit-source-id: 622c0b7bcaa471a88483c6c4ddef7e0be95a3dfa
2017-10-25 22:36:06 -07:00
Chad Austin
3240f2dff9 warn when creating new logger, allow disabling inheritance for log level
Summary: This diff helps some common pitfalls when using set_log_level.

Reviewed By: simpkins

Differential Revision: D6142849

fbshipit-source-id: 7fa35392dda148af90d0aefdb872b6e8a8b770db
2017-10-25 09:56:16 -07:00
Chad Austin
b921f9ec98 add units and improve table rendering of hg stats {latency,io}
Reviewed By: wez

Differential Revision: D6101986

fbshipit-source-id: c556042f57ca5ba8c319f1a18d930406e8b35d56
2017-10-20 14:10:01 -07:00
Michael Bolin
2c46c59ad6 Write the PID to the lockfile and update eden health to use it.
Summary:
We have encountered cases where `eden health` reported
`"edenfs not healthy: edenfs not running"` even though the `edenfs` process is
still running. Because the existing implementation of `eden health` bases its
health check on the output of a `getStatus()` Thrift call, it will erroneously
report `"edenfs not running"` even if Eden is running but its Thrift server is
not running. This type of false negative could occur if `edenfs` has shutdown
the Thrift server, but not the rest of the process (quite possibly, its
shutdown is blocked on calls to `umount2()`).

This is further problematic because `eden daemon` checks `eden health`
before attempting to start the daemon. If it gets a false negative, then
`eden daemon` will forge ahead, trying to launch a new instance of the daemon,
but it will fail with a nasty error like the following:

```
I1017 11:59:25.188414 3064499 main.cpp:81] Starting edenfs.  UID=5256, GID=100, PID=3064499
terminate called after throwing an instance of 'std::runtime_error'
  what():  another instance of Eden appears to be running for /home/mbolin/local/.eden
*** Aborted at 1508266765 (Unix time, try 'date -d 1508266765') ***
*** Signal 6 (SIGABRT) (0x1488002ec2b3) received by PID 3064499 (pthread TID 0x7fd0d3787d40) (linux TID 3064499) (maybe from PID 30644
99, UID 5256), stack trace: ***
    @ 000000000290d3cd folly::symbolizer::(anonymous namespace)::signalHandler(int, siginfo_t*, void*)
    @ 00007fd0d133cacf (unknown)
    @ 00007fd0d093e7c8 __GI_raise
    @ 00007fd0d0940590 __GI_abort
    @ 00007fd0d1dfeecc __gnu_cxx::__verbose_terminate_handler()
    @ 00007fd0d1dfcdc5 __cxxabiv1::__terminate(void (*)())
    @ 00007fd0d1dfce10 std::terminate()
    @ 00007fd0d1dfd090 __cxa_throw
    @ 00000000015fe8ca facebook::eden::EdenServer::acquireEdenLock()
    @ 000000000160f27b facebook::eden::EdenServer::prepare()
    @ 00000000016107d5 facebook::eden::EdenServer::run()
    @ 000000000042c4ee main
    @ 00007fd0d0929857 __libc_start_main
    @ 0000000000548ad8 _start
Aborted
```

By providing more accurate information to `eden daemon`, if the user tries to
run it while the daemon is already running, they will get a more polite error
like the following:

```
error: edenfs is already running (pid 274205)
```

This revision addresses this issue by writing the PID of `edenfs` in the
lockfile. It updated the implementation of `eden health` to use the PID in the
lockfile to assess the health of Eden if the call to `getStatus()` fails. It
does this by running:

```
ps -p PID -o comm=
```

and applying some heuristics on the output to assess whether the command
associated with that process is the `edenfs` command. If it is, then
`eden health` reports the status as `STOPPED` whereas previously it would report
it as `DEAD`.

Reviewed By: wez

Differential Revision: D6086473

fbshipit-source-id: 825421a6818b56ddd7deea257a92c070c2232bdd
2017-10-18 11:29:43 -07:00
Michael Bolin
5aaf96ce40 eden shutdown now sends SIGKILL if the shutdown() Thrift request fails to terminate Eden.
Summary:
In practice, we have seen cases where `eden shutdown` does not succeed within
15 seconds (the default timeout), and then we see the following message printed
to the console:

    error: sent shutdown request, but edenfs did not exit within 15.0 seconds

Sometimes we end up in a state where the Thrift server has successfully shutdown
but the `edenfs` process is still running. Because `eden health` is implemented
using a Thrift call, it reports that `edenfs` is not running even though it
still is. This is confusing because a subsequent `eden daemon` request will
likely fail with something like:

```
terminate called after throwing an instance of 'std::runtime_error'
  what():  another instance of Eden appears to be running for /home/mbolin/local/.eden
```

To address this, we make `eden shutdown` more aggressive in killing `edenfs`
by sending `SIGKILL`.

Follow-up work:
- Make Eden's shutdown process more robust so that `SIGKILL` is rarely, if ever,
  necessary.
- Store the PID of the `edenfs` process in the lock file so that Eden does not
  rely upon the Thrift server to be running in order to check whether the
  `edenfs` process is running.

Reviewed By: wez

Differential Revision: D6080929

fbshipit-source-id: 462a6ec506cdb6a51211d2c64b777eadbcee9fc1
2017-10-18 11:29:43 -07:00
Chad Austin
73dc6620fc add a debug CLI command to set a log category's level
Reviewed By: simpkins

Differential Revision: D6068539

fbshipit-source-id: 45d0baecc2291c83c48ad22403d44a790b270b9a
2017-10-16 16:37:10 -07:00
Michael Bolin
ee2c0f2cff Make the destination of eden rage output configurable in ~/.edenrc.
Summary:
This adds support for specifying where the output of `eden rage` should be sent
by adding a `reporter` property to the `[rage]` section of `~/.edenrc` like so:

```
[rage]
reporter = arc paste
```

If specified, Eden will take the command as an opaque string and use it as an
argument to `sh -c <reporter_from_edenrc>` when spawning a subprocess that will
receive the output of `eden rage` on its stdin. If no reporter is specified,
then the stream will be written directly to stdout.

Reviewed By: wez

Differential Revision: D6049355

fbshipit-source-id: beafe37eed8c48dac7499a6978cacfb44d8f253e
2017-10-16 11:56:23 -07:00
Michael Bolin
4cfe1c373e Use --home-dir to compute the config dir, if specified.
Summary:
Previously, `$HOME` was used as the location of the home dir when determining
the config dir even if `--home-dir` was specified. Now `--home-dir` affects
both.

Reviewed By: simpkins

Differential Revision: D5997870

fbshipit-source-id: 11e9d4fccc558da0c90fb2e38071ebc2d33491bf
2017-10-06 12:28:41 -07:00
Adam Simpkins
cf92fa6f6d add a CLI option to run edenfs under strace
Summary:
Add an `--strace <FILE>` flag to the `eden daemon` CLI command to run eden
under strace, saving the strace output to the specified path.

Reviewed By: wez

Differential Revision: D5771462

fbshipit-source-id: fe4bf18f372f3276400bee624e906ed4f3569735
2017-09-07 19:08:31 -07:00
Wez Furlong
6cad3592b9 fixup SNAPSHOT file format in the eden cli
Summary:
Make the CLI read and write a SNAPSHOT file that is
consistent with the C++ server implementation.

Ideally we'd only ever write this file from the C++ side.

Reviewed By: simpkins

Differential Revision: D5740079

fbshipit-source-id: 2057df0ee2b0b271a4734d58e1b6d1334a28020b
2017-08-30 15:12:28 -07:00
Jyothsna Konisa
8fb37c1ada Diagnostic tool to report Stat information of EdenFs
Summary:
Added new tool to report stat information of EdenFs like fuse counters, Memory counters, latencies, Inode status for all the mount points etc.

eden stat : Prints the general information about eden like list of mount points, loaded unloaded and materialized inodes in each mount point. Also this reports how well periodic unload job is doing by reporting the number of unloaded inodes by periodic job.

eden stat io : Prints how many number of calls made to a system call in Edenfs.

eden stat memory : returns the memory stat for edenfs.

eden stat latency : reports the latencies of system calls in Edenfs.

Reviewed By: bolinfest

Differential Revision: D5660345

fbshipit-source-id: 97a1c2b83a6d8df0cd1b82c4d54b52d7ebd126bd
2017-08-25 12:49:35 -07:00
Braden Watling
ab43c66a8d Add test to verify that eden debug getpath indicates when inodes are unloaded
Summary:
This test was supposed to be a part of D5627411 but it was causing strange behaviour so was brought to a separate diff for further investigation.

After investigating, the test didn't pass because the UnloadedInodeData struct only contained the name of the file, not the path to it. The fix for this was to implement a way to get the relative path of the file even after the inode is unloaded.

Reviewed By: simpkins

Differential Revision: D5646929

fbshipit-source-id: f166398a651e8aea49da7e4474a5ad7fde2eaa4e
2017-08-25 08:34:31 -07:00
Michael Bolin
8ff2ba5d5b Use pwd as the default argument for eden debug overlay.
Summary:
Also modified the `getpath` handler to defer the `os.getcwd()` call.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D5698232

fbshipit-source-id: 9483907771fd1fd2918f62120664bb0d8c431cf3
2017-08-24 14:23:39 -07:00
Michael Bolin
0508c0b819 Change eden debug getpath to use pwd as the default mount point.
Summary: This seems a little more user-friendly.

Reviewed By: bradenwatling

Differential Revision: D5686562

fbshipit-source-id: 8142fb9105a3a44823f935fc04187cf0ed2258d7
2017-08-23 11:27:22 -07:00
Michael Bolin
303655c4b1 Add integration test for hg copy.
Summary:
Note that this feature was mostly implemented before this commit, but never
tested. Unsurprisingly, there were bugs.

This change also introduces a new `eden debug hg_copy_map_get_all` subcommand
because that was a straightforward way to verify the internal state of the copy
map on the server side from an integration test.

Adding this test uncovered a key copy/paste bug in `EdenThriftClient.py`
(`hgCopyMapGet` was being invoked instead of `hgCopyMapPut`.)

It also uncovered a bug in `LameThriftClient` because the `compile()` and
`eval()` calls on the output are not appropriate when the return type of the
Thrift endpoint is `string`.

Reviewed By: simpkins

Differential Revision: D5686114

fbshipit-source-id: f0093d2b67062c01982dc5bc1f0db2774b3a9356
2017-08-22 21:06:07 -07:00
Jyothsna Konisa
371cfa097d TestCase to verify unloadChildrenNow with age
Summary:
Added a test case `test_unload_free_inodes_age` to verify the behaviour of unloadChildrenNow with age parameter.
Added new parameter age to `unloadInodeForPath` in eden.thrift, and `EdenServiceHandler`.
Modified `do_unload_inodes` function in `debug.py` to support the new behaviour.

Reviewed By: simpkins

Differential Revision: D5565859

fbshipit-source-id: a35053725be26bc906cf158969cbe21db1cbadde
2017-08-22 19:50:00 -07:00
Simon Jensen
3a0e66677b Cache invalidation thrift api
Summary: Provide a thrift interface to invalidate the cache for an inode denoted by path.

Reviewed By: simpkins

Differential Revision: D5655387

fbshipit-source-id: 887aa4963d216a0d8eed93b6fb8721632cc31d19
2017-08-21 16:05:44 -07:00
Michael Bolin
70050affcc Introduce eden debug hg_get_dirstate_tuple.
Summary:
This is a convenient way to test the `hgGetDirstateTuple()` endpoint in
`eden.thrift`.

Reviewed By: quark-zju, wez

Differential Revision: D5654237

fbshipit-source-id: 0b285e056002d4556733a53293582345f36780b2
2017-08-18 21:49:59 -07:00
Braden Watling
cf297e0106 Add subcommand getpath to eden debug
Summary: Add a command to lookup the path for an inode given the inode number and eden mount path.

Reviewed By: bolinfest

Differential Revision: D5627411

fbshipit-source-id: 25928f506d3f48d8a6784fe81fb17fa0500d6bc9
2017-08-16 20:04:30 -07:00
Wez Furlong
39b21f383b compensate for the new header when debugging the overlay
Summary:
I'm trying to troubleshoot why a new dir that I added isn't showing up in the overlay and I found that the debug tool doesn't know about the overlay.

This is the dumbest minimal thing I could do to make this basically functional again

Reviewed By: simpkins

Differential Revision: D5602439

fbshipit-source-id: 4ae7fa34136697f9f915ccd95275cb3a7923ae4a
2017-08-10 11:42:25 -07:00
Adam Simpkins
8be3b57eed fix issues updating TreeInode materialization status during checkout
Summary:
This updates the TreeInode code to remove the redundant materialized flag.
A TreeInode should have a Tree Hash if and only if it is dematerialized, so
there is no need for an extra `materialized` boolean.

This diff also fixes an issue in TreeInode::saveOverlayPostCheckout() where it
was not correctly informing it's parent TreeInode of the change if it moved
from one dematerialized state to another (with a different TreeInode hash).
This fixes the code to correctly call `parent->childDematerialized()` when it
needs to inform the parent that it now refers to a different source control
hash.

Reviewed By: wez

Differential Revision: D5336629

fbshipit-source-id: b4d86ecdef2f5faefbc243a09d869c02384ae95c
2017-07-07 18:45:02 -07:00
Adam Simpkins
305325319c add an "eden debug overlay" command
Summary:
Add a command to deserialize and display information about files in the
overlay.  This can be used to help debug the current state of files in the
overlay.

Reviewed By: wez

Differential Revision: D5332014

fbshipit-source-id: 25b01579df33aa9f1926c0144e9f03aa8ece38fc
2017-07-07 18:45:01 -07:00
Jyothsna Konisa
299f7d1373 Integration Test for UnnloadFreeInodes
Summary:
1. Moved read, write, mkdir, rm methods in hg/lib/hg_extension_test_base.py to lib/test_case.py.
2. Added integration test case to test unload free inodes.

Reviewed By: simpkins

Differential Revision: D5277870

fbshipit-source-id: b93b6049a10357cf8c92366e6dca3968f7f30c30
2017-06-22 22:38:47 -07:00
Jyothsna Konisa
b8be1633bc Cli command to unload free inodes of a under a given directory.
Summary:
1.Added a new thrift method to unload free inodes of a directory and its sub directories.
2.Added a new debug sub command 'eden debug unload <path>' to cli tools to unload free inodes.

Reviewed By: simpkins

Differential Revision: D5261038

fbshipit-source-id: 85b4c5ae18c0ae24c666a44ac9892765e753397f
2017-06-16 16:22:32 -07:00
Jyothsna Konisa
62cd0f90e1 Basic eden rage command
Summary:
1.Added new rage command to command line tools.
2.Eden rage command currently shows Logs,package version,rpm version,build revision,build upstream revision,list of running eden processes and their info,list of mount points and their info.

Reviewed By: simpkins

Differential Revision: D5220250

fbshipit-source-id: 357f46d8d08d4a1f197b705dfd1a28668dd180f0
2017-06-15 11:12:15 -07:00
Jyothsna Konisa
8da0797e92 Fix in eden debug for relative path in get_path_info()
Summary: made the relative path return "" when mount point directory is returned "."

Reviewed By: simpkins

Differential Revision: D5250543

fbshipit-source-id: bd0d648db8030cfc6ca952fccfb9972f18290b5e
2017-06-15 11:12:11 -07:00
Andrew Gallagher
03bdaff954 codemod: format TARGETS with buildifier [4/5] (D5092623)
Reviewed By: igorsugak

fbshipit-source-id: 277a9d2bdc1d7e3ff3075bfe2d7307502fd0a507
2017-06-01 17:52:40 -07:00
Michael Bolin
edbb0ce210 Build //eden/fs/service:thrift-EdenService-pyremote as part of :all target.
Summary:
When we say we are building "all" of Eden, we generally want to ensure we have
built the pyremote service that the Hg extension needs, as well.

Reviewed By: wez

Differential Revision: D4982118

fbshipit-source-id: 7282266e82e662a48b5ced6da6b7daedab8b65ea
2017-05-02 10:50:09 -07:00
Wez Furlong
4923ba4d07 fixup finding the edenfs binary
Summary: We overlooked this in the recent move around of the cli code

Reviewed By: bolinfest

Differential Revision: D4894230

fbshipit-source-id: 5c3ae274a182e5cc41df47100959f8cfbcb59c2d
2017-04-14 16:48:29 -07:00
Adam Simpkins
ce0ce6fa4e move eden/fs/cli to eden/cli
Summary:
Move the code for the command-line tool up one directory, out of eden/fs.
This better separates the code so that eden/fs contains code for the edenfs
daemon, while eden/cli contains code for the command line tool.

Reviewed By: bolinfest

Differential Revision: D4888633

fbshipit-source-id: 5041e292c5353d05122eefe5db3257289e31239a
2017-04-14 11:39:01 -07:00