From a2a1c3babad52491bb0435bf3d59d2f77cd37702 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 25 Dec 2024 10:55:13 +0800 Subject: [PATCH] Fix some comments --- .../meta-service/meta_service_resource.cpp | 2 - cloud/test/meta_service_test.cpp | 39 +++++++++++++++++++ .../apache/doris/catalog/StorageVaultMgr.java | 8 ++-- gensrc/proto/cloud.proto | 3 -- 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/cloud/src/meta-service/meta_service_resource.cpp b/cloud/src/meta-service/meta_service_resource.cpp index 13f5e4a8723711..d873dec7b21070 100644 --- a/cloud/src/meta-service/meta_service_resource.cpp +++ b/cloud/src/meta-service/meta_service_resource.cpp @@ -642,7 +642,6 @@ static int alter_hdfs_storage_vault(InstanceInfoPB& instance, std::unique_ptrset_storage_vault_id(new_vault.id()); - response->set_storage_vault_name(new_vault.name()); return 0; } @@ -770,7 +769,6 @@ static int alter_s3_storage_vault(InstanceInfoPB& instance, std::unique_ptrset_storage_vault_id(new_vault.id()); - response->set_storage_vault_name(new_vault.name()); return 0; } diff --git a/cloud/test/meta_service_test.cpp b/cloud/test/meta_service_test.cpp index 3bf20facca1217..777c7419b701ad 100644 --- a/cloud/test/meta_service_test.cpp +++ b/cloud/test/meta_service_test.cpp @@ -637,6 +637,25 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) { meta_service->alter_storage_vault( reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, nullptr); ASSERT_EQ(res.status().code(), MetaServiceCode::OK) << res.status().msg(); + + { + AlterObjStoreInfoRequest req; + req.set_cloud_unique_id("test_cloud_unique_id"); + req.set_op(AlterObjStoreInfoRequest::ALTER_S3_VAULT); + StorageVaultPB vault; + vault.set_alter_name(new_vault_name); + ObjectStoreInfoPB obj; + obj_info.set_ak("new_ak"); + obj_info.set_sk("new_sk"); + vault.mutable_obj_info()->MergeFrom(obj); + vault.set_name(new_vault_name); + req.mutable_vault()->CopyFrom(vault); + meta_service->alter_storage_vault( + reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, + nullptr); + ASSERT_EQ(res.status().code(), MetaServiceCode::ALREADY_EXISTED) << res.status().msg(); + } + InstanceInfoPB instance; get_test_instance(instance); @@ -726,6 +745,7 @@ TEST(MetaServiceTest, AlterHdfsStorageVaultTest) { meta_service->alter_storage_vault( reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, nullptr); ASSERT_EQ(res.status().code(), MetaServiceCode::OK) << res.status().msg(); + InstanceInfoPB instance; get_test_instance(instance); @@ -793,6 +813,25 @@ TEST(MetaServiceTest, AlterHdfsStorageVaultTest) { meta_service->alter_storage_vault( reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, nullptr); ASSERT_EQ(res.status().code(), MetaServiceCode::OK) << res.status().msg(); + + { + AlterObjStoreInfoRequest req; + req.set_cloud_unique_id("test_cloud_unique_id"); + req.set_op(AlterObjStoreInfoRequest::ALTER_HDFS_VAULT); + StorageVaultPB vault; + vault.mutable_hdfs_info()->mutable_build_conf()->set_user("hadoop"); + vault.set_name(new_vault_name); + vault.set_alter_name(new_vault_name); + req.mutable_vault()->CopyFrom(vault); + + brpc::Controller cntl; + AlterObjStoreInfoResponse res; + meta_service->alter_storage_vault( + reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, + nullptr); + ASSERT_EQ(res.status().code(), MetaServiceCode::ALREADY_EXISTED) << res.status().msg(); + } + InstanceInfoPB instance; get_test_instance(instance); diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/StorageVaultMgr.java b/fe/fe-core/src/main/java/org/apache/doris/catalog/StorageVaultMgr.java index daabb85cf09128..957a4279f4ad6b 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/catalog/StorageVaultMgr.java +++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/StorageVaultMgr.java @@ -199,9 +199,11 @@ public void alterStorageVault(StorageVaultType type, Map propert throw new DdlException(response.getStatus().getMsg()); } - updateVaultNameToIdCache(name, response.getStorageVaultName(), response.getStorageVaultId()); - LOG.info("Succeed to alter storage vault, old name:{} new name: {} id:{}", name, - response.getStorageVaultName(), response.getStorageVaultId()); + if (request.hasVault() && request.getVault().hasAlterName()) { + updateVaultNameToIdCache(name, request.getVault().getAlterName(), response.getStorageVaultId()); + LOG.info("Succeed to alter storage vault, old name:{} new name: {} id:{}", name, + request.getVault().getAlterName(), response.getStorageVaultId()); + } // Make BE eagerly fetch the storage vault info from Meta Service ALTER_BE_SYNC_THREAD_POOL.execute(() -> alterSyncVaultTask()); diff --git a/gensrc/proto/cloud.proto b/gensrc/proto/cloud.proto index 46d7f29ba4fb2e..c113868a2c3286 100644 --- a/gensrc/proto/cloud.proto +++ b/gensrc/proto/cloud.proto @@ -887,9 +887,6 @@ message AlterObjStoreInfoResponse { optional MetaServiceResponseStatus status = 1; optional string storage_vault_id = 2; optional bool default_storage_vault_replaced = 3; - - // storage_vault_name maybe changed, so return new storage_vault_name - optional string storage_vault_name = 4; } message UpdateAkSkRequest {