Skip to content

Commit 61acc42

Browse files
muirdmmeta-codesync[bot]
authored andcommitted
Back out "remove recas backing store"
Reviewed By: zzl0 Differential Revision: D88781365 fbshipit-source-id: fc8c945925af31deeefdee29d1098fbfa28ccc24
1 parent 28deeb3 commit 61acc42

13 files changed

Lines changed: 111 additions & 6 deletions

File tree

eden/fs/cli/config.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"git": "refs/heads/master",
105105
"hg": "first(present(master) + .)",
106106
"filteredhg": "first(present(master) + .)",
107+
"recas": "",
107108
"http": "",
108109
}
109110

@@ -221,6 +222,7 @@ class CheckoutConfig(typing.NamedTuple):
221222
predictive_prefetch_num_dirs: int
222223
enable_sqlite_overlay: bool
223224
use_write_back_cache: bool
225+
re_use_case: str
224226
enable_windows_symlinks: bool
225227
inode_catalog_type: Optional[str]
226228
off_mount_repo_dir: bool
@@ -1493,6 +1495,9 @@ def save_config(self, checkout_config: CheckoutConfig) -> None:
14931495
"predictive-prefetch": {
14941496
"predictive-prefetch-active": checkout_config.predictive_prefetch_profiles_active,
14951497
},
1498+
"recas": {
1499+
"use-case": checkout_config.re_use_case,
1500+
},
14961501
}
14971502

14981503
if checkout_config.predictive_prefetch_num_dirs:
@@ -1645,6 +1650,12 @@ def get_field(key: str) -> str:
16451650
if not isinstance(use_write_back_cache, bool):
16461651
use_write_back_cache = False
16471652

