Commit Graph

394 Commits

Author SHA1 Message Date
Zeyi (Rice) Fan
5fedaa71b8 enable redirection tests
Summary: This diff fixes the eden redirection tests so it runs on Windows.

Reviewed By: xavierd

Differential Revision: D22958766

fbshipit-source-id: 45d26587831ed74d6bd7912b22c7c955b077f571
2020-09-18 16:39:52 -07:00
Zeyi (Rice) Fan
506ba2cbf3 remove resolve_path
Reviewed By: xavierd

Differential Revision: D23766446

fbshipit-source-id: 3f8238de7c8e93ce8d76f201de9eff0984365979
2020-09-18 16:39:52 -07:00
Zeyi (Rice) Fan
923bac59b2 allow disabling kerberos check via configuration
Reviewed By: wez

Differential Revision: D23717373

fbshipit-source-id: a65106852d995974b557f058bec9ef4774ee01ea
2020-09-17 18:04:48 -07:00
Chad Austin
fdc83eaa75 rename EdenInstance.get_thrift_client to get_thrift_client_legacy
Summary:
Rather than switch all of Eden at once to the thrift-py3 client,
rename get_thrift_client to get_thrift_client_legacy so uses of the
new client can be introduced piecemeal.

(I did try migrating everything at once but it's been quite painful.)

Reviewed By: fanzeyi

Differential Revision: D22423399

fbshipit-source-id: 9e6d938b90fff9fc3266ba20bc77e880e7f5b1aa
2020-09-17 13:25:00 -07:00
Chad Austin
e8e9d906fa remove fallback for old open source builds
Summary:
There was a time when getRegexExportedValues was not in open source
fb303, but that time has long passed.

Reviewed By: kmancini

Differential Revision: D23745295

fbshipit-source-id: 4702068f0bb7350467e42439444b3f4d75aeec76
2020-09-16 17:48:32 -07:00
Zeyi (Rice) Fan
7f6479f790 fix eden redirect fixup properly now
Summary:
ghostbooleans

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

Reviewed By: xavierd

Differential Revision: D23698179

fbshipit-source-id: 95a28cc13bff5e325214b6a398e19c821b5ae17f
2020-09-15 10:28:38 -07:00
generatedunixname89002005307016
827498fc82 suppress errors in eden - batch 1
Differential Revision: D23685952

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

Reviewed By: kmancini

Differential Revision: D23683153

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

Reviewed By: genevievehelsel

Differential Revision: D23520008

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

Reviewed By: genevievehelsel

Differential Revision: D23653027

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

Reviewed By: wez

Differential Revision: D23633574

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

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

Reviewed By: xavierd

Differential Revision: D23605233

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

Reviewed By: wez

Differential Revision: D23582015

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

Reviewed By: chadaustin

Differential Revision: D23550567

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

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

Reviewed By: fanzeyi

Differential Revision: D23443268

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

Reviewed By: fanzeyi

Differential Revision: D23442884

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

Reviewed By: wez

Differential Revision: D23442710

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

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

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

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

Reviewed By: genevievehelsel

Differential Revision: D23502306

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

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

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

Reviewed By: genevievehelsel

Differential Revision: D23502307

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

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

Reviewed By: xavierd

Differential Revision: D23484626

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

Reviewed By: fanzeyi

Differential Revision: D23183163

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

Reviewed By: wez

Differential Revision: D23438306

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

Reviewed By: fanzeyi

Differential Revision: D23438318

fbshipit-source-id: b3d9ac3981d3fb2bb8045b07b8d949cd601f6898
2020-09-02 20:19:48 -07:00
Xavier Deguillard
32609a44ac cli: increase start timeout to 60s
Summary:
I've seen cases where `edenfsctl start` would timeout after 10s, but EdenFS
ends up starting up shortly after, let's increase the timeout a bit.

Reviewed By: singhsrb

Differential Revision: D23475926

fbshipit-source-id: 3ef495aae7a03b064cb7cdf72241a7f60a8c4b77
2020-09-02 10:47:26 -07:00
Genevieve Helsel
89791f6b89 mock kerberos checks in doctor tests
Summary: These tests fail locally since adding these checks in eden doctor, so we need to mock them.

Reviewed By: chadaustin

Differential Revision: D23326597

fbshipit-source-id: 87a0e6ab0472e3ae56f89503e928c5a00a16ab04
2020-08-31 07:51:17 -07:00
Xavier Deguillard
4f9e1750c2 cli: enable doctor on Windows
Summary:
Most of the fixes are pretty trivial as the code was using functions not
present on Windows, either work around them, or switch to ones that are
multi-platform.

Of note, it looks like `hg doctor` doesn't properly detect when Mercurial and
EdenFS are out of sync, disabling the  tests until we figure out why.

Reviewed By: genevievehelsel, fanzeyi

Differential Revision: D23409708

fbshipit-source-id: 3314c197d43364dda13891a6874caab4c29e76ca
2020-08-28 19:49:37 -07:00
Genevieve Helsel
92eba77a06 remove duplicated code in proc_utils
Summary: I refactored this method to be a member fuction of `EdenFSProcess` and I thought this instance of the method was deleted, but I came across it while working in this area again.

Reviewed By: fanzeyi

Differential Revision: D23113075

fbshipit-source-id: 2c257cca2da3a4bfefb974753eb00c7580c5a104
2020-08-27 09:53:10 -07:00
Zeyi (Rice) Fan
17d2c95a18 enable mkscratch on Windows
Summary: With D22956659, we can now use mkscratch on Windows with EdenFS.

Reviewed By: xavierd

Differential Revision: D22956983

fbshipit-source-id: 995073cbc89d5cb23dbb9c1a58926f8c51f0a896
2020-08-24 21:38:12 -07:00
Genevieve Helsel
fdccaae59b add unique return code for unhealthy instance before restart
Reviewed By: xavierd

Differential Revision: D23024654

fbshipit-source-id: c306752219bfe594dc9486d6770f8b7118deb8d5
2020-08-13 09:44:11 -07:00
Xavier Deguillard
5ef7260cc4 cli: remove the repo on edenfsctl remove
Summary:
On Windows, unmounting the repo isn't sufficient to remove all traces of the
repo as ProjectedFS uses it as a cache, and thus all the files that were
touched by the user are still present on disk after unmounting it.

Reviewed By: wez

Differential Revision: D22915349

fbshipit-source-id: 445379fef57160b5da39a298ca4518e2662d16e3
2020-08-13 08:28:45 -07:00
Xavier Deguillard
077ba2fd96 cli: properly detect running buck on Windows
Summary:
Using os.kill on EdenFS would always fail and raise an exception. Use the
proc_utils code to detect if the process is running. Also using BUCKVERSION
always raises an error on Windows, so let's ignore that for now.

Reviewed By: fanzeyi

Differential Revision: D22915350

fbshipit-source-id: 806bfab12ae0e8fc97e83d5720481f2a47516129
2020-08-11 19:01:13 -07:00
Ailin Zhang
4f43f8bb8d make a separate command for prefetch_profile
Summary:
Previously `eden prefetch` had two subcommands `record-profile` and `finish-profile`, but then when we only want to use `eden prefetch PATTERN`, an error shows up saying that the COMMAND argument is missed.

Since `eden prefetch` has many of its own arguments, and we don't want to use it with `record-profile` and `finish-profile` all the time, we remove those subcommands and create a new `eden debug prefetch_profile` command to get prefetch profiles.

Reviewed By: fanzeyi

Differential Revision: D22959981

fbshipit-source-id: 21b278555fcb56580a62f66a7384b1cff54ba398
2020-08-06 13:17:07 -07:00
Xavier Deguillard
ae62478818 cli: wait for EdenFS to be healthy on start
Summary:
On Windows, we were just spawning EdenFS without waiting for it to become
either healthy, or unhealthy. While in most cases EdenFS becomes healthy
shortly after, scripts could race with it and behave weirdly as a consequence.
For instance, `eden clone` would start EdenFS if it isn't started already, and
then immediately clone the repo, that second step may fail and just leave an
empty folder on disk.

On unices, due to EdenFS daemonizing itself, edenfsctl waits for the parent
process to exit which signify that EdenFS is either started, or dead. On
Windows, we can wait on the pid that CreateProcess returns. One drawback is
that the user won't see what `edenfsctl start` is doing while on unices we have
progress bars regarding the repositories being mounted. One approach to
alleviate this would be to use a pipe as the StartupLogger and close it once
EdenFS is initialized.

Reviewed By: fanzeyi

Differential Revision: D22964058

fbshipit-source-id: 4e83c265d22e7e5150ed8b40e2b554cfcd181f8e
2020-08-06 12:31:57 -07:00
Zeyi (Rice) Fan
8a61bc52d3 treat bind mount redirection as symlink
Summary:
For EdenFS Redirection on Windows, we can simply use symlinks in place of bind mounts on other platforms. This works fine from what I can tell.

NOTE: at this commit EdenFS on Windows is still not able to create these redirections at start up time since that code is located in `EdenMount` and it uses `folly::subprocess`: https://www.internalfb.com/intern/diffusion/FBS/browse/master/fbcode/eden/fs/inodes/EdenMount.cpp. For the same reason we can't enable the EdenFS redirection integration tests.

Reviewed By: xavierd

Differential Revision: D22544200

fbshipit-source-id: b1a33da128c932544660c3e895583574d7891be9
2020-08-05 14:27:05 -07:00
Zeyi (Rice) Fan
a4d520acc6 replace os.path with pathlib in redirect
Summary:
The mix use of `os.path` and `pathlib` in `redirect.py` is a little messy, which is making adding Windows support trickier since `os.path` functions do not accept `Path` until 3.8. So before I make the change I think it's better to clean it up.

Since we are target Python 3 nowadays, replacing `os.path` with `pathlib` seems to be better. Basically this diff does the following:

* Replace use of `os.path` functions with the counterpart in `pathlib`.
* Reduce unnecessary conversions from/to `Path` to `str` / `bytes`.
* Only convert `Path` to `str` or `bytes` when interactive with other APIs (Thrift or os)
  * Cross-platform APIs: `os.fspath`
  * API expecting `str`: `os.fsdecode`
  * API expecting `bytes`: `os.fsencode`

Reviewed By: chadaustin

Differential Revision: D22879004

fbshipit-source-id: a247973dc9919c8805daa4046472124310725516
2020-08-05 14:27:04 -07:00
Genevieve Helsel
7c5ebb67bf check kerberos certificate issues in eden doctor
Summary: Often users run into kerberos certificate issues, which in turn causes permissions issues with mercurial and eden. This issue is not obvious while users are running hg commands, so `eden doctor` should identity this issue and tell the user about it. `hg doctor` runs `eden doctor`, so this should also show itself if a user runs `hg doctor`.

Reviewed By: wez

Differential Revision: D22825882

fbshipit-source-id: 5f51901934862336b0ebc2996da6e1168ea8d8a3
2020-08-05 12:48:30 -07:00
Xavier Deguillard
e8c0739b74 cli: return the full path from get_eden_mount_name
Summary:
The non-Windows part of it returns the full path for the mount, do the same on
Windows. Since this is used in the remove path to unmount the repo, and the
paths expected in unmount are fullpaths, this meant remove would always fail to
unmount the repo.

Reviewed By: chadaustin

Differential Revision: D22915352

fbshipit-source-id: 6739267188c46d5ca1d6cb212a7155e70056f0f7
2020-08-04 17:36:41 -07:00
Ailin Zhang
bbc193c7ed eden prefetch record-profile and eden prefetch finish-profile
Summary:
added `record-profile` and `finish-profile` subcommands to `eden prefetch`
`eden prefetch record-profile` triggers `startRecordingFetch()` in `HgQueuedBackingStore`. `eden prefetch finish-profile` triggers `stopRecordingFetch()` in `HgQueuedBackingStore` and write the returned fetched file names to a text file. We can use the output file to predict what files are fetched for frequently used commands.

Reviewed By: chadaustin

Differential Revision: D22797896

fbshipit-source-id: ff240829b4fb3c47093279a1f2bd453009ff5f73
2020-08-04 06:50:45 -07:00
Genevieve Helsel
395c78df5b fix typo in restarter log message
Summary: While testing something for another change, I came across this overlooked typo.

Reviewed By: wez

Differential Revision: D22894060

fbshipit-source-id: 8aa48ef5da714650c974adcf8a34a542fdd4ed9e
2020-08-03 11:19:21 -07:00
Ailin Zhang
fb5d18666a allow specifying a mount for 'eden debug gc_process_fetch'
Summary: If the user specifies a mount, only clear for that mount, otherwise clear for all mounts.

Reviewed By: fanzeyi

Differential Revision: D22674210

fbshipit-source-id: 832c4fd37a63fdb44cb12844378b61d113731016
2020-07-23 11:54:12 -07:00
Ailin Zhang
20ae54a69b clear fetch counts using eden debug gc_process_fetch
Summary: add a thrift call to clear `pidFetchCount_` in `ObjectStore` and call it in `eden debug gc_process_fetch`. Users might want this command to start a new recording of process fetch counts.

Reviewed By: kmancini

Differential Revision: D22583430

fbshipit-source-id: eba7d63b08da5134fd09b7512895aba06f6a7ca5
2020-07-23 11:54:12 -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
Stanislau Hlebik
9d18c46b1f remediation of S205607
fbshipit-source-id: 798decc90db4f13770e97cdce3c0df7d5421b2a3
2020-07-17 17:16:13 -07:00
Stanislau Hlebik
3665548bb0 remediation of S205607
fbshipit-source-id: 5113fe0c527595e4227ff827253b7414abbdf7ac
2020-07-17 17:16:13 -07:00
Ailin Zhang
316698a3c6 add --mount option to eden debug processfetch
Summary: add `--mount` option to `eden debug processfetch` as users might want to know under which checkout they have run those commands.

Reviewed By: kmancini

Differential Revision: D22485225

fbshipit-source-id: df321e6c30064c17abc62584863119b362b2c296
2020-07-17 06:43:58 -07:00
Ailin Zhang
aef527dbb0 eliminate extra blank line in tabulate
Summary: Eliminate extra blank line in tabulate

Reviewed By: kmancini

Differential Revision: D22477405

fbshipit-source-id: b867bfa5c971fcac0104563e866a314416f24fb0
2020-07-17 06:43:58 -07:00
Ailin Zhang
2deb2f28eb eden debug processfetch
Summary:
This diff added a sub-command `process_fetch` to `eden debug`, which lists eden processes sorted by their fetch counts.

New argument options will be added in following diffs.

Reviewed By: fanzeyi

Differential Revision: D22456147

fbshipit-source-id: 75f94ec0ad03d59af1a5bf31c37bdf56de70241b
2020-07-17 06:43:57 -07:00
Katie Mancini
a701242bf7 fetch aux data on corp
Summary:
This extends the metadata importer to work on corp.

Prefetching metadata for the entries in a tree when we fetch it saves us
an extra round trip to the server to fetch a blob when only the metadata
for that blob is fetched. This is particularly important on corp where the
latencies to the server are larger.

Requesting metadata with out the blob itself happens often in the parsing
phase of buck commands, thus this metadata prefetch should improve
the build times, and other work flows that rely heavily on buck queries.

Reviewed By: chadaustin

Differential Revision: D21698728

fbshipit-source-id: 4072be23f2fa7df33cf46879e8c1d8ddd6c316ba
2020-07-10 16:03:32 -07:00
Zeyi (Rice) Fan
30ba5cf783 fix missed use of Path.resolve
Summary:
There was some missed usage of `Path.resolve`. This diff should cover it all.

```
cli $ rg -F ".resolve"
main.py
967:        uid = self.resolve_uid(args.uid)
968:        gid = self.resolve_gid(args.gid)

util.py
622:    `Path.resolve`. This is a helper method to work around that by using
628:    return path.resolve(strict=strict)
```

Reviewed By: chadaustin

Differential Revision: D22459188

fbshipit-source-id: c2a1b132f752cc399ebf34723f26123559939f2a
2020-07-09 13:03:58 -07:00
Chad Austin
4c0996afa5 make systemd management functions explicitly async
Summary:
Rather than dynamically allocating an event loop in the systemd async
code, make all the corresponding functions async, so the caller is
responsible for threading an event loop down.

Reviewed By: genevievehelsel

Differential Revision: D21894106

fbshipit-source-id: 398c769c30c85a3bb210dbc209f34f9f7336996c
2020-07-07 11:31:33 -07:00
Genevieve Helsel
bda44c5201 move is_system_idle to procutils
Summary: I'd eventually like to use this in the edenfs_monitor, so moving it to `proc_utils` for sharibility.

Reviewed By: chadaustin

Differential Revision: D21998763

fbshipit-source-id: 052e78fb8e58515f98eb465b8041fd0e621fc9da
2020-07-07 11:22:33 -07:00
Genevieve Helsel
cd1196bb28 move eden idleness detection to EdenFSProcess
Summary: I'd eventually like to use this in the edenfs_monitor, so I'm adding this to `proc_utils` for future ease of use.

Reviewed By: chadaustin

Differential Revision: D21987390

fbshipit-source-id: 076672b44311c2a1e0cac934c0674a18a87649af
2020-07-07 11:22:33 -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
Adam Simpkins
14a289528d fix a crash in edenfsctl top
Summary:
Older versions of EdenFS do not return the `fetchCountsByPid` field in the
`getAccessCounts()`.

The Python thrift client code returns this as `None` instead of as an empty
dictionary.  This behavior arguably seems like a bug in the thrift code, since
the field is not marked optional.  However, updating the thrift behavior would
have much wider implications for other projects.  Additionally it's probably
not worth putting a lot of effort in to the older "py" thrift generator code.

Update the `edenfsctl` code to explicitly use an empty dictionary if the value
received from the thrift call is `None`

Reviewed By: fanzeyi

Differential Revision: D22302992

fbshipit-source-id: eced35a19d86e34174f73e27fdc61f1e2ba6a57f
2020-06-29 20:43:01 -07:00
Xavier Deguillard
c1a6d6fd21 dirstate: paths in hg are unicode, not bytes
Summary:
This was causing `hg mv` to fail due to trying to hash a unicode path, but
Python3 refuses to hash anything but bytes.

Reviewed By: DurhamG

Differential Revision: D22235561

fbshipit-source-id: 3eb80b8e02d442a4036ab7be7ea5c139bd24ff5e
2020-06-25 15:48:00 -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
Zeyi (Rice) Fan
4e7af724fb avoid using Path.resolve on Windows
Summary:
On Windows, `pathlib.Path.resolve` has an use of uninitialized memory bug in Python 3.6.2. Lego Windows has this version of Python 3 installed.

When `eden prefetch` runs, it will first attempt to read the config file at the root of the repository (`$REPOROOT/.eden/config`). Because of this bug, when we normalize the path in edenfsctl, it will get some random bytes as a result. This subsequently causes `toml.read` to fail as it is unable to read a path containing NUL byte.

As you can see, this is the same exception as we see on Windows:

```
In [1]: open("test\x00")
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-57764b20d660> in <module>
----> 1 open("test\x00")

ValueError: embedded null byte
```

Reviewed By: xavierd

Differential Revision: D22177997

fbshipit-source-id: ab2565c8946d809bc15bc1597b749fb5e9440ca0
2020-06-23 16:55:13 -07:00
Katie Mancini
f8d69a24cf fix rendering of process commands in eden top
Summary:
`eden top` often adds extra quotes to the end of the commands in the process
table, this removes those pesky quotes

Reviewed By: genevievehelsel

Differential Revision: D21440316

fbshipit-source-id: f1200a28a5345691fcce517526d119f44e5993d0
2020-06-23 13:39:45 -07:00
Chad Austin
65e7a01d6f allow async subcmd run functions
Summary: In advance of peppering async everywhere, allow subcmd's run method to be async.

Reviewed By: genevievehelsel

Differential Revision: D21892187

fbshipit-source-id: f611faacf95649d8bb5588aeefc4546bd5f63984
2020-06-22 11:27:11 -07:00
Xavier Deguillard
51df752a46 cli: support re-mounting a repo on Windows
Summary:
On Windows, we can't rely on the .eden directory to not be present to decide if
the repository is mounted. Instead, we can just let edenfs decide and catch the
exception if it tells us that it's already mounted.

Reviewed By: fanzeyi

Differential Revision: D21934538

fbshipit-source-id: 60ed9f530456b627091f95f7387dc4b8f3a8dc5c
2020-06-19 18:13:20 -07:00
Chad Austin
6d79d2559a fall back on the subprocess telemetry logger when necessary
Summary:
When the scuba telemetry logger is unavailable, fall back on the
subprocess.

Reviewed By: genevievehelsel

Differential Revision: D21687855

fbshipit-source-id: c58a4bc1b34974add35d194c8aafdaac7ed47fdb
2020-06-19 15:15:26 -07:00
Ailin Zhang
41df657be1 update eden du backing repos printing
Summary:
This diff updated the `eden du` command. Instead of printing
```Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/opsfiles gc

Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/megarepo_test gc

Reclaim space from the LFS cache directory by running:

hg -R /data/users/akushner/eden-repos/instagram-server_test gc
```
We now print "Reclaim.." only once and put available commands together
```
LFS cache detected in backing repo. To reclaim space from the LFS cache directory, run:

hg -R /data/users/akushner/eden-repos/opsfiles gc
hg -R /data/users/akushner/eden-repos/megarepo_test gc
hg -R /data/users/akushner/eden-repos/instagram-server_test gc
```
and did the same for working copy under backing repositories.

Reviewed By: fanzeyi

Differential Revision: D22038555

fbshipit-source-id: c19869db6f91e90a0627b3bb4b4f7e95142ae198
2020-06-15 11:57:29 -07:00
Ailin Zhang
2c52eed9e4 update eden du summary printing
Summary: This diff fixed small problems in previous `eden du` summary printing and added a reminder of option `--clean` to users.

Reviewed By: fanzeyi

Differential Revision: D22038552

fbshipit-source-id: 7dbac858b74833e59d8d3f1c6fb1f5d8944935d0
2020-06-15 11:40:04 -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
Zeyi (Rice) Fan
ab26fb2b83 fix eden rage on Windows
Summary:
This diff fixes `eden rage` command on Windows.

`eden doctor` and `eden redirect` related rage items are disabled as they are not implemented on Windows yet.

Reviewed By: chadaustin

Differential Revision: D21962673

fbshipit-source-id: 14399a89c26eead8fe5114e0a3764644ee86a1ed
2020-06-10 19:29:52 -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
Ailin Zhang
e9e6f94b92 update eden du to display a summary and display warnings with color
Summary: This diff updated `eden du` to display a summary and display warnings and cleaning information with colors.

Reviewed By: kmancini

Differential Revision: D21885051

fbshipit-source-id: be127b81c92bea1051a80715682cdbccf22f22e3
2020-06-10 19:29:26 -07:00
Ailin Zhang
a2a754b6f0 update eden du to display an aggregated result of all mounts.
Summary: This diff updated  `eden du` to display an aggregated result of all mounts instead of showing all details for each mount, as users generally just want to reduce disk usage but don't really care about details.

Reviewed By: genevievehelsel

Differential Revision: D21877178

fbshipit-source-id: dde43e51e96a5c2569c9fe21ab06cc7ea4295866
2020-06-10 19:29:25 -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
Xavier Deguillard
93ad242d60 packaging: use scheduled tasks
Summary:
In order to start EdenFS automatically at boot, a template service was used
previously, but due to several issues, we decided to move away from it.
Thankfully microsoft supports several other ways of starting tasks at startup,
one of which is the "Task Scheduler" itself.

One of the weird part of the task scheduler is that there isn't a good way
to tell it to not show a console for a non-graphical application, and thus
plainly executing edenfsctl start in it would create a cmd window, which
would then disappear a couple of seconds later. To avoid this, a "graphical"
version of Python is used (pythonw.exe) to start edenfsctl.

Reviewed By: fanzeyi

Differential Revision: D21732281

fbshipit-source-id: 87ef3a2d5569302392bd30a4b9e7fc48807ee316
2020-06-10 19:29:15 -07:00
Katie Mancini
137b6d984f add OS release version to eden rage
Summary:
When I was debugging the multithreaded bug issue it came up that the issue would
only affect certain versions of macos. There may be other bugs that come up
affecting only certain os versions. Having the os version in eden rage could be
helpful to identify such issues.

Reviewed By: chadaustin

Differential Revision: D21776154

fbshipit-source-id: a493e7da1823075ca4a845bd73b21716ce884911
2020-06-10 19:29:14 -07:00
Ailin Zhang
c44c95441f update eden du to look at all mounts by default
Summary: This diff made `eden du` able to run under any directory and gives statistics for every EdenFS mount on disk by default.

Reviewed By: fanzeyi

Differential Revision: D21846894

fbshipit-source-id: 2d421db8a4a0202419aa7a41e620d92f6ebdea2e
2020-06-02 21:12:27 -07:00
Genevieve Helsel
1cc1ba124c run eden start command with stdin set to /dev/null
Summary: When calling `eden start` from the CLI layer, make sure to redirect stdin in order to daemonize.

Reviewed By: chadaustin

Differential Revision: D21675707

fbshipit-source-id: 26085cc2ff7774e86f03872030c8885bc3c3b949
2020-05-28 11:32:01 -07:00
Katie Mancini
6801240ecf flag to silence fork error on mac os
Summary:
Currently when you run commands on eden on mac that both fetch data for commit
and update to that commit there is a multithreading bug. This could be a new bug
or an old bug that was not causing problems before, but is showing up a lot more
recently.

See http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html
for a nice explanation of this.

The root cause of this is still unknown, but this flag should bring back the
old behavior where we were not seeing this bug.

Reviewed By: fanzeyi

Differential Revision: D21744987

fbshipit-source-id: 85092e32212e83b16bc00dc0188f03b643c48eea
2020-05-28 10:31:12 -07:00
Xavier Deguillard
c04037d5aa cli: sys.stdout may be None
Summary:
On Windows, if edenfsctl is started by pythonw, sys.stdout will be None,
check if it is before calling isatty on it.

Reviewed By: fanzeyi

Differential Revision: D21732282

fbshipit-source-id: f0a63094f2c53b026c388f4e5b58433be4397ba9
2020-05-27 11:44:39 -07:00
Sukwon Chung
abaa62ad33 Handle inaccessible files in redirections in eden du
Summary:
1. Add directory existence checking logic before checking "legacy_bind_mounts_dir"
2. Still print the disk consumption returned by the du command when it fails with an error invoking du -skxc

Reviewed By: chadaustin

Differential Revision: D21683421

fbshipit-source-id: 531b6b289e9ffa445ed691611c9cbf22f393e742
2020-05-21 22:20:17 -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
Genevieve Helsel
f799ca8981 suggest graceful restart in eden doctor version check
Summary: I've updated most messages to suggest a graceful restart, but I overlooked this instance and we got a user question about this. So lets update this message here as well.

Reviewed By: chadaustin

Differential Revision: D21681035

fbshipit-source-id: 32bf5e75b9ad1d98bcd70427101aabeee0be5046
2020-05-21 09:38:58 -07:00
Xavier Deguillard
6cdc2782b3 cli: add a startservice.ps1 script
Summary:
This script deals with obtaining the right privilege to start the EdenFS
service. This effectively enables `edenfsctl start`.

Reviewed By: wez

Differential Revision: D21585739

fbshipit-source-id: 7b835434d865fa4c4c8473e13665ae669fd86108
2020-05-19 13:00:54 -07:00
Genevieve Helsel
234383d086 remove version check from redirect fixup
Summary: Nothing should be running with this version, so this check is not needed anymore!

Reviewed By: chadaustin, wez

Differential Revision: D21513269

fbshipit-source-id: 698c9d84e87461cd0484ef997f44dc9169e87a25
2020-05-12 15:43:31 -07:00
Genevieve Helsel
12c5a2d221 doctor - fixup redirections
Summary: `eden doctor` should probably fix misconfigured redirections. this is mostly copy pasted from the `eden redirect fixup` command.

Reviewed By: wez

Differential Revision: D21487225

fbshipit-source-id: 69e7fcb446cbc42966cabb6d80ab716533da50a9
2020-05-11 22:13:06 -07:00
Alvaro Leiva Geisse
675b83557e add extra 2 extra type hints for systemd Manager
Summary: add two methods calls as typehints (no real code change).

Reviewed By: zeroxoneb

Differential Revision: D21337646

fbshipit-source-id: 8079883f7f989251965d3308c5374f097023b57a
2020-05-11 20:52:13 -07:00
Jessica Gomes
50022171c9 add uptime field to DaemonInfo
Summary:
- Added uptime field to DaemonInfo thrift struct
- Created startTime member variable in EdenServer
- Made appropriate refactoring changes to EdenMain and EdenServer
- Changed main.py and util.py to use the new uptime value

Reviewed By: genevievehelsel

Differential Revision: D21471140

fbshipit-source-id: 8868de667dfb95de93e3e71b90c0412fb3825388
2020-05-11 11:42:15 -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
0f6e81bbd7 add an eden pid subcommand
Summary:
Sometimes, in shell one-liners, it's convenient to insert the current
eden pid. We print the pid as part of `eden status` (like nginx and
many other daemonizing programs), but that is not useful for shell
substitution. So a pid subcommand that succeeds and prints the pid to
stdout if running and fails if edenfs is not running.

An example use would be `strace -fyp $(eden pid)`

Reviewed By: genevievehelsel

Differential Revision: D21397118

fbshipit-source-id: 06010150557ec882b452180665b84452fa06ebbd
2020-05-08 13:14:38 -07:00
Katie Mancini
5d4975aa02 add help page to eden top
Summary:
The information available in `eden top` is growing and as we add more and
more to eden top, we want to make sure that eden top users can understand
what `eden top` is telling them. Particularly if we want eden end users to be
able to debug themselves, providing them enough context on the
metrics eden top provides is important.

The help page explains what data is included, why this data is helpful and
when this data indicates a concern.

Reviewed By: wez

Differential Revision: D20974262

fbshipit-source-id: caaef70e76d283968bee8533c7c34d63a95c5490
2020-05-08 09:53:06 -07:00
Katie Mancini
fe779826bf add scrolling in eden top
Summary:
this is preperation for adding a help page to eden top (D20974262)

This allows adding a scrollable section to `eden top`. This is particuarly needed
so that the help page is readable when it does not fit all in one screen. This
also allows scrolling the process table on the main page to see all the
processes listed (this is added here).

Reviewed By: chadaustin

Differential Revision: D20974245

fbshipit-source-id: 402409efdc451db32e7a267b0750204f2322dc4f
2020-05-08 09:53:05 -07:00
Katie Mancini
c194bc78be refactor writing to the screen in eden top
Summary:
this is preparation for adding a help page to eden top (D20974262)

This moves all code for writing to the screen to its own class so that
it is not scattered through out the rest of the eden top logic. This is
primarlity so that it is easier to make changes the screen writing logic to
allow scrolling, which is needed so that the full help screen can be read
when it takes up more space than is avaiable.

Reviewed By: chadaustin

Differential Revision: D20965954

fbshipit-source-id: c2690a293579706605d26be9d3bbe491104e6847
2020-05-08 09:53:05 -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
Chad Austin
b9ba1b40af fix help text for info subcommand
Summary:
The name of a checkout is not a public concept, so refer to the
checkout's path.

Reviewed By: genevievehelsel

Differential Revision: D21393208

fbshipit-source-id: 4c014a6f65515f4632f2dffe5d563d0ee859dda0
2020-05-05 12:09:12 -07:00
Chad Austin
e0cfe9e104 rename stats io to stats fuse and stats latency to stats fuse-latency
Summary:
When I want FUSE stats, I never run `eden stats io`. To unify the
command language, rename `io` to `fuse` and `latency` to
`fuse-latency`, to match `thrift` and `thrift-latency`.

Leave aliases in place in the off chance someone cares.

Reviewed By: genevievehelsel

Differential Revision: D21392931

fbshipit-source-id: 843c1c85ea0aa162ba167f251f0f2cde5a389e72
2020-05-05 12:09:12 -07:00
Chad Austin
8b5c1e66b7 remove stats memory command
Summary:
`eden stats memory` was never useful because it shows system
statistics which you can get better from `top`, `htop`, or `atop`.

Reviewed By: genevievehelsel

Differential Revision: D21392737

fbshipit-source-id: 010021b8a97bd8ba8ac289d906acc3c3ecd10768
2020-05-05 12:09:11 -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
Genevieve Helsel
367db1d20a shorten recovery wait timeout and increase restarter restart timeout
Reviewed By: wez

Differential Revision: D21333897

fbshipit-source-id: ba2b9aa375bfa91693c8985ff4cb57e944b04eff
2020-05-04 09:22:24 -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
Genevieve Helsel
bd00e12830 introduce eden uptime command
Summary: I thought it would be helpful to introduce and `eden uptime` command, especially with automated graceful restart on the way. This prints it in human readable format, later on if for some reason automation would like to use this, a flag could be added that allows for custom formatting. Also, this can be added to `eden rage` output later.

Reviewed By: chadaustin

Differential Revision: D21260800

fbshipit-source-id: 3f9a4f8d6264dfc38bd15c024a0209f7eeb912fa
2020-04-28 18:25:03 -07:00
Katie Mancini
6dd392de92 update eden top display for pending FUSE imports
Summary:
D21074489 adds metrics for pending FUSE requests, this cleans up the display for
pending requests.

This removes the max duration of pending requests for FUSE requests since this
data is not available (it is not measured by the FUSE library).

Reviewed By: chadaustin

Differential Revision: D21074746

fbshipit-source-id: e5585ec091aa5fd5499deee2d8be89f47f769a6a
2020-04-28 13:28:01 -07:00
Katie Mancini
44f3d2fab9 show live FUSE requests in eden top
Summary:
This adds the number and duration of FUSE requests to eden top.

The purpose of this metric is to provide a highlevel indicator of
the health of eden and the fuse interface. Because FUSE is the
interface through which the user mostly interacts with the file
system it these metrics are reflective of edens overall
responsiveness.

The metrics are collected per mount, but we only display the
aggregate since this serves as an overall summary metric.

These metrics are displayed similarly to the import metrics,
for consistency. There is not a metric for the max duration
of pending FUSE requests D21074746 cleans this up so that
the NA is removed from the display.

Reviewed By: chadaustin

Differential Revision: D20928603

fbshipit-source-id: ce78f4274203c2302e7595ae2ef601e18893db38
2020-04-28 13:28:01 -07:00
Wez Furlong
b45765cf8c eden: preserve the mkscratch config path when starting daemon
Summary:
This makes it a bit easier to write integration tests
that run an isolated EdenFS instance complete with its own
unique scratch path environment.

Reviewed By: genevievehelsel

Differential Revision: D21258455

fbshipit-source-id: 3ea13b6337bb8bb58a237e67488b116c423bbe6c
2020-04-28 13:15:46 -07:00
Wez Furlong
605665368f eden: windows: use globFiles to power prefetch
Summary:
Now that we have globFiles available via thrift on windows,
we can use it to implement eden prefetch on windows, rather than the
significantly slower `hg prefetch`.

Reviewed By: pkaush

Differential Revision: D20781187

fbshipit-source-id: f6cd37a2a504d07f03be2695a69a72ddf7a62593
2020-04-24 15:57:27 -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
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
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
Xavier Deguillard
97cdd3a4d1 escape repository path
Summary:
On Windows, paths components are usually separated by '\', and since the
repository path is stored in a toml file, whatever character is after a '\',
will be escaped. In my case, this is followed by U (for C:\Users), and thus
toml expects the next characters to be an escaped unicode. That's obviously
not the case and thus EdenFS fails to parse the config, preventing me from
cloning fbsource.

Since Windows is perfectly fine with '/' as path separator, let's just
replace '\' with '/'.

The underlying bug appears to be in the toml Python code: https://github.com/uiri/toml/issues/280

Manually trying some random path is pretty conclusive:
  (Pdb) toml.dumps({'foo': 'c:\\Users\\wez'})
  'foo = "c:\\\\Users\\\\wez"\n'
  (Pdb) toml.dumps({'foo': 'c:\\Users\\xavier'})
  'foo = "c:\\Users\\xavier"\n'

Reviewed By: chadaustin

Differential Revision: D21143545

fbshipit-source-id: 448471da12c253dd37680f6a28251a1e69850920
2020-04-20 21:05:20 -07:00
Genevieve Helsel
9242ac8e23 ensure a process is running after a failed graceful restart
Summary:
As a top layer of reliability in graceful restart, we'd like the CLI to enforce that something has started after a graceful restart call. There are a few things that can happen

1) The restart short circuts before attempting to shutdown (version mismatch etc). The old process will continue (`success == False`)
2) The restart is successful, the new process will continue (`success == True`)
3) The restart is not successful (failed ping), the old process will recover (`success ==
False`)

