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

Add agent state to DA node id response #2140

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ void TDiskRegistryActor::HandleGetAgentNodeId(
return;
}

const auto* info = AgentRegInfo.FindPtr(agent->GetAgentId());
const bool connected = info && info->Connected;

response->Record.SetNodeId(agent->GetNodeId());
response->Record.SetAgentState(agent->GetState());
response->Record.SetConnected(connected);
NCloud::Reply(ctx, *ev, std::move(response));
}

Expand Down
6 changes: 6 additions & 0 deletions cloud/blockstore/libs/storage/protos/disk.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,12 @@ message TGetAgentNodeIdResponse

// Node that agent is running on.
uint32 NodeId = 2;

// Agent state.
EAgentState AgentState = 3;

// Whether the agent is connected to the DR or not.
bool Connected = 4;
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ void TGetDiskAgentNodeIdActor::HandleGetAgentNodeIdResponse(
SetErrorProtoFlag(error, NCloud::NProto::EF_SILENT);
}

auto response =
std::make_unique<TEvService::TEvExecuteActionResponse>(std::move(error));
auto response = std::make_unique<TEvService::TEvExecuteActionResponse>(
std::move(error));

google::protobuf::util::JsonPrintOptions options;
options.always_print_primitive_fields = true;
google::protobuf::util::MessageToJsonString(
msg->Record,
response->Record.MutableOutput());
response->Record.MutableOutput(),
options);

ReplyAndDie(ctx, std::move(response));
}
Expand Down
2 changes: 2 additions & 0 deletions cloud/blockstore/tests/client/test_with_multiple_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def test_wait_dependent_disks_to_switch_node_timeout():
agent_id = make_agent_id(0)
node_id_response = json.loads(client.get_disk_agent_node_id(agent_id))
assert node_id_response["NodeId"] > 50000
assert node_id_response["AgentState"] == "AGENT_STATE_ONLINE"
assert node_id_response["Connected"]

# This should return immediately.
wait_response = client.wait_dependent_disks_to_switch_node(
Expand Down
Loading