Skip to content

Commit

Permalink
Merge pull request #51854 from fky2015/master
Browse files Browse the repository at this point in the history
fix: correct exception messages on policies comparison
  • Loading branch information
evillique committed Jul 7, 2023
2 parents fa9514f + bf4dbb8 commit 8da8b79
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Disks/StoragePolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,23 @@ void StoragePolicy::checkCompatibleWith(const StoragePolicyPtr & new_storage_pol
for (const auto & volume : getVolumes())
{
if (!new_volume_names.contains(volume->getName()))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "New storage policy {} shall contain volumes of old one", backQuote(name));
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"New storage policy {} shall contain volumes of old one ({})",
backQuote(new_storage_policy->getName()),
backQuote(name));

std::unordered_set<String> new_disk_names;
for (const auto & disk : new_storage_policy->getVolumeByName(volume->getName())->getDisks())
new_disk_names.insert(disk->getName());

for (const auto & disk : volume->getDisks())
if (!new_disk_names.contains(disk->getName()))
throw Exception(ErrorCodes::BAD_ARGUMENTS, "New storage policy {} shall contain disks of old one", backQuote(name));
throw Exception(
ErrorCodes::BAD_ARGUMENTS,
"New storage policy {} shall contain disks of old one ({})",
backQuote(new_storage_policy->getName()),
backQuote(name));
}
}

Expand Down

0 comments on commit 8da8b79

Please sign in to comment.