(note here that the `success` field is the return code of the `StartupLogger` process, not the edenfs process itself).

In case any of these fail, we'd like a final line of defence with the CLI.

First, in the case of a successful start from the `StartupLogger` report, we consider this successful and exit. If we do not have a successful (`success == False`) graceful restart, we will wait for the new process to recover (since the old process will go from `ALIVE` to `STOPPED` to `ALIVE`). I do not expect recovery to take long since we are only remounting, not waiting on RocksDB. Here though, we give a fairly long timeout (1hr) to ensure we're not stuck on an in process thrift call, since we would not like to force kill the process if we're writing to the overlay.

If we time out waiting, we will just kick off a force restart and assume the old process is stuck.

Reviewed By: simpkins

Differential Revision: D20673460

fbshipit-source-id: 215e06fa8aa76dbe5dae6602f82ce5f05968e538
2020-04-20 15:47:52 -07:00
Genevieve Helsel
7492cc406f add more explicit remediation steps for stale mounts after restart
Summary:
We got a user request to add this output after a restart. This (` run "cd / && cd -" to
update your shell's working directory.`) is the output from eden doctor when it detects stale mount points. I don't think it hurts to add, especially since new customers may not make the connection/have the context to deduce that "programs" in this message also apply to the user's shell.

Reviewed By: kmancini

