This is an automated email from the ASF dual-hosted git repository. alexey pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kudu.git
commit 7241bfb2532d80e66d61930e3da3306b5172cbe6 Author: Alexey Serbin <[email protected]> AuthorDate: Thu Feb 27 18:36:02 2025 -0800 [fs] fix result status handling This patch addresses sloppy result handling of functions/methods that return Status under the src/kudu/fs directory. Change-Id: Ib2033dee550c144b57a2e97d74427b86bb45ebfe Reviewed-on: http://gerrit.cloudera.org:8080/22663 Tested-by: Alexey Serbin <[email protected]> Reviewed-by: Yifan Zhang <[email protected]> --- src/kudu/fs/block_manager-test.cc | 4 ++-- src/kudu/fs/default_key_provider.h | 2 +- src/kudu/fs/file_block_manager.cc | 2 +- src/kudu/fs/fs_manager-test.cc | 11 ++++++++--- src/kudu/fs/log_block_manager-test.cc | 16 ++++++++-------- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/kudu/fs/block_manager-test.cc b/src/kudu/fs/block_manager-test.cc index c4968ff64..b01fe4a6e 100644 --- a/src/kudu/fs/block_manager-test.cc +++ b/src/kudu/fs/block_manager-test.cc @@ -657,8 +657,8 @@ TYPED_TEST(BlockManagerTest, CloseManyBlocksTest) { for (int i = 0; i < sizeof(data); i += sizeof(uint32_t)) { data[i] = rand.Next(); } - written_block->Append(Slice(data, sizeof(data))); - written_block->Finalize(); + ASSERT_OK(written_block->Append(Slice(data, sizeof(data)))); + ASSERT_OK(written_block->Finalize()); creation_transaction->AddCreatedBlock(std::move(written_block)); } } diff --git a/src/kudu/fs/default_key_provider.h b/src/kudu/fs/default_key_provider.h index 807ede669..043403ce1 100644 --- a/src/kudu/fs/default_key_provider.h +++ b/src/kudu/fs/default_key_provider.h @@ -63,7 +63,7 @@ public: OPENSSL_RET_NOT_OK(RAND_bytes(iv_bytes, num_bytes), "Failed to generate random key"); strings::b2a_hex(iv_bytes, iv, num_bytes); - DecryptEncryptionKey(dek, *iv, *key_version, encryption_key); + RETURN_NOT_OK(DecryptEncryptionKey(dek, *iv, *key_version, encryption_key)); *key_version = "encryptionkey@0"; return Status::OK(); } diff --git a/src/kudu/fs/file_block_manager.cc b/src/kudu/fs/file_block_manager.cc index 041667c12..ba12dc290 100644 --- a/src/kudu/fs/file_block_manager.cc +++ b/src/kudu/fs/file_block_manager.cc @@ -372,7 +372,7 @@ Status FileWritableBlock::Finalize() { VLOG(3) << "Finalizing block " << id(); if (state_ == DIRTY && FLAGS_block_manager_preflush_control == "finalize") { - FlushDataAsync(); + RETURN_NOT_OK(FlushDataAsync()); } state_ = FINALIZED; return Status::OK(); diff --git a/src/kudu/fs/fs_manager-test.cc b/src/kudu/fs/fs_manager-test.cc index 23c38226e..f9ea04075 100644 --- a/src/kudu/fs/fs_manager-test.cc +++ b/src/kudu/fs/fs_manager-test.cc @@ -19,6 +19,7 @@ #include <sys/stat.h> #include <unistd.h> +// IWYU pragma: no_include <bits/struct_stat.h> #include <cstdint> #include <functional> @@ -281,8 +282,12 @@ TEST_P(FsManagerTestBase, TestTenantAccountOperation) { ASSERT_FALSE(fs_manager()->is_tenants_exist()); // Add tenant is not allowed. - ASSERT_DEATH(fs_manager()->AddTenant(non_exist_tenant_name, non_exist_tenant, - nullopt, nullopt, nullopt), ""); + ASSERT_DEATH({ ASSERT_OK(fs_manager()->AddTenant( + non_exist_tenant_name, + non_exist_tenant, + nullopt, + nullopt, + nullopt)); }, ""); ASSERT_FALSE(fs_manager()->VertifyTenant(non_exist_tenant)); ASSERT_TRUE(fs_manager()->VertifyTenant(default_tenant_id)); ASSERT_EQ(0, fs_manager()->GetDataRootDirs(non_exist_tenant).size()); @@ -621,7 +626,7 @@ TEST_P(FsManagerTestBase, TestCreateWithFailedDirs) { // Create some top-level paths to place roots in. vector<string> data_paths = { GetTestPath("data1"), GetTestPath("data2"), GetTestPath("data3") }; for (const string& path : data_paths) { - GetEnv()->CreateDir(path); + ASSERT_OK(GetEnv()->CreateDir(path)); } // Initialize the FS layout with roots in subdirectories of data_paths. When // we canonicalize paths, we canonicalize the dirname of each path (e.g. diff --git a/src/kudu/fs/log_block_manager-test.cc b/src/kudu/fs/log_block_manager-test.cc index a4ee00928..4b2e72b7f 100644 --- a/src/kudu/fs/log_block_manager-test.cc +++ b/src/kudu/fs/log_block_manager-test.cc @@ -475,7 +475,7 @@ TEST_P(LogBlockManagerTest, MetricsTest) { for (int j = 0; j < sizeof(data); j += sizeof(uint32_t)) { data[j] = rand.Next(); } - b->Append(Slice(data, sizeof(data))); + ASSERT_OK(b->Append(Slice(data, sizeof(data)))); ASSERT_OK(b->Finalize()); transaction->AddCreatedBlock(std::move(b)); } @@ -550,7 +550,7 @@ TEST_P(LogBlockManagerTest, MetricsTest) { unique_ptr<WritableBlock> b; ASSERT_OK(bm_->CreateBlock(test_block_opts_, &b)); blocks.emplace_back(b->id()); - b->Append("test data"); + ASSERT_OK(b->Append("test data")); ASSERT_OK(b->Finalize()); transaction->AddCreatedBlock(std::move(b)); } @@ -2062,7 +2062,7 @@ TEST_P(LogBlockManagerTest, TestLIFOContainerSelection) { for (int i = 0; i < 4; i++) { unique_ptr<WritableBlock> writer; ASSERT_OK(bm_->CreateBlock(test_block_opts_, &writer)); - writer->Append("test data"); + ASSERT_OK(writer->Append("test data")); blocks.emplace_back(std::move(writer)); } for (const auto& block : blocks) { @@ -2078,7 +2078,7 @@ TEST_P(LogBlockManagerTest, TestLIFOContainerSelection) { for (int i = 0; i < 4; i++) { unique_ptr<WritableBlock> writer; ASSERT_OK(bm_->CreateBlock(test_block_opts_, &writer)); - writer->Append("test data"); + ASSERT_OK(writer->Append("test data")); ASSERT_OK(writer->Finalize()); // After finalizing the written block, the used container will be // available again and can be reused for the following created block. @@ -2207,7 +2207,7 @@ TEST_P(LogBlockManagerTest, TestDeleteDeadContainersByDeletionTransaction) { {0, &METRIC_log_block_manager_dead_containers_deleted} })); // After the reader is closed, the container is actually deleted. - reader->Close(); + ASSERT_OK(reader->Close()); NO_FATALS(CheckLogMetrics(entity, { {0, &METRIC_log_block_manager_bytes_under_management}, {0, &METRIC_log_block_manager_blocks_under_management}, @@ -2322,7 +2322,7 @@ TEST_P(LogBlockManagerNativeMetaTest, TestHalfPresentContainer) { opts.is_sensitive = true; ASSERT_OK(env_->NewWritableFile(opts, metadata_file_name, &metadata_file_writer)); ASSERT_OK(metadata_file_writer->Append(Slice("a"))); - metadata_file_writer->Close(); + ASSERT_OK(metadata_file_writer->Close()); }; const auto CreateDataFile = [&] () { @@ -2334,7 +2334,7 @@ TEST_P(LogBlockManagerNativeMetaTest, TestHalfPresentContainer) { WritableFileOptions opts; opts.is_sensitive = true; ASSERT_OK(env_->NewWritableFile(opts, data_file_name, &data_file_writer)); - data_file_writer->Close(); + ASSERT_OK(data_file_writer->Close()); }; const auto DeleteBlock = [&] () { @@ -2597,7 +2597,7 @@ TEST_P(LogBlockManagerRdbMetaTest, TestHalfPresentContainer) { WritableFileOptions opts; opts.is_sensitive = true; ASSERT_OK(env_->NewWritableFile(opts, data_file_name, &data_file_writer)); - data_file_writer->Close(); + ASSERT_OK(data_file_writer->Close()); }; const auto DeleteBlock = [&] () {
