Commit Graph

24 Commits

Author SHA1 Message Date
Lukasz Langa
deee232d74 Upgrade to 18.5b1
Summary: Mostly empty lines removed and added.  A few bugfixes on excessive line splitting.

Reviewed By: cooperlees

Differential Revision: D8198776

fbshipit-source-id: 4361faf4a2b9347d57fb6e1342c494575f2beb67
2018-05-30 01:11:47 -07:00
Wez Furlong
eb052bb5c4 eden: eden daemon -> eden start in eden doctor
Summary: Notice this while checking something for a new hire yesterday.

Reviewed By: bolinfest

Differential Revision: D8119130

fbshipit-source-id: 8a27797061b2316c62f72e34c9f20130d97dc2b1
2018-05-23 09:17:40 -07:00
Lukasz Langa
bf7f0a79b8 Reformat already opted in directories with Black Beta @allow-large-files
Summary:
This is stacked on top of Black 18.5b0.

allow-large-files

Reviewed By: carljm

Differential Revision: D8061834

fbshipit-source-id: 92e3645e159b60d77cf7e0bec64a8262ca4e88c2
2018-05-18 23:07:24 -07:00
Wez Furlong
c83849e5af enable Black python formatting and apply to eden
Summary: No functional changes

Reviewed By: simpkins

Differential Revision: D7945989

fbshipit-source-id: e267e6134d87570427b3fdf5974006dce5774113
2018-05-09 21:37:07 -07:00
Michael Bolin
9d849ca35c Catch subprocess.CalledProcessError instead of OSError in eden doctor.
Summary:
Before I fixed an issue with `nuclide-connections` in D7833410, it could throw
an error. Although there was a try/except around the `check_output` call in
`eden doctor`, it caught `OSError` rather than `CalledProcessError`, which
seems like a mistake (or maybe an inadvertent evolution of the code).

While there, I also extended it to catch `ValueError` in case the stdout of the
subprocess is not valid JSON, in which case `json.loads()` will raise a
`ValueError`.

Reviewed By: chadaustin

Differential Revision: D7890571

fbshipit-source-id: 184f6f669e9d62a5fb04db29bcbab450defc226e
2018-05-07 11:24:20 -07:00
Michael Bolin
d2e6ed4077 Colorize eden doctor output when attached to a tty.
Summary:
For sure, there is still more we can do to improve the output of `eden doctor`
to make it easier to scan, but I thought some color to classify the status
would be helpful. With this change, `eden doctor`:

* Prints green when no issues are encountered.
* Prints red when there are issues that could not be fixed.
* Prints yellow when there were issues that were fixed.
* Prints yellow when there were issues that were not fixed because it was a dry run.

In making this change, I took `StdoutPrinter` from `eden/cli/debug.py` and moved
it into its own file, `eden/cli/stdout_printer.py`. While there, I introduced an
`AnsiEscapeCodes` class that can be passed to the constructor of `StdoutPrinter`
so the client can specify its own ANSI escape codes. The unit test uses these to
ensure the test output will be the same independent of the value of
`sys.stdout.isatty()` when the test is run.

Reviewed By: chadaustin

Differential Revision: D7890525

fbshipit-source-id: a95ff8c1685b48c2d239923cf08456ec6de757fe
2018-05-07 11:24:20 -07:00
Adam Simpkins
c21571f23a fix eden doctor to avoid interfering with other edenfs instances
Summary:
Only treat edenfs mount points as stale if attempting to access them fails with
ENOTCONN.  If we can successfully access the mount point then it cannot be
stale and does not need to be unmounted.

This prevents `eden doctor` from incorrectly unmounting mount points owned by
another edenfs process running on this system.

Reviewed By: bolinfest

Differential Revision: D7683503

fbshipit-source-id: 412cc17442fac1e8030dd40de0e0f642c15d1253
2018-04-25 17:06:59 -07:00
Adam Simpkins
0a2630c56a update eden doctor to recommend running eden restart
Summary:
Recommend using `eden restart` to restart edenfs, rather than running
`eden daemon`.

Reviewed By: akushner

Differential Revision: D7683502

fbshipit-source-id: ebb8571f3647ce1405830381deada0288972a999
2018-04-19 19:14:19 -07:00
Michael Bolin
2104ea3389 Update eden doctor to use nuclide-connections
Summary:
In practice, we have received a number of user reports where Nuclide had lost
track of its Watchman subscriptions and `eden doctor` failed to report it.

When the `NuclideHasExpectedWatchmanSubscriptions` check was first added to
`eden doctor`, in the repro case we had, it seemed that Nuclide would lose its
`filewatcher-<root-folder>` subscription, but would retain its
`hg-repository-watchman-subscription-primary` subscription. As such, we encoded
a heuristic where the presence of the `hg-repository-watchman-subscription-primary`
subscription without the accompanying `filewatcher-<root-folder>` subscription
was taken as a sign that (1) the user was connected to the directory via
Nuclide and (2) Nuclide's Watchman subscriptions had gotten corrupted.