Differential Revision: D20971070

fbshipit-source-id: 3448651cae90b2b5c8c4d2432b946521cdc5a292
2020-04-20 09:21:01 -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
ce48896dad get edenfsctl stop working on Windows
Summary:
Update the `edenfsctl` and `edenfs` code so that `edenfsctl stop` works on
Windows.

Reviewed By: pkaush

Differential Revision: D20854616

fbshipit-source-id: 9a51cdc1f1d1838c5089b945df1fb624a3eaedb7
2020-04-15 15:46:25 -07:00
Adam Simpkins
104ae880db fix issues when checking EdenFS status on windows
Summary:
- Catch the Windows-specific exceptions types thrown when attempting to open
  the socket if EdenFS is not running, and convert this to an EdenNotRunning
  exception.
- Update EdenFS to write its pid to a separate file, in addition to the normal
  lock file, and have `edenfsctl` read this file instead of the lock file on
  Windows.  Other processes cannot read the lock file while EdenFS is running
  and holding the lock, so it is nice to have the pid written in an alternate
  location.

Reviewed By: pkaush

Differential Revision: D20854615

fbshipit-source-id: 1c8e8f402eb17dd012d03e11fbb662f493d9362d
2020-04-15 15:46:24 -07:00
Adam Simpkins
b1a35b8252 move systemd-related start code to its own module
Summary:
Move the `start_systemd_service()` function from `daemon.py` to a separate
module.  This allows `daemon.py` to be imported on Windows without causing any
of the systemd logic to be imported.

