Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue-3017: restore endpoints despite of missing socket directory #3011

Merged
merged 2 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading