Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
komarevtsev-d committed Jan 28, 2025
1 parent 44ea4ba commit c686e07
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 29 deletions.
33 changes: 12 additions & 21 deletions cloud/blockstore/libs/storage/volume/model/helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,35 +232,26 @@ bool RowHasFreshDevices(
return false;
}

void RemoveLaggingDevicesFromMeta(
void UpdateLaggingDevicesAfterMetaUpdate(
NProto::TVolumeMeta& meta,
const TVector<TString>& laggingDeviceIds)
const TVector<TString>& removedLaggingDeviceIds)
{
auto& agents = *meta.MutableLaggingAgentsInfo()->MutableAgents();
for (auto& agent: agents) {
EraseIf(
*agent.MutableDevices(),
[&laggingDeviceIds](const NProto::TLaggingDevice& laggingDevice)
auto& laggingAgents = *meta.MutableLaggingAgentsInfo()->MutableAgents();
for (auto& agent: laggingAgents) {
const bool laggingDevicesWereRemoved = AllOf(
agent.GetDevices(),
[&removedLaggingDeviceIds](
const NProto::TLaggingDevice& laggingDevice)
{
return !!FindPtr(
laggingDeviceIds,
removedLaggingDeviceIds,
laggingDevice.GetDeviceUUID());
});
}
EraseIf(
agents,
[](const NProto::TLaggingAgent& laggingAgent)
{ return laggingAgent.GetDevices().empty(); });
if (agents.empty()) {
meta.MutableLaggingAgentsInfo()->Clear();
}
}

void UpdateLaggingDevicesAfterMetaUpdate(NProto::TVolumeMeta& meta)
{
auto& laggingAgents = *meta.MutableLaggingAgentsInfo()->MutableAgents();
for (auto& agent: laggingAgents) {
agent.ClearDevices();
if (laggingDevicesWereRemoved) {
continue;
}

auto replicaIndex = FindReplicaIndexByAgentId(meta, agent.GetAgentId());
if (!replicaIndex) {
Expand Down
6 changes: 2 additions & 4 deletions cloud/blockstore/libs/storage/volume/model/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ namespace NCloud::NBlockStore::NStorage {
const google::protobuf::RepeatedPtrField<NProto::TLaggingDevice>&
alreadyLagging);

void RemoveLaggingDevicesFromMeta(
void UpdateLaggingDevicesAfterMetaUpdate(
NProto::TVolumeMeta& meta,
const TVector<TString>& laggingDeviceIds);

void UpdateLaggingDevicesAfterMetaUpdate(NProto::TVolumeMeta& meta);
const TVector<TString>& removedLaggingDeviceIds);

} // namespace NCloud::NBlockStore::NStorage
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ NProto::TVolumeMeta CreateNewMeta(
newMeta.SetIOMode(args.IOMode);
newMeta.SetIOModeTs(args.IOModeTs.MicroSeconds());
newMeta.SetMuteIOErrors(args.MuteIOErrors);
RemoveLaggingDevicesFromMeta(newMeta, args.RemovedLaggingDeviceIds);
UpdateLaggingDevicesAfterMetaUpdate(newMeta);
UpdateLaggingDevicesAfterMetaUpdate(newMeta, args.RemovedLaggingDeviceIds);

return newMeta;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,9 @@ void TVolumeActor::FinishUpdateVolumeConfig(const TActorContext& ctx)
if (State) {
newMeta.MutableLaggingAgentsInfo()->CopyFrom(
State->GetMeta().GetLaggingAgentsInfo());
RemoveLaggingDevicesFromMeta(
UpdateLaggingDevicesAfterMetaUpdate(
newMeta,
UnfinishedUpdateVolumeConfig.RemovedLaggingDeviceIds);
UpdateLaggingDevicesAfterMetaUpdate(newMeta);
}

UnfinishedUpdateVolumeConfig.Devices = {};
Expand Down

0 comments on commit c686e07

Please sign in to comment.