I kept this separate from the existing `systemd.py` module for now just to
help keep the dependencies a little bit cleaner.  The `systemd.py` module
currently does not depend on any other logic from other edenfsctl modules.

Reviewed By: pkaush

Differential Revision: D20854612

fbshipit-source-id: dbdbf0fec90682e3b7d16a7532aefdd3f186bf80
2020-04-15 15:46:24 -07:00
Genevieve Helsel
66076644f7 list redirections in eden rage
Summary: I believe it would be nice to include the output of `eden redirect list` in `eden rage` since I've run into a few times this week where that was something that was asked for.

Reviewed By: chadaustin

Differential Revision: D20955632

fbshipit-source-id: 0d28688b3764a1bec8a9e92b72c166dddd18f591
2020-04-15 14:25:11 -07:00
Adam Simpkins
dd12bff33d clean up some pyre-fixme comments in eden/fs/cli/config.py
Summary:
Clean up the last two remaining pyre-fixme comments in this file.
I believe these casts were needed at one point to make mypy happy, but it
looks like they are no longer necessary.

Reviewed By: genevievehelsel

Differential Revision: D21007030

fbshipit-source-id: 6933425d9fde8b86272c68b955faf21348453f68
2020-04-13 19:36:47 -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
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
0979042fd7 Explicitly track current/pending imports -- display current metrics in eden top
Summary:
As discussed in D20629833 metrics for live imports
like those for pending imports can help differentiate
where imports are in the process.