Unfortunately, this was not a sufficient heuristic because it would not detect
the error case where Nuclide had lost //all// of its Watchman subscriptions!
Because `eden doctor` did not flag this, users kept using Nuclide even though
things were in a bad state, sometimes losing data as a result.

To fix that, we introduced a new tool, `nuclide-connections`, in D7598900. This
executable prints the list of local folders used as root folders in Nuclide
clients connected to the local Nuclide server. Now we no longer have to rely on
the presence of the `hg-repository-watchman-subscription-primary` Watchman
subscription as a proxy for a Nuclide connection.

This commit updates the `NuclideHasExpectedWatchmanSubscriptions` check in
`eden doctor` to use `nuclide-connections`. For every Nuclide connection that is
also an Eden mount, it verifies that the expected Watchman subscriptions exist.

As noted in the TODO in `NuclideHasExpectedWatchmanSubscriptions`, this
check is a bit brittle, but it is intended as a stopgap until we find the root cause
of the missing Watchman subscriptions and fix it.

Reviewed By: simpkins

Differential Revision: D7663214

fbshipit-source-id: 200b78ce25010222e59f3296f2412161086aa7ce
2018-04-18 18:09:01 -07:00
Chad Austin
e9765e7c37 have eden doctor unmount unconnected mounts
Summary:
If we fail to lstat a mount because the FUSE daemon is
unconnected, go ahead and unmount it.

Reviewed By: simpkins

Differential Revision: D6848115

fbshipit-source-id: df797b15956db24c4ac87dc6d4cd0a7177dd20ef
2018-01-31 11:48:21 -08:00
Chad Austin
7a909f6168 avoid a crash in eden doctor if any active mounts are unconfigured
Summary:
My stale mounts check regressed eden doctor's handling of
unconfigured mounts.  For now, just skip them, and add a test that
eden doctor doesn't crash.

Reviewed By: simpkins

Differential Revision: D6801445

fbshipit-source-id: 65d2f9028af651ef487a7ce6c334f387b541492d
2018-01-25 15:14:58 -08:00
Chad Austin
916f069b91 bring back eden doctor's stale mounts check - filter by st_uid and st_dev instead of path
Summary:
The prior implementation of StaleMountsCheck filtered by path
and did not correctly handle seeing the same FUSE mount multiple times
in the mount table. This occurred when an Eden mount was created
underneath a bind mount.

Now it only unmounts mounts where st_dev does not match the st_dev of
any active mounts, and where st_uid matches the current user.

Reviewed By: simpkins

Differential Revision: D6787618

fbshipit-source-id: 24e0f156cb74822500d91205349c0e6638c0340c
2018-01-25 15:14:58 -08:00
Chad Austin
7ad29f79d4 temporarily disable the StaleMountsCheck - it's unmounting active mounts
Summary:
bolinfest has observed `eden doctor` unmounting active mounts, so disable
that check until this is resolved.

Reviewed By: bolinfest

Differential Revision: D6768284

fbshipit-source-id: 21add1fa283f8631055019dae99819d04e179d5e
2018-01-20 10:35:20 -08:00
Wez Furlong
ff7cf0e6a0 have doctor suggest running a takeover restart
Summary: as above

Reviewed By: bolinfest

Differential Revision: D6763283

fbshipit-source-id: 8963d35e7f34d9d764e166a156faea7c34e999e4
2018-01-19 14:51:36 -08:00
Chad Austin
b6b2a08998 unmount stale edenfs mounts in eden doctor
Summary:
If the Eden process dies or malfunctions, it's possible to end up with stale
edenfs mounts on the system.  Change `eden doctor` to correct them.

Reviewed By: simpkins

Differential Revision: D6659193

