neon_local init: add --force mode that allows an empty dir

This will be useful to prepare repo_dir snapshot in an empty overlayfs mount.
(Think Dockerfile `FROM scratch`.)
This commit is contained in:
Christian Schwarz
2024-01-09 15:08:54 +00:00
parent 7721f1b9c6
commit 9bdbca0c02
3 changed files with 70 additions and 24 deletions

View File

@@ -473,6 +473,7 @@ class NeonEnvBuilder:
self.test_output_dir = test_output_dir
self.test_overlay_dir = test_overlay_dir
self.overlay_mounts_created_by_us: List[Tuple[str, Path]] = []
self.config_init_force: Optional[str] = None
assert test_name.startswith(
"test_"
@@ -911,7 +912,7 @@ class NeonEnv:
cfg["safekeepers"].append(sk_cfg)
log.info(f"Config: {cfg}")
self.neon_cli.init(cfg)
self.neon_cli.init(cfg, force=config.config_init_force)
def start(self):
# Start up broker, pageserver and all safekeepers
@@ -1399,6 +1400,7 @@ class NeonCli(AbstractNeonCli):
def init(
self,
config: Dict[str, Any],
force: Optional[str] = None,
) -> "subprocess.CompletedProcess[str]":
with tempfile.NamedTemporaryFile(mode="w+") as tmp:
tmp.write(toml.dumps(config))
@@ -1406,6 +1408,9 @@ class NeonCli(AbstractNeonCli):
cmd = ["init", f"--config={tmp.name}", "--pg-version", self.env.pg_version]
if force is not None:
cmd.extend(["--force", force])
storage = self.env.pageserver_remote_storage
append_pageserver_param_overrides(