1653+
re_use_case = "buck2-default"
1654+
recas = config.get("recas")
1655+
if recas is not None:
1656+
if recas.get("use-case") is not None:
1657+
re_use_case = str(recas.get("use-case"))
1658+
16481659
enable_windows_symlinks = repository.get("enable-windows-symlinks")
16491660
if not isinstance(enable_windows_symlinks, bool):
16501661
enable_windows_symlinks = False
@@ -1697,6 +1708,7 @@ def get_field(key: str) -> str:
16971708
predictive_prefetch_num_dirs=predictive_num_dirs,
16981709
enable_sqlite_overlay=enable_sqlite_overlay,
16991710
use_write_back_cache=use_write_back_cache,
1711+
re_use_case=re_use_case,
17001712
enable_windows_symlinks=enable_windows_symlinks,
17011713
inode_catalog_type=inode_catalog_type,
17021714
off_mount_repo_dir=off_mount_repo_dir,
@@ -2216,6 +2228,7 @@ def get_repo_info(
22162228
case_sensitive: bool,
22172229
overlay_type: Optional[str],
22182230
backing_store_type: Optional[str] = None,
2231+
re_use_case: Optional[str] = None,
22192232
enable_windows_symlinks: bool = False,
22202233
off_mount_repo_dir: bool = False,
22212234
) -> Tuple[util.Repo, CheckoutConfig]:
@@ -2248,6 +2261,7 @@ def get_repo_info(
22482261
case_sensitive,
22492262
overlay_type,
22502263
backing_store_type=backing_store_type,
2264+
re_use_case=re_use_case,
22512265
enable_windows_symlinks=enable_windows_symlinks,
22522266
off_mount_repo_dir=off_mount_repo_dir,
22532267
)
@@ -2262,6 +2276,7 @@ def create_checkout_config(
22622276
case_sensitive: bool,
22632277
overlay_type: Optional[str],
22642278
backing_store_type: Optional[str] = None,
2279+
re_use_case: Optional[str] = None,
22652280
enable_windows_symlinks: bool = False,
22662281
off_mount_repo_dir: bool = False,
22672282
) -> CheckoutConfig:
@@ -2315,6 +2330,7 @@ def create_checkout_config(
23152330
predictive_prefetch_num_dirs=0,
23162331
enable_sqlite_overlay=enable_sqlite_overlay,
23172332
use_write_back_cache=False,
2333+
re_use_case=re_use_case or "buck2-default",
23182334
enable_windows_symlinks=enable_windows_symlinks,
23192335
inode_catalog_type=overlay_type,
23202336
off_mount_repo_dir=off_mount_repo_dir,

eden/fs/cli/doctor/test/lib/fake_eden_instance.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def create_test_mount(
144144
predictive_prefetch_num_dirs=0,
145145
enable_sqlite_overlay=True,
146146
use_write_back_cache=False,
147+
re_use_case="buck2-default",
147148
enable_windows_symlinks=False,
148149
inode_catalog_type=None,
149150
off_mount_repo_dir=False,

eden/fs/cli/main.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,17 @@ def setup_parser(self, parser: argparse.ArgumentParser) -> None:
462462
"--backing-store",
463463
help=(
464464
"Clone the path with a specified Backing Store implementation. "
465-
"Currently only supports 'filteredhg' (all), "
465+
"Currently only supports 'filteredhg' (all), 'recas' (Linux), "
466466
"and 'http' (Linux). Takes precedent over the inferred backing"
467467
"store type from the existing repository we're cloning from."
468468
),
469469
)
470470

471+
parser.add_argument(
472+
"--re-use-case",
473+
help="The Remote Execution use-case to use when --backing-store=recas",
474+
)
475+
471476
parser.add_argument(
472477
"--enable-windows-symlinks",
473478
action="store_true",
@@ -619,6 +624,7 @@ def is_nfs_default():
619624
args.case_sensitive,
620625
overlay_type=args.overlay_type,
621626
backing_store_type=args.backing_store,
627+
re_use_case=args.re_use_case,
622628
enable_windows_symlinks=enable_windows_symlinks,
623629
off_mount_repo_dir=instance.get_config_bool(
624630
"clone.off-mount-repo-dir",
@@ -664,6 +670,18 @@ def is_nfs_default():
664670
)
665671
return 1
666672

673+
elif args.backing_store == "recas":
674+
if sys.platform != "linux":
675+
print_stderr(
676+
"error: recas backing store was passed but this feature is only available on Linux"
677+
)
678+
return 1
679+
if args.rev is not None:
680+
commit = args.rev
681+
else:
682+
NULL_REVISION = "0" * 40
683+
# A special digest for RE CAS representing an empty folder
684+
commit = f"{NULL_REVISION}:0"
667685
elif args.backing_store == "http":
668686
if sys.platform != "linux":
669687
print_stderr(

eden/fs/cli/test/cli_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ def test_list_mounts_no_backing_repos(self) -> None:
9090
predictive_prefetch_num_dirs=0,
9191
enable_sqlite_overlay=False,
9292
use_write_back_cache=False,
93+
re_use_case="buck2-default",
9394
enable_windows_symlinks=False,
9495
inode_catalog_type=None,
9596
off_mount_repo_dir=False,
@@ -117,6 +118,7 @@ def test_list_mounts_no_backing_repos(self) -> None:
117118
predictive_prefetch_num_dirs=0,
118119
enable_sqlite_overlay=False,
119120
use_write_back_cache=False,
121+
re_use_case="buck2-default",
120122
enable_windows_symlinks=False,
121123
inode_catalog_type=None,
122124
off_mount_repo_dir=False,
@@ -144,6 +146,7 @@ def test_list_mounts_no_backing_repos(self) -> None:
144146
predictive_prefetch_num_dirs=0,
145147
enable_sqlite_overlay=False,
146148
use_write_back_cache=False,
149+
re_use_case="buck2-default",
147150
enable_windows_symlinks=False,
148151
inode_catalog_type=None,
149152
off_mount_repo_dir=False,
@@ -171,6 +174,7 @@ def test_list_mounts_no_backing_repos(self) -> None:
171174
predictive_prefetch_num_dirs=0,
172175
enable_sqlite_overlay=False,
173176
use_write_back_cache=False,
177+
re_use_case="buck2-default",
174178
enable_windows_symlinks=False,
175179
inode_catalog_type=None,
176180
off_mount_repo_dir=False,
@@ -198,6 +202,7 @@ def test_list_mounts_no_backing_repos(self) -> None:
198202
predictive_prefetch_num_dirs=0,
199203
enable_sqlite_overlay=False,
200204
use_write_back_cache=False,
205+
re_use_case="buck2-default",
201206
enable_windows_symlinks=False,
202207
inode_catalog_type=None,
203208
off_mount_repo_dir=False,
@@ -326,6 +331,7 @@ def test_list_mounts_no_state(self) -> None:
326331
predictive_prefetch_num_dirs=0,
327332
enable_sqlite_overlay=False,
328333
use_write_back_cache=False,
334+
re_use_case="buck2-default",
329335
enable_windows_symlinks=False,
330336
inode_catalog_type=None,
331337
off_mount_repo_dir=False,
@@ -353,6 +359,7 @@ def test_list_mounts_no_state(self) -> None:
353359
predictive_prefetch_num_dirs=0,
354360
enable_sqlite_overlay=False,
355361
use_write_back_cache=False,
362+
re_use_case="buck2-default",
356363
enable_windows_symlinks=False,
357364
inode_catalog_type=None,
358365
off_mount_repo_dir=False,
@@ -380,6 +387,7 @@ def test_list_mounts_no_state(self) -> None:
380387
predictive_prefetch_num_dirs=0,
381388
enable_sqlite_overlay=False,
382389
use_write_back_cache=False,
390+
re_use_case="buck2-default",
383391
enable_windows_symlinks=False,
384392
inode_catalog_type=None,
385393
off_mount_repo_dir=False,
@@ -499,6 +507,7 @@ def test_list_mounts_with_backing_repos(self) -> None:
499507
predictive_prefetch_num_dirs=0,
500508
enable_sqlite_overlay=False,
501509
use_write_back_cache=False,
510+
re_use_case="buck2-default",
502511
enable_windows_symlinks=False,
503512
inode_catalog_type=None,
504513
off_mount_repo_dir=False,
@@ -526,6 +535,7 @@ def test_list_mounts_with_backing_repos(self) -> None:
526535
predictive_prefetch_num_dirs=0,
527536
enable_sqlite_overlay=False,
528537
use_write_back_cache=False,
538+
re_use_case="buck2-default",
529539
enable_windows_symlinks=False,
530540
inode_catalog_type=None,
531541
off_mount_repo_dir=False,

eden/fs/cli/util.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,23 @@ def get_commit_hash(self, commit: str) -> str:
515515
return out.strip().decode("utf-8")
516516

517517

518+
class ReCasRepo(Repo):
519+
HEAD = "HEAD"
520+
521+
def __init__(self, source: str, working_dir: Optional[str] = None) -> None:
522+
if working_dir is not None:
523+
raise RuntimeError("ReCas Repo is not expected a working_dir")
524+
super(ReCasRepo, self).__init__("recas", source, working_dir)
525+
526+
def __repr__(self) -> str:
527+
return f"ReCasRepo(source={self.source!r})"
528+
529+
def get_commit_hash(self, commit: str) -> str:
530+
raise NotImplementedError(
531+
"get_commit_hash is not supposed to be called for ReCasRepo"
532+
)
533+
534+
518535
class HttpRepo(Repo):
519536
HEAD = "HEAD"
520537

@@ -591,6 +608,14 @@ def get_hg_repo(path: str, backing_type: Optional[str] = None) -> Optional[HgRep
591608
return HgRepo(repo_path, working_dir, backing_type)
592609

593610

611+
def get_recas_repo(path: str) -> Optional[ReCasRepo]:
612+
"""
613+
If path points to a Re Cas dir, return a ReCasRepo object.
614+
Otherwise, return None.
615+
"""
616+
return ReCasRepo(path)
617+
618+
594619
def get_http_repo(path: str) -> Optional[HttpRepo]:
595620
"""
596621
Return a HttpRepo object, with the source path.
@@ -607,6 +632,11 @@ def get_repo(path: str, backing_store_type: Optional[str] = None) -> Optional[Re
607632
# Skip checking if the local path exists with the repo source name.
608633
return get_http_repo(path)
609634

635+
if backing_store_type is not None and backing_store_type == "recas":
636+
recas_repo = get_recas_repo(path)
637+
if recas_repo is not None:
638+
return recas_repo
639+
610640
path = os.path.realpath(path)
611641
if not os.path.exists(path):
612642
return None

eden/fs/cli_rs/edenfs-client/src/checkout.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ enum RepositoryType {
8585
Git,
8686
#[strum(serialize = "hg")]
8787
Hg,
88+
#[strum(serialize = "recas")]
89+
Recas,
8890
#[strum(serialize = "filteredhg")]
8991
FilteredHg,
9092
}

eden/fs/config/CheckoutConfig.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ constexpr folly::StringPiece kInodeCatalogType{"inode-catalog-type"};
4545
constexpr folly::StringPiece kRequireUtf8Path{"require-utf8-path"};
4646
constexpr folly::StringPiece kEnableSqliteOverlay{"enable-sqlite-overlay"};
4747
constexpr folly::StringPiece kUseWriteBackCache{"use-write-back-cache"};
48+
constexpr folly::StringPiece kReCas{"recas"};
49+
constexpr folly::StringPiece kReUseCase{"use-case"};
4850
#ifdef _WIN32
4951
constexpr folly::StringPiece kRepoGuid{"guid"};
5052
constexpr folly::StringPiece kEnableWindowsSymlinks{"enable-windows-symlinks"};
@@ -425,6 +427,14 @@ std::unique_ptr<CheckoutConfig> CheckoutConfig::loadFromClientDirectory(
425427
auto useWriteBackCache = repository->get_as<bool>(kUseWriteBackCache.str());
426428
config->useWriteBackCache_ = useWriteBackCache.value_or(false);
427429

430+
auto recas = configRoot->get_table(kReCas.str());
431+
if (recas) {
432+
auto re_use_case = recas->get_as<std::string>(kReUseCase.str());
433+
if (re_use_case) {
434+
config->reUseCase_ = *re_use_case;
435+
}
436+
}
437+
428438
#ifdef _WIN32
429439
auto guid = repository->get_as<std::string>(kRepoGuid.str());
430440
config->repoGuid_ = guid ? Guid{*guid} : Guid::generate();

eden/fs/config/CheckoutConfig.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace facebook::eden {
2828
constexpr BackingStoreType kSupportedRepositoryTypes[] = {
2929
BackingStoreType::HG,
3030
BackingStoreType::GIT,
31+
BackingStoreType::RECAS,
3132
BackingStoreType::EMPTY,
3233
BackingStoreType::HTTP,
3334
};
@@ -120,7 +121,8 @@ class CheckoutConfig {
120121
/**
121122
* Get the repository type.
122123
*
123-
* Currently supported types include "git", "hg", "filteredhg", and "empty".
124+
* Currently supported types include "git", "hg", "filteredhg", "empty", and
125+
* "recas".
124126
*/
125127
const std::string& getRepoType() const {
126128
return repoType_;
@@ -203,6 +205,10 @@ class CheckoutConfig {
203205
return useWriteBackCache_;
204206
}
205207

208+
const std::string& getReUseCase() const {
209+
return reUseCase_;
210+
}
211+
206212
#ifdef _WIN32
207213
/** Guid for that repository */
208214
Guid getRepoGuid() const {
@@ -234,6 +240,8 @@ class CheckoutConfig {
234240

235241
bool useWriteBackCache_{false};
236242

243+
std::string reUseCase_{"buck2-default"};
244+
237245
#ifdef _WIN32
238246
Guid repoGuid_;
239247
bool enableWindowsSymlinks_;

eden/fs/inodes/InodeBase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ class InodeBase {
467467
* Force materialize a file or a tree and rely on the overlay as the source of
468468
* the files. If the inode is a symlink and followSymlink is true, its target
469469
* will be materialized if possible. If the inode is a tree, every child in
470-
* this node will be recursively materialized. This function should be used
471-
* carefully.
470+
* this node will be recursively materialized. This function should be careful
471+
* to be used and should be used by RECAS backing store only
472472
*/
473473
[[nodiscard]] virtual ImmediateFuture<folly::Unit> ensureMaterialized(
474474
const ObjectFetchContextPtr& context,

eden/fs/service/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ cpp_binary(
8181
"linux",
8282
[
8383
"//eden/fs/store/facebook/http:http",
84+
"//eden/fs/store/facebook/recas:recas",
8485
"//eden/fs/telemetry/facebook:activity_recorder",
8586
"//eden/fs/telemetry/facebook:scribe_logger",
8687
"//services_efficiency/heap:init",

0 commit comments

Comments
 (0)