fbshipit-source-id: d9fcf2e68663295e4f43b2c11fd4503a1dfac038
2018-01-19 11:06:51 -08:00
Sergey Zhupanov
6ae3b840f8 Added --version implementation to eden.
Summary:
Added --version to main.py, including -v and version.
It prints both installed and running version (as per Wez's suggestion), and accounts for the possibilities that eden may not be running at all, or dev version may be running.

Reviewed By: wez

Differential Revision: D6724204

fbshipit-source-id: 5085f53a00a557f759a23fe41fb57189c9ad6a7e
2018-01-18 15:48:17 -08:00
Sergey Zhupanov
0b4fea5374 change eden clone to check out master commit in both git and hg.
Summary:
Changed `eden clone` to check out master commit in both git and hg.
Previously, it checked out the current commit for the repo.

Reviewed By: simpkins

Differential Revision: D6663754

fbshipit-source-id: 92b185ccca5d082dc2bde9c8b191c82a2a4f06b4
2018-01-13 14:26:32 -08:00
Chad Austin
b0fac29b0b enable python typechecking from buck
Summary: Turn on check_types for CLI's python_binary.

Reviewed By: simpkins

Differential Revision: D6668636

fbshipit-source-id: abde1e1cedf2a5104cdaa5433377b1d2adc372fd
2018-01-08 12:10:19 -08:00
Michael Bolin
1cfec17294 Do not run the EdenfsIsLatest eden doctor check when Eden is not running.
Summary: Previously, this would cause a crash when running `eden doctor`. Now fixed.

Reviewed By: simpkins

Differential Revision: D6607211

fbshipit-source-id: a0e077beaf6b7031d57efd72b947e90884369852
2017-12-19 21:50:09 -08:00
Michael Bolin
88d4e2e546 Use correct argument: --queryformat instead of --queryfmt.
Summary:
When I updated D6577031 in response to code review feedback,
I manually tested with `--qf` but at the last minute changed to the
suggested long-form `--queryfmt` without verifying it was the
appropriate name.

Reviewed By: simpkins

Differential Revision: D6579002

fbshipit-source-id: ac2a96e7340099eb83336cb11d16dd711b0d4f9f
2017-12-15 13:06:21 -08:00
Michael Bolin
aa87671ff9 Fix a string vs. bytes issue in Python.
Summary:
I forgot that `subprocess.check_output()` returns a `bytes` instead of a `str`.
This caused `eden doctor` to return false positives because the installed and
running versions of `edenfs` would be the same, but the check would fail because
it was comparing a `bytes` to a `str`.

Reviewed By: simpkins

Differential Revision: D6577031

fbshipit-source-id: 681ea22ef79604a3dfb278d713e5c68c54d8ecd5
2017-12-15 00:20:15 -08:00
Michael Bolin
b9cff8cf88 eden doctor check to verify that the running Eden matches the installed Eden.
Reviewed By: chadaustin

Differential Revision: D6565974

fbshipit-source-id: eb02615437b860db9507b6f455717350a67f89ee
2017-12-14 21:18:14 -08:00
Michael Bolin
f972117076 Fix a bug in eden doctor.
Summary:
In the initial implementation of `eden doctor`, if you had a mount point like:

    /data/users/mbolin/eden-fbsource

then it looked for a pair of Watchman subscriptions for
`/data/users/mbolin/eden-fbsource` with the names:

    hg-repository-watchman-subscription-primary
    filewatcher-/data/users/mbolin/eden-fbsource

as a heuristic that Nuclide was being used to edit files in that Eden mount.

However, if the user is using Nuclide to edit files in a subdirectory of that
Eden mount (as determined by the Nuclide connection profile), then the
subscriptions look like this:

    hg-repository-watchman-subscription-primary
    filewatcher-/data/users/mbolin/eden-fbsource/<path-to-subdirectory>

In this case, `eden doctor` was returning a false positive because it thought
that the `filewatcher-/data/users/mbolin/eden-fbsource` subscription was missing
when in fact everything was just fine.

This revision changes the logic to look for a subscription to the root or one of
its subdirectories.

(Note: this ignores all push blocking failures!)

Reviewed By: simpkins

Differential Revision: D6467113

fbshipit-source-id: bfe5fafaa388405f2e59e61315c5a2084c8adc56
2017-12-01 18:49:56 -08:00
Michael Bolin
7cb7607b94 Introduce eden doctor.
Summary:
`eden doctor` is a new subcommand that attempts to diagnose
issues with Eden and autofix them, as appropriate. There is also
a `--dry-run` flag that will tell the user about issues without attempting
to fix them.

Initially, `eden doctor` checks for the following:
- If Watchman has an `inotify` watcher, `eden doctor` identifies this and
  will attempt to replace it with an `eden` watcher.
- If there are some active Watchman subscriptions that appear to come
  from Nuclide, warn the user if the mission-critical `filewatcher-` subscription
  that watches the entire repo is missing.
- If p1 in `SNAPSHOT` and `.hg/dirstate` do not match, warn the user.

The code for `eden doctor` is organized so that it should be relatively
easy to add new conditions to check for going forward. Admittedly, the
UX could be better by formatting the output (color, boldness, etc.) to
make certain information stand out, but we can improve that in
subsequent revisions.

Note that I had to do a bit of cleanup in `eden/cli/TARGETS` as part of
this revision and I created `eden/cli/test/TARGETS` so the tests have
their own build file.

Reviewed By: chadaustin

Differential Revision: D6446057

fbshipit-source-id: ae23c5996dba4f7f70f118179e5556efc29c31c3
2017-12-01 11:21:30 -08:00