Skip to content

Commit

Permalink
Add agent state to DA node id response (#2140)
Browse files Browse the repository at this point in the history
  • Loading branch information
komarevtsev-d committed Sep 30, 2024
1 parent e9ec61a commit f4f684f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
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 @@ -227,6 +227,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

0 comments on commit f4f684f

Please sign in to comment.