Skip to content

Commit

Permalink
merge to stable-23-3 (#1623)
Browse files Browse the repository at this point in the history
* NEBDUTY-1543: tweak tests/local_ssd (#1464)

* issue-1567: send DeallocateDisk in case a Volume is not found (#1568)

* do not trigger DiskRegistryAgentDevicePoolConfigMismatch event on allocated devices (#1570)
  • Loading branch information
sharpeye authored Jul 18, 2024
1 parent 8271163 commit 3d93255
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 154 deletions.
42 changes: 31 additions & 11 deletions cloud/blockstore/libs/storage/disk_registry/disk_registry_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,31 @@ void SetDeviceErrorState(
device.SetStateMessage(std::move(message));
}

auto CollectDirtyDeviceUUIDs(const TVector<TDirtyDevice>& dirtyDevices)
{
TVector<TString> uuids;
uuids.reserve(dirtyDevices.size());

for (const auto& [uuid, diskId]: dirtyDevices) {
uuids.push_back(uuid);
}

return uuids;
}

auto CollectAllocatedDevices(const TVector<NProto::TDiskConfig>& disks)
{
TVector<std::pair<TString, TString>> r;

for (const auto& disk: disks) {
for (const auto& uuid: disk.GetDeviceUUIDs()) {
r.emplace_back(uuid, disk.GetDiskId());
}
}

return r;
}

} // namespace

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -323,15 +348,10 @@ TDiskRegistryState::TDiskRegistryState(
StorageConfig->GetNonReplicatedAgentDisconnectRecoveryInterval(),
StorageConfig->GetSerialNumberValidationEnabled(),
}, counters, std::move(agents), std::move(diskRegistryAgentListParams), Log)
, DeviceList([&] {
TVector<TDeviceId> uuids;
uuids.reserve(dirtyDevices.size());
for (auto& [uuid, diskId]: dirtyDevices) {
uuids.push_back(uuid);
}

return uuids;
}(), std::move(suspendedDevices))
, DeviceList(
CollectDirtyDeviceUUIDs(dirtyDevices),
std::move(suspendedDevices),
CollectAllocatedDevices(disks))
, BrokenDisks(std::move(brokenDisks))
, AutomaticallyReplacedDevices(std::move(automaticallyReplacedDevices))
, CurrentConfig(std::move(config))
Expand Down Expand Up @@ -469,7 +489,7 @@ void TDiskRegistryState::ProcessDisks(TVector<NProto::TDiskConfig> configs)
disk.DeviceReplacementIds.push_back(id);
}

for (auto& m: config.GetMigrations()) {
for (const auto& m: config.GetMigrations()) {
const auto* device = DeviceList.FindDevice(m.GetSourceDeviceId());
TString poolName;
if (device) {
Expand Down Expand Up @@ -512,7 +532,7 @@ void TDiskRegistryState::ProcessDisks(TVector<NProto::TDiskConfig> configs)
: diskId);
}

for (auto& m: config.GetFinishedMigrations()) {
for (const auto& m: config.GetFinishedMigrations()) {
const auto& uuid = m.GetDeviceId();

DeviceList.MarkDeviceAllocated(diskId, uuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,10 @@ Y_UNIT_TEST_SUITE(TDiskRegistryStatePoolsTest)
AgentConfig(3, {
device("uuid-3.1", allocationUnitSize, "rack-3"),
device("uuid-3.2", allocationUnitSize, "rack-3"),
}),
AgentConfig(4, {
// uuid-4.1 has a non-standard size
device("uuid-4.1", 2 * allocationUnitSize, "rack-4"),
})
};

Expand All @@ -873,6 +877,16 @@ Y_UNIT_TEST_SUITE(TDiskRegistryStatePoolsTest)
return config;
}())
.WithKnownAgents(agents)
.WithDisks({[] {
NProto::TDiskConfig disk;
disk.SetDiskId("vol0");
disk.AddDeviceUUIDs("uuid-4.1");
disk.SetBlockSize(4_KB);
disk.SetStorageMediaKind(
NProto::STORAGE_MEDIA_SSD_NONREPLICATED);

return disk;
}()})
.Build();

// uuid-2.1 was detected as a non-standart size device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ auto FindDeviceRange(

TDeviceList::TDeviceList(
TVector<TDeviceId> dirtyDevices,
TVector<NProto::TSuspendedDevice> suspendedDevices)
: DirtyDevices(
TVector<NProto::TSuspendedDevice> suspendedDevices,
TVector<std::pair<TDeviceId, TDiskId>> allocatedDevices)
: AllocatedDevices(
std::make_move_iterator(allocatedDevices.begin()),
std::make_move_iterator(allocatedDevices.end()))
, DirtyDevices(
std::make_move_iterator(dirtyDevices.begin()),
std::make_move_iterator(dirtyDevices.end()))
{
Expand Down
37 changes: 20 additions & 17 deletions cloud/blockstore/libs/storage/disk_registry/model/device_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,19 @@ class TDeviceList
}
};

TDeviceList() = default;

explicit TDeviceList(
TVector<TDeviceId> dirtyDevices,
TVector<NProto::TSuspendedDevice> suspendedDevices);
TVector<NProto::TSuspendedDevice> suspendedDevices,
TVector<std::pair<TDeviceId, TDiskId>> allocatedDevices);

