Skip to content

Commit

Permalink
[nbs] delete checkpoint successfully even if it never existed (#1411)
Browse files Browse the repository at this point in the history
* [nbs] delete checkpoint successfully even if it never existed

* fix

* fix
  • Loading branch information
gy2411 authored Jun 14, 2024
1 parent 28c1105 commit f7c923c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cloud/blockstore/libs/storage/volume/model/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@ std::optional<NProto::TError> TCheckpointStore::ValidateCheckpointRequest(
return std::nullopt;
}
case ECheckpointRequestType::DeleteData:
case ECheckpointRequestType::Delete: {
return makeErrorInvalid("Checkpoint does not exist");
case ECheckpointRequestType::Delete: {
return makeErrorAlready("Checkpoint does not exist");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions cloud/blockstore/libs/storage/volume/model/checkpoint_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ Y_UNIT_TEST_SUITE(TCheckpointStore)

executeRequests(ECheckpointType::Normal, TVector<TStep>{
{ECheckpointRequestType::DeleteData, E_PRECONDITION_FAILED},
{ECheckpointRequestType::Delete, E_PRECONDITION_FAILED},
{ECheckpointRequestType::Delete, S_ALREADY},
{ECheckpointRequestType::Create, std::nullopt},
{ECheckpointRequestType::Create, S_ALREADY},
{ECheckpointRequestType::DeleteData, std::nullopt},
Expand Down Expand Up @@ -914,7 +914,7 @@ Y_UNIT_TEST_SUITE(TCheckpointStore)
ECheckpointType::Light})
{
executeRequests(checkpointType, TVector<TStep>{
{ECheckpointRequestType::Delete, E_PRECONDITION_FAILED},
{ECheckpointRequestType::Delete, S_ALREADY},
{ECheckpointRequestType::Create, std::nullopt},
{ECheckpointRequestType::Create, S_ALREADY},
{ECheckpointRequestType::Delete, std::nullopt},
Expand Down
30 changes: 30 additions & 0 deletions cloud/blockstore/libs/storage/volume/volume_ut_checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4751,6 +4751,36 @@ Y_UNIT_TEST_SUITE(TVolumeCheckpointTest)
volume.RecvCreateCheckpointResponse()->GetStatus());
}

Y_UNIT_TEST(ShouldDeleteCheckpointEvenIfItNeverExisted)
{
NProto::TStorageServiceConfig storageServiceConfig;

auto runtime = PrepareTestActorRuntime(std::move(storageServiceConfig));

TVolumeClient volume(*runtime);
volume.UpdateVolumeConfig(
0, // maxBandwidth
0, // maxIops
0, // burstPercentage
0, // maxPostponedWeight
false, // throttlingEnabled
1, // version
NProto::STORAGE_MEDIA_SSD,
1024, // block count per partition
"vol0", // diskId
"cloud", // cloudId
"folder", // folderId
1, // partition count
2 // blocksPerStripe
);
volume.WaitReady();

volume.SendDeleteCheckpointRequest("checkpoint_never_existed");
UNIT_ASSERT_VALUES_EQUAL(
S_ALREADY,
volume.RecvDeleteCheckpointResponse()->GetStatus());
}

Y_UNIT_TEST(ShouldHandleGetChangedBlocksForShadowDiskBasedCheckpoint)
{
NProto::TStorageServiceConfig config;
Expand Down

0 comments on commit f7c923c

Please sign in to comment.