This is an automated email from the ASF dual-hosted git repository.
lide pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 62723c933f5 [fix](backup) support aws_token for backup/restore (#26275)
62723c933f5 is described below
commit 62723c933f5ae7d4c9bb6017491481f78f1ffbcd
Author: xueweizhang <[email protected]>
AuthorDate: Thu Nov 2 20:52:53 2023 +0800
[fix](backup) support aws_token for backup/restore (#26275)
---
be/src/util/s3_util.cpp | 6 ++++++
be/src/util/s3_util.h | 9 ++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/be/src/util/s3_util.cpp b/be/src/util/s3_util.cpp
index 9c938322094..25d8d7f45cc 100644
--- a/be/src/util/s3_util.cpp
+++ b/be/src/util/s3_util.cpp
@@ -139,6 +139,9 @@ std::shared_ptr<Aws::S3::S3Client>
S3ClientFactory::create(const S3Conf& s3_conf
Aws::Auth::AWSCredentials aws_cred(s3_conf.ak, s3_conf.sk);
DCHECK(!aws_cred.IsExpiredOrEmpty());
+ if (!s3_conf.token.empty()) {
+ aws_cred.SetSessionToken(s3_conf.token);
+ }
Aws::Client::ClientConfiguration aws_config =
S3ClientFactory::getClientConfiguration();
aws_config.endpointOverride = s3_conf.endpoint;
@@ -176,6 +179,9 @@ Status S3ClientFactory::convert_properties_to_s3_conf(
StringCaseMap<std::string> properties(prop.begin(), prop.end());
s3_conf->ak = properties.find(S3_AK)->second;
s3_conf->sk = properties.find(S3_SK)->second;
+ if (properties.find(S3_TOKEN) != properties.end()) {
+ s3_conf->token = properties.find(S3_TOKEN)->second;
+ }
s3_conf->endpoint = properties.find(S3_ENDPOINT)->second;
s3_conf->region = properties.find(S3_REGION)->second;
diff --git a/be/src/util/s3_util.h b/be/src/util/s3_util.h
index ec72d4d17a0..393b9d7f118 100644
--- a/be/src/util/s3_util.h
+++ b/be/src/util/s3_util.h
@@ -53,6 +53,7 @@ const static std::string S3_CONN_TIMEOUT_MS =
"AWS_CONNECTION_TIMEOUT_MS";
struct S3Conf {
std::string ak;
std::string sk;
+ std::string token;
std::string endpoint;
std::string region;
std::string bucket;
@@ -64,9 +65,10 @@ struct S3Conf {
std::string to_string() const {
return fmt::format(
- "(ak={}, sk=*, endpoint={}, region={}, bucket={}, prefix={},
max_connections={}, "
- "request_timeout_ms={}, connect_timeout_ms={},
use_virtual_addressing={})",
- ak, endpoint, region, bucket, prefix, max_connections,
request_timeout_ms,
+ "(ak={}, sk=*, token={}, endpoint={}, region={}, bucket={},
prefix={}, "
+ "max_connections={}, request_timeout_ms={},
connect_timeout_ms={}, "
+ "use_virtual_addressing={})",
+ ak, token, endpoint, region, bucket, prefix, max_connections,
request_timeout_ms,
connect_timeout_ms, use_virtual_addressing);
}
@@ -74,6 +76,7 @@ struct S3Conf {
uint64_t hash_code = 0;
hash_code += Fingerprint(ak);
hash_code += Fingerprint(sk);
+ hash_code += Fingerprint(token);
hash_code += Fingerprint(endpoint);
hash_code += Fingerprint(region);
hash_code += Fingerprint(bucket);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]