Skip to content

Commit

Permalink
create socket directory after host restart
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmyagkov committed Feb 11, 2025
1 parent d9cf11f commit f7ea82d
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cloud/blockstore/libs/endpoints/endpoint_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,10 @@ TFuture<NProto::TStartEndpointResponse> TEndpointManager::RestoreSingleEndpoint(
return promise.ExtractValue();
}

auto socketPath = request->GetUnixSocketPath();
auto socketPath = TFsPath(request->GetUnixSocketPath());
if (!socketPath.Parent().Exists()) {
socketPath.Parent().MkDir();
}

auto response = self->StartEndpointImpl(
std::move(ctx),
Expand Down
65 changes: 65 additions & 0 deletions cloud/blockstore/tests/e2e-tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,68 @@ def test_do_not_restore_endpoint_with_missing_volume():
assert result.returncode == 0
assert 0 == len(os.listdir(endpoints_dir))
cleanup_after_test(env)


def test_restore_endpoint_when_socket_directory_does_not_exist():
# Scenario:
# 1. run nbs
# 2. create volume and start endpoint
# 4. copy endpoint to backup directory
# 5. stop endpoint
# 6. stop nbs
# 7. copy endpoint from backup directory to endpoints directory
# 8. remove socket directory
# 8. run nbs
# 9. check that endpoint was restored
env, run = init()

test_hash = hash(common.context.test_name)

volume_name = "example-disk"
block_size = 4096
blocks_count = 10000
nbd_device = Path("/dev/nbd0")
socket_dir = Path("/tmp") / volume_name
socket_dir.mkdir()
socket_path = socket_dir / "nbd.sock"
try:
result = run(
"createvolume",
"--disk-id",
volume_name,
"--blocks-count",
str(blocks_count),
"--block-size",
str(block_size),
)
assert result.returncode == 0

result = run(
"startendpoint",
"--disk-id",
volume_name,
"--socket",
socket_path,
"--ipc-type",
"nbd",
"--persistent",
"--nbd-device",
nbd_device
)

shutil.rmtree(socket_dir)

env.nbs.restart()

result = run(
"listendpoints",
"--wait-for-restoring",
)
assert result.returncode == 0
assert socket_path.exists()

except subprocess.CalledProcessError as e:
log_called_process_error(e)
raise

cleanup_after_test(env)

0 comments on commit f7ea82d

Please sign in to comment.