mirror of
https://github.com/neondatabase/neon.git
synced 2026-07-03 20:20:38 +00:00
@@ -296,14 +296,17 @@ pub async fn create_tenant(
|
||||
let created_tenant =
|
||||
schedule_local_tenant_processing(conf, &tenant_directory, remote_storage, ctx)?;
|
||||
|
||||
// As we already removed the directory, the tenant should directly go into the broken state.
|
||||
let destroy = || created_tenant.set_broken("failed to create".into());
|
||||
|
||||
fail::fail_point!("tenant-create-fail", |_| {
|
||||
created_tenant.set_stopping(); // add this to all possible error paths
|
||||
destroy(); // add this to all fail paths
|
||||
anyhow::bail!("tenant-create-fail");
|
||||
});
|
||||
|
||||
let crated_tenant_id = created_tenant.tenant_id();
|
||||
if tenant_id != crated_tenant_id {
|
||||
created_tenant.set_stopping();
|
||||
destroy(); // add this to all fail paths
|
||||
anyhow::bail!("loaded created tenant has unexpected tenant id (expect {tenant_id} != actual {crated_tenant_id})");
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,8 @@ class PageserverHttpClient(requests.Session):
|
||||
self.verbose_error(res)
|
||||
if res.status_code == 409:
|
||||
raise Exception(f"could not create tenant: already exists for id {new_tenant_id}")
|
||||
if not res.ok:
|
||||
raise Exception(f"could not create tenant: {res.text}")
|
||||
new_tenant_id = res.json()
|
||||
assert isinstance(new_tenant_id, str)
|
||||
return TenantId(new_tenant_id)
|
||||
|
||||
@@ -413,18 +413,24 @@ def test_pageserver_create_tenants_fail(
|
||||
env = neon_env_builder.init_start()
|
||||
|
||||
env.pageserver.allowed_errors.append(
|
||||
".*marking .* as locally complete, while it doesnt exist in remote index.*"
|
||||
".*tenant-create-fail.*"
|
||||
)
|
||||
env.pageserver.allowed_errors.append(
|
||||
".*could not load tenant.*Failed to list timelines directory.*"
|
||||
".*Tenant is already in Broken state.*"
|
||||
)
|
||||
env.pageserver.allowed_errors.append(
|
||||
".*could not load tenant.*"
|
||||
)
|
||||
|
||||
pageserver_http = env.pageserver.http_client()
|
||||
pageserver_http.configure_failpoints(("tenant-create-fail", "return"))
|
||||
|
||||
client = env.pageserver.http_client()
|
||||
client.configure_failpoints(("tenant-create-fail", "return"))
|
||||
tenant_id = "deadbeefdeadbeefdeadbeefdeadbeef"
|
||||
try:
|
||||
client.tenant_create(tenant_id)
|
||||
except Exception as e:
|
||||
exception_string = str(e)
|
||||
assert "tenant-create-fail" in exception_string, "should reach failpoint"
|
||||
|
||||
dir = client.tenant_create()
|
||||
|
||||
path = Path(env.repo_dir) / "tenants" / str(dir)
|
||||
path = Path(env.repo_dir) / "tenants" / tenant_id
|
||||
assert not path.exists()
|
||||
|
||||
Reference in New Issue
Block a user