This can help give users more insight into what is
happening inside eden. Meaning that they can see
progress being made, and that eden is not stuck. But
also when eden is stuck these metics can indicate
that it is stuck fetching data from the mercurial servers.

This displays those metrics in `eden top` similar to those
for pending imports

Reviewed By: chadaustin

Differential Revision: D20630826

fbshipit-source-id: ab7368927d2832acbea89a82585fda5195ce03d1
2020-04-09 12:35:23 -07:00
Adam Simpkins
49cc8e4d3c default to checking out the master revision for hg repositories
Summary:
When cloning a Mercurial repository, default to checking out the `master`
bookmark, if it exists.  Continue using `.` in case the repository does not
have a `master` bookmark.

Reviewed By: pkaush

Differential Revision: D20876461

fbshipit-source-id: 57fa12e4c713bd50c15f59eb9281e0511c3cfe88
2020-04-09 00:18:19 -07:00
Adam Simpkins
a3d4ae3d40 do not create the README_EDEN.txt file on Windows
Summary:
Do not put a `README_EDEN.txt` file in the checkout root on Windows.  On Linux
& Mac the EdenFS mount hides this directory, so the README file is not visible
while the checkout is mounted and running normally.  However on Windows
anything present in this directory is visible to the user, so this results in
`README_EDEN.txt` incorrectly showing up in the checkout root.

Reviewed By: genevievehelsel

Differential Revision: D20929408

fbshipit-source-id: 9994524041f22fd8922c531f0185186b04c54821
2020-04-08 20:49:24 -07:00
Adam Simpkins
b3ad383ad7 never try to use systemd on Mac or Windows
Summary:
Make sure the function that decides if we should use systemd always returns
False on non-Linux platforms, even if it is explicitly enabled via the config
file or environment variable.  systemd is Linux-specific, and it doesn't make
sense to try and use it on other platforms.

Reviewed By: fanzeyi

Differential Revision: D20925344

fbshipit-source-id: cee67f607809da15f584de1eb12a2c4a243b0c91
2020-04-08 17:38:38 -07:00
Adam Simpkins
6d86308c22 delete the old eden debug set_log_level command
Summary: This has been deprecated for a long time in favor of `eden debug logging`

Reviewed By: genevievehelsel

Differential Revision: D20876084

fbshipit-source-id: 0d9bf71e55aaffde7ae9f061def0adf8312c2411
2020-04-06 18:53:00 -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
Adam Simpkins
dbbb0d64c8 rename the ProcessFinder class to ProcUtils
Summary:
This renames the `ProcessFinder` class to `ProcUtils`, in preparation for
adding some more generic process management utilities into this class.

This class was originally just used for finding stale processes in
`edenfsctl doctor`.  However, it seems like a good place to consolidate all
platform-specific process querying logic.  We are currently need
platform-specific querying to tell if specific process IDs are still running
for `edenfsctl status` and `edenfsctl stop`, and we also already have some
Windows-specific spawning logic in `edenfsctl start`.  I plan to move all of
that logic into this `proc_utils.py` module.

This renames `ProcessFinder` to `ProcUtils` just to better reflect its
expanded purpose.

Reviewed By: genevievehelsel

Differential Revision: D20833243

fbshipit-source-id: 8d33460b7468d877bc327e855af5c620ac5b80a7
2020-04-03 16:52:33 -07:00
Adam Simpkins
17a3c9124d update Python platform checks to use sys.platform
Summary:
Update out platform checks to use `sys.platform` instead of `os.name`

Python type checkers (mypy and Pyre) currently understand checks against
`sys.platform`, and know that code guarded by these checks is platform
specific.  They don't understand the `os.name` checks.

This code should behave the same, but allows type checkers to do a better job
checking this code.

Note that there is also `platform.system()`, but this has drawbacks that it
apparently does runtime-checks to determine the platform, whereas `sys.platform`
is baked-in at compile time.  Additionally, the typecheckers do not appear to
support checking based on `platform.system()` for now.  There is an open
feature request for this for mypy, but it is not implemented yet.

One caveat for `sys.platform` is that the results on Linux are not consistent
across Python versions: older versions of Python used to report `linux2` while
new versions report simply `linux`.

Reviewed By: chadaustin

Differential Revision: D20830149

fbshipit-source-id: d173e41f1ae84951a84b87e2dc05787fe8b01407
2020-04-03 16:52:32 -07:00
Adam Simpkins
83f036f483 update the CLI to find the correct edenfs binary on Windows
Summary:
Update the `edenfsctl.exe` binary to find `edenfs.exe` relative to itself.
This ensures that when you run `edenfsctl.exe` from a development build that it
finds the associated development build of `edenfs.exe`, rather than the current
system-installed version.

Reviewed By: wez

Differential Revision: D20821419

fbshipit-source-id: 29ff0b587800f1b76c0b729512bc19f5aef648a7
2020-04-03 16:52:32 -07:00
Katie Mancini
fbf319050b Adding Longest outstanding imports to eden top
Summary:
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.

Because it is a strong indicator (specifically stronger than the number of imports) for when there is an issue effecting imports, we use it as a warning signal to the user, meaning we display warning colors when the duration of the longest import is long enough to warrant concern.

We have 2 levels of concern to differentiate when there may be something strange happening and when there is almost definitely something strange happening. These correspond to displaying the import metrics in yellow and red respectively. The current threshold for something strange possibly happing is imports taking longer than 10s and something strange definitely happening is imports taking longer than 30s.

Reviewed By: chadaustin

Differential Revision: D20627754

fbshipit-source-id: 7931d2c0ab53952c1291fd1d411dad14d142734b
2020-04-01 09:54:30 -07:00
Katie Mancini
44a352e8e3 Add number of pending Imports to eden top
Summary:
When there is an issue in the import process, there is not an easy way to detect this currently. As a first step towards making it possible to detect when there is an issue here, we expose the number if imports pending to `eden top`.

If there is a problem blocking imports from happening, then they will start to queue up and the number of pending imports will keep growing. When there are a lot of pending imports it indicates that there may be a problem in the import process.

note: there are cases when there are many pending imports under normal operation. It is common to batch fetch a bunch of files at once, and submitting all these prefetches at once will mean a lot of pending imports though there is no problem. Thus number of pending imports only indicates there *may* be an issue in the import process. (Thus we couple it with the duration of the longest import D20627754 for stronger signal)

The other value in showing the number of pending imports is giving users more transparency into eden. When there is a big batch of imports this may leave the user waiting a while, and this gives a way for them to know why. They can see that eden is making progress rather than being stuck.

Reviewed By: fanzeyi

Differential Revision: D20527273

fbshipit-source-id: 59e0fdff6e7b154b409dfab385b4fdb02062b066
2020-04-01 09:54:30 -07:00
Adam Simpkins
97f0ab8b6c update LinuxProcessFinder find the eden directory from the lock file
Summary:
Update the LinuxProcessFinder code to ignore the command line arguments when
looking for the state directory, and instead only look at the open file
descriptors.

The path found from the command line arguments could be incorrect: if the
EdenFS state directory had been deleted or renamed the information extracted
from the command line would be incorrect.

The information found by examining the open file descriptors will point to the
new directory location if the state directory has been renamed.  We can also
tell if the lock file had been deleted in this case as well.  This adds
another field to the `EdenFSProcess` class to indicate if the lock file is no
longer valid.

Reviewed By: wez

Differential Revision: D20638621

fbshipit-source-id: e9db1390f97baf50ad3246de4a964eaaf92622e7
2020-03-27 12:22:44 -07:00
Chad Austin
8c5dab9219 enable python cli tests on macOS
Summary: Enable the CLI tests on macOS when run with Buck.

Reviewed By: wez

Differential Revision: D20524347

fbshipit-source-id: cf3e302256b6b0e6958999cf83c5be5d48f65907
2020-03-26 13:22:36 -07:00
Wez Furlong
0f01cbc149 eden: EASY: fix missing f"" in edenfsctl du
Summary:
I noticed that the output was `{backing_repo}` in a couple
of user reports, rather than the path to the backing repo.

Reviewed By: genevievehelsel

Differential Revision: D20669756

fbshipit-source-id: c9f1dbb4f4b2ad3de03c54f1e3cb5f688ee433ac
2020-03-26 10:05:35 -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
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
Adam Simpkins
6d4d187deb an "eden debug" CLI command and thrift APIs to support it
Summary:
This diff adds a new "eden debug" command, with a few subcommands:

- "eden debug inode": Report information about currently loaded inodes
- "eden debug tree": Report data about source control Tree objects
- "eden debug blobmeta": Report metadata about source control Blob objects
- "eden debug blob": Report the contents of source control Blob objects

This diff also includes the thrift APIs in edenfs to support these commands.

Reviewed By: bolinfest

Differential Revision: D4760528

fbshipit-source-id: 7dc2bd6e0e952ba6fb61702c672fb9417d603ffa
2017-04-03 15:50:32 -07:00
Adam Simpkins
645b6fca0a update "eden daemon" to also pass through KRB5CCNAME
Summary:
When the "eden daemon" CLI command has to run edenfs via sudo, also explicitly
pass through the KRB5CCNAME environment variable.  This will allow edenfs and
it's hg import helper to find the correct Kerberos credentials if it needs to
connect to a remote server.

Reviewed By: wez, bolinfest

Differential Revision: D4584132

fbshipit-source-id: 6c72e4eca76d81b3d4b53a9e72a0e8388da30a7d
2017-02-22 18:37:42 -08:00
Adam Simpkins
fed342da30 store overlay files using inode numbers instead of paths
Summary:
Refactor the Overlay code to store data using inode numbers rather than the
affected file's path in the repository.  This simplifies the TreeInode code a
bit, as we no longer have to rename overlay files to stay in sync with the file
paths.  This also eliminates some crashes when trying to update overlay files
for inodes that have been unlinked (and hence no longer have a path).  This
also includes a few fixes to avoid writing journal entries for unlinked files
too.  Additionally this contains a few fixes to how mode bits are stored in the
overlay, and fixes a bug where create() was ignoring the mode argument.

Reviewed By: wez

Differential Revision: D4517578

fbshipit-source-id: c1e31497dcf62c322b0deff72b0a02675b0509ab
2017-02-10 14:17:52 -08:00
Wez Furlong
fb957d58ec allow interpolating USER and HOME in the ClientConfig class
Summary:
This mirrors the capability added in D4444058.

