gavinchou commented on code in PR #37468:
URL: https://github.com/apache/doris/pull/37468#discussion_r1668263945
##########
cloud/src/recycler/recycler.cpp:
##########
@@ -2233,49 +2233,35 @@ int InstanceRecycler::init_copy_job_accessor(const
std::string& stage_id,
}
#else
// init s3 accessor and add to accessor map
- bool found = false;
- ObjectStoreInfoPB object_store_info;
- StagePB::StageAccessType stage_access_type = StagePB::AKSK;
- for (auto& s : instance_info_.stages()) {
- if (s.stage_id() == stage_id) {
- object_store_info = s.obj_info();
- if (s.has_access_type()) {
- stage_access_type = s.access_type();
- }
- found = true;
- break;
- }
- }
- if (!found) {
+ auto stage_it =
+ std::find_if(instance_info_.stages().begin(),
instance_info_.stages().end(),
+ [&stage_id](auto&& stage) { return stage.stage_id()
== stage_id; });
+
+ if (stage_it == instance_info_.stages().end()) {
LOG(INFO) << "Recycle nonexisted stage copy jobs. instance_id=" <<
instance_id_
<< ", stage_id=" << stage_id << ", stage_type=" <<
stage_type;
return 1;
}
+
+ const auto& object_store_info = stage_it->obj_info();
+ auto stage_access_type = stage_it->has_access_type() ?
stage_it->access_type() : StagePB::AKSK;
+
S3Conf s3_conf;
if (stage_type == StagePB::EXTERNAL) {
- s3_conf.endpoint = object_store_info.endpoint();
- s3_conf.region = object_store_info.region();
- s3_conf.bucket = object_store_info.bucket();
- s3_conf.prefix = object_store_info.prefix();
if (stage_access_type == StagePB::AKSK) {
- s3_conf.ak = object_store_info.ak();
- s3_conf.sk = object_store_info.sk();
- if (object_store_info.has_encryption_info()) {
- AkSkPair plain_ak_sk_pair;
- int ret = decrypt_ak_sk_helper(object_store_info.ak(),
object_store_info.sk(),
-
object_store_info.encryption_info(),
- &plain_ak_sk_pair);
- if (ret != 0) {
- LOG(WARNING) << "fail to decrypt ak sk. instance_id: " <<
instance_id_
- << " obj_info: " <<
proto_to_json(object_store_info);
- return -1;
- }
- s3_conf.ak = std::move(plain_ak_sk_pair.first);
- s3_conf.sk = std::move(plain_ak_sk_pair.second);
+ auto conf = S3Conf::from_obj_store_info(object_store_info);
+ if (!conf) {
+ return -1;
}
+
+ s3_conf = std::move(*conf);
} else if (stage_access_type == StagePB::BUCKET_ACL) {
- s3_conf.ak = instance_info_.ram_user().ak();
- s3_conf.sk = instance_info_.ram_user().sk();
+ auto conf = S3Conf::from_obj_store_info(object_store_info, true);
Review Comment:
```suggestion
auto conf = S3Conf::from_obj_store_info(object_store_info,
true/*withou_ak_sk*/);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]