size_t Size() const
[[nodiscard]] size_t Size() const
{
return AllDevices.size();
}

const auto& GetPoolName2DeviceCount() const
[[nodiscard]] const auto& GetPoolName2DeviceCount() const
{
return PoolName2DeviceCount;
}
Expand All @@ -109,15 +112,15 @@ class TDeviceList

void RemoveDevices(const NProto::TAgentConfig& agent);

TNodeId FindNodeId(const TDeviceId& id) const;
TString FindAgentId(const TDeviceId& id) const;
[[nodiscard]] TNodeId FindNodeId(const TDeviceId& id) const;
[[nodiscard]] TString FindAgentId(const TDeviceId& id) const;

TString FindRack(const TDeviceId& id) const;
TDiskId FindDiskId(const TDeviceId& id) const;
const NProto::TDeviceConfig* FindDevice(const TDeviceId& id) const;
[[nodiscard]] TString FindRack(const TDeviceId& id) const;
[[nodiscard]] TDiskId FindDiskId(const TDeviceId& id) const;
[[nodiscard]] const NProto::TDeviceConfig* FindDevice(const TDeviceId& id) const;

TVector<NProto::TDeviceConfig> GetBrokenDevices() const;
TVector<NProto::TDeviceConfig> GetDirtyDevices() const;
[[nodiscard]] TVector<NProto::TDeviceConfig> GetBrokenDevices() const;
[[nodiscard]] TVector<NProto::TDeviceConfig> GetDirtyDevices() const;

NProto::TDeviceConfig AllocateDevice(
const TDiskId& diskId,
Expand All @@ -126,7 +129,7 @@ class TDeviceList
const TDiskId& diskId,
const TDeviceId& deviceId,
const TAllocationQuery& query);
bool IsAllocatedDevice(const TDeviceId& id) const;
[[nodiscard]] bool IsAllocatedDevice(const TDeviceId& id) const;
bool ValidateAllocationQuery(
const TAllocationQuery& query,
const TDeviceId& targetDeviceId);
Expand All @@ -143,16 +146,16 @@ class TDeviceList
bool MarkDeviceAsClean(const TDeviceId& uuid);
void MarkDeviceAsDirty(const TDeviceId& uuid);

bool IsDirtyDevice(const TDeviceId& uuid) const;
NProto::EDeviceState GetDeviceState(const TDeviceId& uuid) const;
[[nodiscard]] bool IsDirtyDevice(const TDeviceId& uuid) const;
[[nodiscard]] NProto::EDeviceState GetDeviceState(const TDeviceId& uuid) const;

void SuspendDevice(const TDeviceId& ids);
void ResumeDevice(const TDeviceId& id);
void ResumeAfterErase(const TDeviceId& id);
bool IsSuspendedDevice(const TDeviceId& id) const;
TVector<NProto::TSuspendedDevice> GetSuspendedDevices() const;
[[nodiscard]] bool IsSuspendedDevice(const TDeviceId& id) const;
[[nodiscard]] TVector<NProto::TSuspendedDevice> GetSuspendedDevices() const;

ui64 GetDeviceByteCount(const TDeviceId& id) const;
[[nodiscard]] ui64 GetDeviceByteCount(const TDeviceId& id) const;

void ForgetDevice(const TString& id);

Expand All @@ -161,7 +164,7 @@ class TDeviceList
const TAllocationQuery& query,
const TString& poolName);
TVector<TDeviceRange> CollectDevices(const TAllocationQuery& query);
TVector<TRack> SelectRacks(
[[nodiscard]] TVector<TRack> SelectRacks(
const TAllocationQuery& query,
const TString& poolName) const;
void RemoveDeviceFromFreeList(const TDeviceId& id);
Expand Down
Loading

0 comments on commit 3d93255

Please sign in to comment.