I don't think the `getenv` calls are awesome, but also don't think that we're
likely to want to override these outside of the environment either, so it
doesn't warrant plumbing these all the way through the eden cli, edenfs command
line flags and the layers to get to instantiate this object.

Reviewed By: simpkins

Differential Revision: D4446320

fbshipit-source-id: d5661e4f3e8dee82617eb6edddbcb9da5f4296d2
2017-01-23 23:54:38 -08:00
Wez Furlong
4829dfe319 change systemConfigDir to etcEdenDir
Summary:
While testing with the fb-eden rpm installed, I hit some integration
test failures.  These were caused by the integration tests picking up the
default post-clone hook configuration.

This diff changes our existing `systemConfigDir` option (which defaults to
`/etc/eden/config.d`) to `etcEdenDir` (which defaults to `/etc/eden`) and
adjusts the code that consumed `systemConfigDir` to construct the effective
value by computing `etcEdenDir + "config.d"`.

Doing this allows us to also default the `repoHooks` path to be
`etcEdenDir + "hooks"` rather than just hard coding `/etc/eden/hooks`.

The result of this is that our integration tests will now pass when `fb-eden`
is installed, because they override the `etcEdenDir` option and isolate their
`edenfs` processes from the globally installed configuration.

Reviewed By: bolinfest

Differential Revision: D4446321

fbshipit-source-id: 524fdb2f386fdf16dce42dce7661d07e13c0f0e7
2017-01-23 23:54:38 -08:00
Wez Furlong
dff225b60e add limited interpolation to eden config parsing
Summary: This allows us to templatize centrally managed config files

Reviewed By: bolinfest

Differential Revision: D4444058

fbshipit-source-id: a44372084d32dcf0b27922490ab40a48478a720d
2017-01-23 23:54:38 -08:00
Wez Furlong
bafc809c36 refactor and centralize ConfigParser calls to _loadConfig
Summary:
I'm going to follow up with some changes to substitute
some core env vars; this is just some prep.

Reviewed By: bolinfest

Differential Revision: D4444030

fbshipit-source-id: ab5d0e39aba14cdba39bb4867ec24955665723c6
2017-01-23 23:54:38 -08:00
Wez Furlong
8b8d6d319f add eden config command
Summary:
`eden config` dumps all parsed config values.

`eden config --get SECTION.OPTION` prints the value of the corresponding key.

Reviewed By: bolinfest

Differential Revision: D4434084

fbshipit-source-id: 63d9f72aa8794371e89a6d9e527bacaab17540de
2017-01-23 23:54:38 -08:00
Wez Furlong
9ff3def69f pass down paths for eden, edenfs, post-clone via environment in tests
Summary:
This makes it easier to reason about where these things can be found,
and in particular, allows passing the path through to the post-clone hook
script.  Although post-clone accepts some command line configuration options,
our hooks scheme doesn't seem to allow setting that in the eden configuration
file.

Reviewed By: bolinfest

Differential Revision: D4443872

fbshipit-source-id: ed92dbac3b91b7f7dc86a39a85b465907f290b47
2017-01-23 23:54:37 -08:00
Andrew Gallagher
14fa8d476e buckification: switch some raw Buck rules to use the buck_ wrappers
Summary:
We implement some sanity checking in wrappers, preventing some unsafe
consequences of using raw Buck UI in fbcode.

Reviewed By: Gownta

Differential Revision: D4453147

fbshipit-source-id: 3069898069c7e89223b133224f7c87d1a6b5886a
2017-01-23 19:30:02 -08:00
Adam Simpkins
e31889d295 fix a variety of lint issues
Summary:
Fix issues flagged by running "arc lint" on all eden files.  There are still 6
warnings outstanding, but these are either false positives or advice that we
intentionally are ignoring for legitimate reasons.

Reviewed By: bolinfest

Differential Revision: D4446615

fbshipit-source-id: 992f3c146f99d63935f849aa775dd6d611a04acf
2017-01-23 18:03:09 -08:00
Adam Simpkins
251da81f36 update all copyright statements to "2016-present"
Summary:
Update copyright statements to "2016-present".  This makes our updated lint
rules happy and complies with the recommended license header statement.

Reviewed By: wez, bolinfest

Differential Revision: D4433594

fbshipit-source-id: e9ecb1c1fc66e4ec49c1f046c6a98d425b13bc27
2017-01-20 22:03:02 -08:00
Wez Furlong
26f5b43a93 fix running "eden" with no arguments
Summary:
Previously we'd emit an AttributeError.  This diff
fixes things up so that we show the help when no arguments are provided.

Reviewed By: simpkins

Differential Revision: D4434060

fbshipit-source-id: 838b1cab47118d8517e4dc0c5fde17fc69752b13
2017-01-18 21:56:57 -08:00
Andrew Gallagher
26c2526080 Fixup more rule names in TARGETS
Summary: Manually fixup rule names which the codemod scripting didn't catch.

Reviewed By: igorsugak

Differential Revision: D4420657

fbshipit-source-id: 20794b17732ca5c37686bd22edc1538837098022
2017-01-16 11:40:07 -08:00
Michael Bolin
3f2f22d8fa Normalize build targets to always start with //.
Summary:
We can use `//` exclusively because we always build Eden with Buck and never
fbbuild, our legacy build system for fbcode.

This revision was initially created by running:

```
find eden -name TARGETS | xargs sed -i -e 's#@/#//#g'
```

And then manually updating the `DEFS` file now that we no longer need
some normalization code for an outdated pattern.

But then I got annoyed by other inconsistencies, so I went through and
alpha-sorted some lists, replaced all double quotes with single quotes,
and fixed indents to be two spaces.

Reviewed By: simpkins

Differential Revision: D4356724

fbshipit-source-id: ab07a48f12fa937c257213d12331efdf09e42da6
2016-12-21 16:28:02 -08:00
Adam Simpkins
29111f3733 normalize mount paths when doing config look-ups
Summary:
The keys in the config directory map are normalized, absolute paths to the
mount point.  When trying to look up a mount point make sure we also always use
a normalized absolute path.

Reviewed By: bolinfest

Differential Revision: D3942565

fbshipit-source-id: 63db838ffc7139d779925adf07c50f849d73bcc5
2016-09-30 19:07:45 -07:00
Michael Bolin
634e96872e Add initial support for hooks akin to Git hooks for Eden.
Summary:
This design is inspired by that of Git hooks:
https://git-scm.com/docs/githooks

By default, `/etc/eden/hooks` should be the place where Eden looks for
hooks; however, this can be overridden in `~/.edenrc` on a per-`repository` basis.
This directory should be installed as part of installing Eden.
There is information in `eden/hooks/README.md` about this.

The first hook that is supported is for post-clone logic for a repository.

This change demonstrates the need for an `eden config --get <value>`
analogous to what Git has, as hooks should be able to leverage this in their
own scripts. There introduces a `TODO` in `post-clone.py` where such a
feature would be useful, so that I could add the following to my `~/.edenrc`
to develop the Eden extension for Hg:

```
[hooks]
hg.edenextension = /data/users/mbolin/fbsource/fbcode/eden/hg/eden

[repository fbsource]
path = /data/users/mbolin/fbsource
type = hg
hooks = /data/users/mbolin/eden-hooks
```

Note that this revision also introduces a `generate-hooks-dir` script that can be
used to generate the standard `/etc/eden/hooks` directory that we intend to
distribute with Eden. This is also useful in creating the basis for a custom `hooks`
directory that can be specified as shown above in an `~/.edenrc` file.

Reviewed By: simpkins

Differential Revision: D3858635

fbshipit-source-id: 215ca26379a4b3b0a07d50845fd645b4d9ccf0f2
2016-09-26 13:53:05 -07:00
Michael Bolin
c750977b59 Fix ResourceWarning due to unclosed file.
Reviewed By: wez

Differential Revision: D3837917

fbshipit-source-id: c9e8d4d8a4574177a4d91eaea4ea0925fb6ddd99
2016-09-09 00:30:13 -07:00
Michael Bolin
7c3db40f8e Fix a bug in eden info when bind mounts are present.
Summary:
This did not work because the dict-like object read from
a `ConfigParser` was not JSON-serializable by Python.

I had to add some methods to the `Repository` that we use in our
integration test harness in order to verify everything I wanted to
in my new integration test. I implemented these methods in both
`HgRepository` and `GitRepository`.

Reviewed By: simpkins

Differential Revision: D3837879

fbshipit-source-id: e0bfb5f1bd3add192ef9bdf561591ac8e52bc002
2016-09-09 00:30:13 -07:00
Michael Bolin
0792dc88e9 Remove some unused Python imports.
Summary: I did what the linter told me to do.

Reviewed By: wez

Differential Revision: D3836659

