Skip to content

Commit cc26ffe

Browse files
Alramechmeta-codesync[bot]
authored andcommitted
Add debug logging to eden chown
Summary: # Context test_chown_with_bindmount is failing on test runners, but not locally. https://www.internalfb.com/intern/test/562950217315212?ref_report_id=0 Print out the results of calling sudo chown to help debug. My suspicion is that there might be limited sudo on the test runner, and this will help confirm that. eg. This test fails on ondemands. Sudo will return the following error, which was previously silent. ``` ## ## IMPORTANT! ## ## On Demand instances have very limited 'sudo' access. ## ## * Run 'sudo -l' to see the list of commands you can run. ## ## * If a password prompt appears, press Ctrl+C to cancel. Your ## password will NOT work at this prompt. This means On Demand ## does not allow running that command via sudo. ## ## For more information, see https://fburl.com/ondemandsudo ``` Reviewed By: vilatto Differential Revision: D91076412 fbshipit-source-id: f1983e9394acec8e2ecf824325a523981adc8e89
1 parent 5a48929 commit cc26ffe

2 files changed

Lines changed: 33 additions & 5 deletions

File tree

eden/fs/cli/main.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,6 +1432,12 @@ def setup_parser(self, parser: argparse.ArgumentParser) -> None:
14321432
default=False,
14331433
help="Are redirections also chowned",
14341434
)
1435+
parser.add_argument(
1436+
"--verbose",
1437+
action="store_true",
1438+
default=False,
1439+
help="Add more info to the output, such as the output of the chown sub-calls",
1440+
)
14351441

14361442
def resolve_uid(self, uid_str: str) -> int:
14371443
try:
@@ -1472,15 +1478,37 @@ def run(self, args: argparse.Namespace) -> int:
14721478
).values():
14731479
target = redir.expand_target_abspath(checkout)
14741480
print(f"Chowning redirection: {redir.repo_path}...", end="", flush=True)
1475-
subprocess.run(["sudo", "chown", "-R", f"{uid}:{gid}", str(target)])
1476-
subprocess.run(
1481+
result1 = subprocess.run(
1482+
["sudo", "chown", "-R", f"{uid}:{gid}", str(target)],
1483+
capture_output=True,
1484+
text=True,
1485+
)
1486+
if args.verbose:
1487+
print(f"\nChowning target: {str(target)}")
1488+
print("stdout:")
1489+
print(result1.stdout)
1490+
if result1.stderr:
1491+
print("stderr: ")
1492+
print(result1.stderr)
1493+
1494+
result2 = subprocess.run(
14771495
[
14781496
"sudo",
14791497
"chown",
14801498
f"{uid}:{gid}",
14811499
str(checkout.path / redir.repo_path),
1482-
]
1500+
],
1501+
capture_output=True,
1502+
text=True,
14831503
)
1504+
if args.verbose:
1505+
print(f"Chowning repo path: {checkout.path / redir.repo_path}")
1506+
print("stdout:")
1507+
print(result2.stdout)
1508+
if result2.stderr:
1509+
print("stderr:")
1510+
print(result2.stderr)
1511+
14841512
print("done")
14851513

14861514
return 0

eden/integration/chown_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def assert_chown_worked(self, mount: str) -> None:
7878
def run_chown(self, mount: str, use_ids: bool = False) -> None:
7979
if use_ids:
8080
output = self.eden.run_cmd(
81-
"chown", mount, str(self.nobody_uid), str(self.nobody_gid)
81+
"chown", mount, str(self.nobody_uid), str(self.nobody_gid), "--verbose"
8282
)
8383
else:
84-
output = self.eden.run_cmd("chown", mount, "nobody", "nobody")
84+
output = self.eden.run_cmd("chown", mount, "nobody", "nobody", "--verbose")
8585
print(output)
8686

8787
def test_chown(self) -> None:

0 commit comments

Comments
 (0)