fbshipit-source-id: a5d3fc8974cf6cb7c7e2d88a6215ac5c54479780
2016-09-08 12:45:02 -07:00
Adam Simpkins
7a6dedfae9 explicitly pass environment settings through sudo
Summary:
Recent changes to our sudo policy seems to be dropping the SSH_AUTH_SOCK
environment variable for me, even when using "sudo -E".  (We do explicitly
configure this to be dropped with sudo's env_delete setting.)

This updates the eden CLI to explicitly ask sudo to set environment variables
that we care about.

Reviewed By: bolinfest

Differential Revision: D3674124

fbshipit-source-id: ab14453056961f7b6a7f5d4122bc0c6f5caa6588
2016-08-10 13:28:15 -07:00
Caren Thomas
670297fa88 add ClientConfig method that compiles repository data
Summary: Restructure the current logic used for loading the config data into a ClientConfig object. Rather than having loadFromClientDirectory iterate through all the config files and parse them to find the necessary information, abstract that logic out into a new method that compiles all of the relevant data so that all loadFromClientDirectory has to do is pull out the needed information. Since this change separates the two steps, this will make it easier to move the first step of compiling config information outside of ClientConfig - the goal here is to have the eden server load all of the config data at start up and cache it in memory so that it doesn't need to be done every time a ClientConfig object is created, and this change is an intermediate step.

Reviewed By: simpkins

Differential Revision: D3580757

fbshipit-source-id: c340a0fe715856066a554238249574f8177bc4d7
2016-08-05 12:50:29 -07:00
Michael Bolin
e17e7c15eb Use the realpath to normalize the path to the clone.
Summary: This should facilitate things by making the way to reference the path unambiguous.

Reviewed By: simpkins

Differential Revision: D3672311

fbshipit-source-id: b2a21e4dba60ea5ded28643f76aa402c4250d7ac
2016-08-05 11:48:07 -07:00
Michael Bolin
40b95a72a1 Use the path as the key to the config rather than the repo_name.
Summary: The repo_name could be cloned multiple times, which would cause a collision.

Reviewed By: simpkins

Differential Revision: D3672298

fbshipit-source-id: f27e1ec00ab773ed50f4fcf6f485461d01f8ba11
2016-08-05 09:05:09 -07:00
Adam Simpkins
59319918bd re-add the "eden mount" command
Summary:
Add back the "mount" CLI command.

While end-users may not need this command under normal circumstances, during
development it is sometimes necessary to re-mount unmounted clients.  This adds
back the "mount" command which simply re-mounts an already configured client.

This also adds a "--no-forget" option to "unmount" which causes it to unmount
the client without forgetting its configuration.  This allows it to be
remounted with "mount", rather than having to re-run the "clone" command and
specify the repository name again (and potentially restore the desired snapshot
hash).

Reviewed By: wez

Differential Revision: D3653706

fbshipit-source-id: 0e3f3fe1efdf72e9e54bdd1e0fb308ae67b7c058
2016-08-03 16:29:21 -07:00
Caren Thomas
90cfd27c37 add configPath_ field to EdenServer
Summary:
Include a configPath_ field for EdenServer that holds the path of the user ~/.edenrc config file. The server needs the data from this user config file in order to perform mounts and currently, the path to the home directory is passed via the CLI to the mount command as a field inside the MountInfo struct in order to get the file. As per discussion in D3498567, including the home directory inside the MountInfo struct is logically a bit disjointed, and this change would no longer require the home directory to be passed to the server via MountInfo.

This restructuring also sets up eden for a future change - having the server remount existing mount points on start-up is now possible from the inside. Before this change, mounting anything had to be done via the CLI since the home directory had to be passed in from the outside. This meant that remounting the existing mount points on start up could only be done if Eden was run in the background - running in the foreground would require manual remounting of all existing mount points. Now that the server has access to the config file's path, remounting can be done without any prompting from the CLI in both cases.

Reviewed By: simpkins

Differential Revision: D3580737

fbshipit-source-id: 46667ccd130b470a3a8a9e9aa08e5ec8e8b90336
2016-07-26 10:16:16 -07:00
Adam Simpkins
a03cdb4d57 update the integration tests to allow running under gdb
Summary:
When the EDEN_GDB environment variable is set, start eden under gdb when
running the integration tests.  Have gdb automatically start the daemon,
and exit automatically if everything is successful.  If the daemon crashes, gdb
will break and the user can interact with gdb normally.

This is generally only useful when manually running a single test.  Trying to
use this in combination with "buck test" will probably cause problems if
multiple gdb instances all try to interact with the terminal together.

Reviewed By: wez

Differential Revision: D3459575

fbshipit-source-id: 1359735a391e93a332a4c673c6525ad44034cc73
2016-07-25 15:14:33 -07:00
Adam Simpkins
98db6e0e01 make sure to close the thrift socket
Summary:
Update the CLI to always close the thrift client socket, to avoid resource leak
warnings on exit.

I also updated the code to just monkey-patch a nicer EdenError.__str__()
method, rather than having to explicitly catch and modify this exception in
multiple different places.

Reviewed By: bolinfest

Differential Revision: D3560662

fbshipit-source-id: 900fe74c793ffd99f4a2c1f1ddd94b96e48f5eb7
2016-07-22 17:33:05 -07:00
Adam Simpkins
90e1a87409 improvements to the repository command
Summary:
The "eden repository <name> <path>" command had a bug that it would duplicate
the existing edenrc contents when writing out a new config: it opened the file
in append mode rather than truncate mode when performing the write.

This addresses that issue, but also does a bigger overhaul of the config update
code.  We now acquire a lock for the duration of the modification, so that
another eden CLI process cannot modify the file between when we read it and
when we write out our modifications.  We also perform the write using an atomic
rename so the file contents are always valid at all points in time.

I also updated the CLI command to print the repositories in sorted order, and
to only catch expected exceptions, and show backtraces for unexpected errors.

Reviewed By: bolinfest

Differential Revision: D3554550

fbshipit-source-id: 5920ccb2447330673eac3f9956a8ae5d8a66a67e
2016-07-22 17:33:00 -07:00
Michael Bolin
f6b4d69455 Create the destination of the clone if it does not already exist.
Summary:
For consistency with `git clone`, the destination path must be either:
* non-existent (but `mkdir -p`-able)
* an empty directory
Or else `clone` should fail.

In the process of writing the integration test, I cleaned up some of our test infra
and took advantage of the fact that we require Python 3 (I believe 3.5) now:
* We now use `subprocess.run()` instead of `subprocess.check_output()`.
* Removed the `client_name` argument to `EdenClient.init()` because that is no longer the right terminology and no one appeared to be overriding the default, anyway.
* `EdenClient.clone_cmd()` no longer calls `os.mkdir(self._mount_path)` because that was papering over the issue this revision is trying to solve.

Reviewed By: simpkins

Differential Revision: D3526909

fbshipit-source-id: 66b5799a1b47a51468faf5dc17d87a385926dc89
2016-07-11 18:28:10 -07:00
Caren Thomas
20915e20aa only add mount path to directory map if clone is successful
Summary: Move adding the mount path to the directory map as the final step of the clone command so that the path is only documented if the mount is actually successful. Previously, if 'eden clone' failed during the mounting, another call to 'eden clone' to try again would fail with 'Error: mount path NAME already exists.' This change ensures that a second call to 'eden clone' will actually try again if the first failed.

Reviewed By: simpkins

Differential Revision: D3543388

fbshipit-source-id: be6412ad6d5d009bd87ad6e0b4110b35e6300fcb
2016-07-11 13:15:03 -07:00
Caren Thomas
e6bbd1e098 fix exception messages
Summary: This change fixes exception messages so that they all match the same format and don't include 'error: ' twice

Reviewed By: simpkins

Differential Revision: D3544034

fbshipit-source-id: 32d600c712d1782d2a1a35331b66e06a842ed8e0
2016-07-11 13:07:21 -07:00
Caren Thomas
a4d869b95f ensure that eden repository can't create multiple entries with the same name
Summary: Fix a bug with the eden repository command that let it add multiple repositories with the same name. If an entry for repository 'name' already exists in the home ~/.edenrc config file, the eden repository command will now raise an error message saying that the repository already exists. Note that if an entry for repository 'name' exists in any of the global /etc/eden/config.d/* files, the eden repository command will still allow the user to create the new repository and will add an entry for 'name' to the home ~/.edenrc config file (since entries in home config file overwrite those in global)

Reviewed By: wez

Differential Revision: D3529743

fbshipit-source-id: b7c7ceef6ef38fcd3b4ff9a92fbd23a4a0bd6951
2016-07-07 19:11:04 -07:00
Caren Thomas
1080dbc13c replace os.makedirs with mkdir_p
Summary: Move the _get_or_create_dir() method from config.py to util.py and rename as mkdir_p(). This change replaces all of the os.makedirs call sites with the new mkdir_p() method.

Reviewed By: bolinfest

Differential Revision: D3512570

fbshipit-source-id: a867049f9af22076934390061f09070bf9ee6397
2016-07-06 16:15:50 -07:00
Caren Thomas
96a63ff972 restructure eden directory
Summary:
These changes restructure the eden directory so that 'client' directories are created during the `eden clone` command and are associated with a single mount path.
The new eden directory looks as follows:
  ~/.eden
      config.json
      clients/
          abcd08d/
              edenrc
              SNAPSHOT
              overlay/
          efgh19i/
              edenrc
              SNAPSHOT
              overlay/
              ...

Where the config.json file holds the mapping of mount paths to their respective client directory which is a hash, and the edenrc files in each client directory is an INI file which holds the name of repository associated with the mount path. This INI file follows the current format:
    [repository]
    name = fbsource

This restructuring required a couple other changes:
- unmount command now cleans up the client directory and removes the mapping of its mount path from config.json
- eden list command now lists all of the mount paths rather than the client names

Reviewed By: bolinfest

Differential Revision: D3506119

fbshipit-source-id: dc07a8baf1052be731ff335d9cf74a07ab8e661a
2016-07-06 16:15:50 -07:00
Caren Thomas
ad7f71f0b4 update ClientConfig class to parse INI file
Summary: Change the ClientConfig class to parse client data via INI config file rather than json file. This class uses boost::property_tree::ini_parser and the ptree data structure to hold the parsed INI file contents. This change makes it possible for eden to no longer rely on json files for getting client data, and the json files will be completely taken out in a separate diff.

Reviewed By: bolinfest

Differential Revision: D3498567

fbshipit-source-id: 3298047a014beda0c250475c0809a7a1ebd95b2b
2016-07-06 16:15:50 -07:00
Caren Thomas
05c63233c4 move snapshot update to clone command
Summary: Previously the repo snapshot id was collected and stored when the repository was initialized, but this diff moves the update to the clone command so now the snapshot is only stored right before a repository is mounted.

Reviewed By: bolinfest

Differential Revision: D3489550

fbshipit-source-id: 1271c1d7c7709ed332307a636c23e26e913483c9
2016-07-06 16:15:49 -07:00
Caren Thomas
5d7b826b19 change unmount to use mount path as arg
Summary: Update the unmount command to use the mount point rather than the client name. This diff also removes the mount command completely since tests are no longer dependent on it.

Reviewed By: bolinfest

Differential Revision: D3489290

fbshipit-source-id: 9bfbcb78a78d1593f6d0950502bdd4a55e3e6ca4
2016-07-06 16:15:49 -07:00
Caren Thomas
c9779be011 add 'eden clone' command
Summary: Introduce new 'clone' command that takes in repo name and mount path. This command replaces the current mount command which uses the client name as an argument

Reviewed By: bolinfest

Differential Revision: D3489098

fbshipit-source-id: 719fb94387da1d4ccab770a0e659f717888a7dc6
2016-07-06 16:15:49 -07:00
Caren Thomas
ce44a06b80 add repository command
Summary: Expand functionality of repository command to also create repositories. The current command line format is 'eden repository <name> <path>' and will soon replace the existing init command.

Reviewed By: bolinfest

Differential Revision: D3489064

fbshipit-source-id: 3e6946cbd80a64ad23b52383f3f14a92d4492a21
2016-07-06 16:15:49 -07:00
Caren Thomas
86238c4098 add simple eden repository command
Summary: Add a simple eden repository command that takes no arguments. The behavior mimics that of git remote and lists all repositories by parsing both the global and local INI config files. The INI file currently needs to be manually added and updated to maintain information about existing repositories.

Reviewed By: bolinfest

Differential Revision: D3479543

fbshipit-source-id: b0d36f33c9b8e0c7b9fe20ec2f362ca15c0adeb8
2016-07-06 16:15:49 -07:00
Wez Furlong
892e0bd07d eden: when launching via sudo, use a helper launcher if available
Summary:
This is a bit ugly and longer term should probably be an
eden configuration that we deploy to our CI tier.

In our CI environment we don't allow unfettered password-less sudo
access and instead must launch privileged processes via a helper
process that is whitelisted.  D3524299 has the definition of that
helper as it applies to our internal infra.

Reviewed By: bolinfest

Differential Revision: D3524373

fbshipit-source-id: f36bf29e6b455220c434b681a6d0d551bc21ecab
2016-07-06 16:09:28 -07:00
Michael Bolin
911b0bde9b Update _find_default_daemon_binary() because the binary is always named edenfs.
Reviewed By: simpkins

Differential Revision: D3492527

fbshipit-source-id: b74859ebd2cfac55568bdb170a863d78607ad108
2016-06-28 11:02:05 -07:00
Caren Thomas
35add0f007 change eden cli to run with python 3
Summary: Update eden/fs/cli directory to run with Python 3.

Reviewed By: simpkins

Differential Revision: D3479252

fbshipit-source-id: 3e3dc023fc54e99b7839a1a4dc8605dd7ef2d8a3
2016-06-27 11:59:24 -07:00
Adam Simpkins
142aba2058 add repository helper functions in the integration tests
Summary:
Start adding utility code to make it easier for the integration tests to
manipulate git and mercurial repositories.

This adds an HgRepository class, but does not update the tests to use it yet.
I will do that in a separate diff.

Reviewed By: bolinfest

Differential Revision: D3449328

fbshipit-source-id: caea5befb683a388cbad30a29017c566e22702af
2016-06-20 13:40:02 -07:00
Adam Simpkins
c51e282dfb import git objects on demand
Summary:
This moves git import logic from the GitImporter class to GitBackingStore.
The logic is simpler now, since GitBackingStore only needs to import a single
Tree or Blob at a time.

Reviewed By: bolinfest

Differential Revision: D3448752

fbshipit-source-id: da2d59f953ada714d8512545ae83dd48e5d3e410
2016-06-20 11:45:09 -07:00
Adam Simpkins
94a26b5503 improvements to the daemon and shutdown commands
Summary:
- Update "eden daemon" to wait until edenfs is healthy before returning.
- Accept additional command line arguments and pass them through to edenfs.
- When starting edenfs as a background daemon, direct stdout and stderr to a
  log file in the eden config directory.
- Update "eden shutdown" command to wait for edenfs to exit.
- Update "eden shutdown" command to print an error message if edenfs was not
  running.

Reviewed By: bolinfest

Differential Revision: D3446403

fbshipit-source-id: 2ca1874256b7d124a85092b886548bea8c198327
2016-06-17 15:12:48 -07:00
Adam Simpkins
cbb493f716 support running in the foreground, and improve test cleanup
Summary:
This adds a --foreground flag to the "eden daemon" command, which causes the
daemon to run in the foreground, rather than daemonizing as a background
process.  Additionally, this drops the --preserve-environment flag and instead
updates the CLI to always build a sane environment to run with.

This also updates the integration test code to use this flag, and wait for eden
to shut down during test clean up.  Without this, the test case code could try
to clean up temporary directories before they were unmounted, which would fail.
This would leave many temporary directories behind after test runs.

This also re-organizes the temporary directory set up a bit, so that each test
uses a single top-level temporary directory.  All other directories it creates
are put inside this one directory.

Reviewed By: bolinfest

Differential Revision: D3439232

fbshipit-source-id: 85305f7db60da6bae589d28c802ee260e42e4dea
2016-06-16 12:44:06 -07:00
Michael Bolin
26403df852 Exclude the cpp_binary for the daemon from the python_binary for the CLI.
Summary:
This changes the way that Eden is built and deployed.

* To build the binary that must be run as `root` (but quickly drops privileges), run `buck build eden-daemon`.
* To build the CLI that communicates with the daemon (and does not require privileges), run `buck build eden-cli`.
* To build both, run `buck build eden`.

There is an example of how to build the various parts of Eden using
Buck and how to package them up in the `install` script introduced by this revision.

While here, I also cleaned up some of our build files and changed them to be
parameterized between internal and external use. In both cases, the user gets the
"unadorned" version of their primary build targets. This ensures that shortcuts such as:

```
buck test eden/fs/integration
```

do the right thing by default.

Finally, I also made `find_default_config_dir()` and `find_default_daemon_binary()`
lazy whereas `find_default_config_dir()` was previously eager.

Reviewed By: simpkins

Differential Revision: D3436245

fbshipit-source-id: 4dfbd59ed0d198620324f0705c462334bb5a7daf
2016-06-15 17:07:58 -07:00
Adam Simpkins
346a4cdc4e fix CLI issues initializing mercurial mount points
Summary:
The _get_hg_dir() function had an incorrect return statement caused "eden init"
to fail with mercurial repositories, unless the path pointed to a shared
working directory.

Also update the code to store the path to the mercurial repository, rather than
the path to the .hg directory.  Unlike git, mercurial requires the repository
path itself, and refuses to work if given a path to the .hg directory.

Reviewed By: bolinfest

Differential Revision: D3409808

fbshipit-source-id: 22ee7748422b614f5af57aff07fcfa517af846d9
2016-06-13 15:16:29 -07:00
Michael Bolin
11169bcf95 Add an eden shutdown command.
Summary:
This revision introduces two complementary changes:
* `eden daemon` no longer runs in the foreground.
* There is now an `eden shutdown` command to kill the daemon.

When `shutdown` is called, it tells the Thrift server to shutdown.
In turn, this causes `EdenServer::runThriftServer()` to exit,
which causes `EdenServer::run()` to exit.

Reviewed By: simpkins

Differential Revision: D3402347

fbshipit-source-id: 80032ba53eb69b3f69bef9d7cd169f93500c833c
2016-06-10 14:16:09 -07:00
Michael Bolin
7a48628bb8 Create dot eden folder if it does not already exist when running eden daemon.
Summary:
Previous to this change, if `~/local/.eden` did not exist when `eden daemon` was
run, then it would fail.

Now the logic to create `~/local/.eden` is encapsulated in `_ensure_dot_eden_folder_exists()`.
We do not call this for all subcommands because we want to make sure that running
`eden --help` does not have the side-effect of writing `~/local/.eden` if it does not exist.

Reviewed By: wez

Differential Revision: D3397057

fbshipit-source-id: a3f974f367058d9e4ebd515c78423e54edc179cc
2016-06-07 13:03:13 -07:00
Michael Bolin
5e69f112eb Add an eden health subcommand.
Summary:
`eden health` will return with exit code 0 if both of the following are true:

* The Thrift client is up and running.
* The status of the client is either ALIVE or STARTING.

Reviewed By: wez

Differential Revision: D3395582

fbshipit-source-id: ba668d26acae73a51fbae8aca2b4979156c0c50f
2016-06-07 13:03:13 -07:00
Michael Bolin
1391f7725c Fix some Python lint warnings.
Reviewed By: simpkins

Differential Revision: D3394466

fbshipit-source-id: 3dd670785e0eb2586ed38be87e74caeb3262966b
2016-06-06 21:01:03 -07:00
Adam Simpkins
bff4754bfe ignore EPERM errors when trying to kill eden
Summary:
When running the CLI "daemon" command, we try killing the underlying eden
process group when we receive SIGTERM or SIGINT.  (We really only want to kill
the main eden process, but we currently have to kill the entire process group
due to how sudo works.)

Since the privhelper process runs as root and is part of this process group, we
can get an EPERM error back.  This was causing the CLI to fail with an
unhandled exception backtrace.  This diff updates the code to ignore EPERM.

Reviewed By: bolinfest, wez

Differential Revision: D3384121

fbshipit-source-id: 39b2364d8c921b1d84a8902566fe9af2a370e4e5
2016-06-06 13:01:58 -07:00
Caren Thomas
203be051a1 add unmount parser and wrapper functions
Summary: Updated python CLI to include subparser for unmount command and added wrapper functions that hand over execution to privhelper process. Unmount currently requires client_name at the command line.

Reviewed By: simpkins

Differential Revision: D3359517

fbshipit-source-id: ff05e90bcdb96ecad63f37634c69dbeef429c90f
2016-05-27 17:41:07 -07:00
Michael Bolin
6e4cb1ebf1 Refactor logic to create a EdenService.Client in Python.
Summary: This logic should be shared by the Eden CLI as well as unit tests.

Reviewed By: simpkins

Differential Revision: D3348300

fbshipit-source-id: c87b1f03f16560323f3d7685063bb6466c39efe2
2016-05-25 21:44:07 -07:00
Adam Simpkins
98dcc73503 initial CLI support for creating hg mounts
Summary:
Update the CLI to support running "init" with a mercurial repository.

This is just some bare bones framework code at the moment.  It doesn't actually
import any data from mercurial at the moment, and mounting doesn't work.

Reviewed By: bolinfest, wez

Differential Revision: D3345426

fbshipit-source-id: 72c31ac8d2aac2a16e0a7d6f0425eb4ca218d487
2016-05-25 13:15:01 -07:00
Wez Furlong
deaf75a6b6 eden: init: require --mount and --repo options
Summary: This avoids an ugly error when --mount isn't passed.

Reviewed By: bolinfest

Differential Revision: D3302970

fbshipit-source-id: e60475e6b94fb4228e75fb392fb472886274aa0a
2016-05-17 18:17:11 -07:00
Facebook Github Bot 8
83f42a9fa6 Include build files that were inadvertently excluded from the initial export.
fbshipit-source-id: 2c76f0d5e55d84859ad9f4841cbe6994a62446f8
2016-05-12 16:08:34 -07:00
Facebook Github Bot 5
2eeea32117 Initial commit
fbshipit-source-id: 2bcefbd0cd127cc5ea982e074ea6819d7aac3d7a
2016-05-12 14:09:13 -07:00