Coverage Report

Created: 2025-05-21 21:22

/root/doris/be/src/util/s3_util.cpp
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "util/s3_util.h"
19
20
#include <aws/core/auth/AWSAuthSigner.h>
21
#include <aws/core/auth/AWSCredentials.h>
22
#include <aws/core/auth/AWSCredentialsProviderChain.h>
23
#include <aws/core/client/DefaultRetryStrategy.h>
24
#include <aws/core/utils/logging/LogLevel.h>
25
#include <aws/core/utils/logging/LogSystemInterface.h>
26
#include <aws/core/utils/memory/stl/AWSStringStream.h>
27
#include <aws/identity-management/auth/STSAssumeRoleCredentialsProvider.h>
28
#include <aws/s3/S3Client.h>
29
#include <aws/sts/STSClient.h>
30
#include <bvar/reducer.h>
31
#include <util/string_util.h>
32
33
#include <atomic>
34
#ifdef USE_AZURE
35
#include <azure/storage/blobs/blob_container_client.hpp>
36
#endif
37
#include <cstdlib>
38
#include <filesystem>
39
#include <functional>
40
#include <memory>
41
#include <ostream>
42
#include <utility>
43
44
#include "common/config.h"
45
#include "common/logging.h"
46
#include "common/status.h"
47
#include "cpp/aws_logger.h"
48
#include "cpp/obj_retry_strategy.h"
49
#include "cpp/sync_point.h"
50
#ifdef USE_AZURE
51
#include "io/fs/azure_obj_storage_client.h"
52
#endif
53
#include "io/fs/obj_storage_client.h"
54
#include "io/fs/s3_obj_storage_client.h"
55
#include "runtime/exec_env.h"
56
#include "s3_uri.h"
57
#include "vec/exec/scan/scanner_scheduler.h"
58
59
namespace doris {
60
namespace s3_bvar {
61
bvar::LatencyRecorder s3_get_latency("s3_get");
62
bvar::LatencyRecorder s3_put_latency("s3_put");
63
bvar::LatencyRecorder s3_delete_object_latency("s3_delete_object");
64
bvar::LatencyRecorder s3_delete_objects_latency("s3_delete_objects");
65
bvar::LatencyRecorder s3_head_latency("s3_head");
66
bvar::LatencyRecorder s3_multi_part_upload_latency("s3_multi_part_upload");
67
bvar::LatencyRecorder s3_list_latency("s3_list");
68
bvar::LatencyRecorder s3_list_object_versions_latency("s3_list_object_versions");
69
bvar::LatencyRecorder s3_get_bucket_version_latency("s3_get_bucket_version");
70
bvar::LatencyRecorder s3_copy_object_latency("s3_copy_object");
71
}; // namespace s3_bvar
72
73
namespace {
74
75
2
doris::Status is_s3_conf_valid(const S3ClientConf& conf) {
76
2
    if (conf.endpoint.empty()) {
77
0
        return Status::InvalidArgument<false>("Invalid s3 conf, empty endpoint");
78
0
    }
79
2
    if (conf.region.empty()) {
80
0
        return Status::InvalidArgument<false>("Invalid s3 conf, empty region");
81
0
    }
82
83
2
    if (conf.role_arn.empty()) {
84
2
        if (conf.ak.empty()) {
85
0
            return Status::InvalidArgument<false>("Invalid s3 conf, empty ak");
86
0
        }
87
2
        if (conf.sk.empty()) {
88
0
            return Status::InvalidArgument<false>("Invalid s3 conf, empty sk");
89
0
        }
90
2
    }
91
2
    return Status::OK();
92
2
}
93
94
// Return true is convert `str` to int successfully
95
0
bool to_int(std::string_view str, int& res) {
96
0
    auto [_, ec] = std::from_chars(str.data(), str.data() + str.size(), res);
97
0
    return ec == std::errc {};
98
0
}
99
100
constexpr char USE_PATH_STYLE[] = "use_path_style";
101
102
constexpr char AZURE_PROVIDER_STRING[] = "AZURE";
103
constexpr char S3_PROVIDER[] = "provider";
104
constexpr char S3_AK[] = "AWS_ACCESS_KEY";
105
constexpr char S3_SK[] = "AWS_SECRET_KEY";
106
constexpr char S3_ENDPOINT[] = "AWS_ENDPOINT";
107
constexpr char S3_REGION[] = "AWS_REGION";
108
constexpr char S3_TOKEN[] = "AWS_TOKEN";
109
constexpr char S3_MAX_CONN_SIZE[] = "AWS_MAX_CONN_SIZE";
110
constexpr char S3_REQUEST_TIMEOUT_MS[] = "AWS_REQUEST_TIMEOUT_MS";
111
constexpr char S3_CONN_TIMEOUT_MS[] = "AWS_CONNECTION_TIMEOUT_MS";
112
constexpr char S3_NEED_OVERRIDE_ENDPOINT[] = "AWS_NEED_OVERRIDE_ENDPOINT";
113
114
constexpr char S3_ROLE_ARN[] = "AWS_ROLE_ARN";
115
constexpr char S3_EXTERNAL_ID[] = "AWS_EXTERNAL_ID";
116
} // namespace
117
118
bvar::Adder<int64_t> get_rate_limit_ns("get_rate_limit_ns");
119
bvar::Adder<int64_t> get_rate_limit_exceed_req_num("get_rate_limit_exceed_req_num");
120
bvar::Adder<int64_t> put_rate_limit_ns("put_rate_limit_ns");
121
bvar::Adder<int64_t> put_rate_limit_exceed_req_num("put_rate_limit_exceed_req_num");
122
123
0
S3RateLimiterHolder* S3ClientFactory::rate_limiter(S3RateLimitType type) {
124
0
    CHECK(type == S3RateLimitType::GET || type == S3RateLimitType::PUT) << to_string(type);
125
0
    return _rate_limiters[static_cast<size_t>(type)].get();
126
0
}
127
128
0
int reset_s3_rate_limiter(S3RateLimitType type, size_t max_speed, size_t max_burst, size_t limit) {
129
0
    if (type == S3RateLimitType::UNKNOWN) {
130
0
        return -1;
131
0
    }
132
0
    return S3ClientFactory::instance().rate_limiter(type)->reset(max_speed, max_burst, limit);
133
0
}
134
135
1
S3ClientFactory::S3ClientFactory() {
136
1
    _aws_options = Aws::SDKOptions {};
137
1
    auto logLevel = static_cast<Aws::Utils::Logging::LogLevel>(config::aws_log_level);
138
1
    _aws_options.loggingOptions.logLevel = logLevel;
139
1
    _aws_options.loggingOptions.logger_create_fn = [logLevel] {
140
1
        return std::make_shared<DorisAWSLogger>(logLevel);
141
1
    };
142
1
    Aws::InitAPI(_aws_options);
143
1
    _ca_cert_file_path = get_valid_ca_cert_path(doris::split(config::ca_cert_file_paths, ";"));
144
1
    _rate_limiters = {
145
1
            std::make_unique<S3RateLimiterHolder>(
146
1
                    config::s3_get_token_per_second, config::s3_get_bucket_tokens,
147
1
                    config::s3_get_token_limit,
148
1
                    metric_func_factory(get_rate_limit_ns, get_rate_limit_exceed_req_num)),
149
1
            std::make_unique<S3RateLimiterHolder>(
150
1
                    config::s3_put_token_per_second, config::s3_put_bucket_tokens,
151
1
                    config::s3_put_token_limit,
152
1
                    metric_func_factory(put_rate_limit_ns, put_rate_limit_exceed_req_num))};
153
1
}
154
155
1
S3ClientFactory::~S3ClientFactory() {
156
1
    Aws::ShutdownAPI(_aws_options);
157
1
}
158
159
3
S3ClientFactory& S3ClientFactory::instance() {
160
3
    static S3ClientFactory ret;
161
3
    return ret;
162
3
}
163
164
2
std::shared_ptr<io::ObjStorageClient> S3ClientFactory::create(const S3ClientConf& s3_conf) {
165
2
    if (!is_s3_conf_valid(s3_conf).ok()) {
166
0
        return nullptr;
167
0
    }
168
169
2
    uint64_t hash = s3_conf.get_hash();
170
2
    {
171
2
        std::lock_guard l(_lock);
172
2
        auto it = _cache.find(hash);
173
2
        if (it != _cache.end()) {
174
0
            return it->second;
175
0
        }
176
2
    }
177
178
2
    auto obj_client = (s3_conf.provider == io::ObjStorageType::AZURE)
179
2
                              ? _create_azure_client(s3_conf)
180
2
                              : _create_s3_client(s3_conf);
181
182
2
    {
183
2
        uint64_t hash = s3_conf.get_hash();
184
2
        std::lock_guard l(_lock);
185
2
        _cache[hash] = obj_client;
186
2
    }
187
2
    return obj_client;
188
2
}
189
190
std::shared_ptr<io::ObjStorageClient> S3ClientFactory::_create_azure_client(
191
0
        const S3ClientConf& s3_conf) {
192
0
#ifdef USE_AZURE
193
0
    auto cred =
194
0
            std::make_shared<Azure::Storage::StorageSharedKeyCredential>(s3_conf.ak, s3_conf.sk);
195
196
0
    const std::string container_name = s3_conf.bucket;
197
0
    std::string uri;
198
0
    if (config::force_azure_blob_global_endpoint) {
199
0
        uri = fmt::format("https://{}.blob.core.windows.net/{}", s3_conf.ak, container_name);
200
0
    } else {
201
0
        uri = fmt::format("{}/{}", s3_conf.endpoint, container_name);
202
0
        if (s3_conf.endpoint.find("://") == std::string::npos) {
203
0
            uri = "https://" + uri;
204
0
        }
205
0
    }
206
207
0
    auto containerClient = std::make_shared<Azure::Storage::Blobs::BlobContainerClient>(uri, cred);
208
0
    LOG_INFO("create one azure client with {}", s3_conf.to_string());
209
0
    return std::make_shared<io::AzureObjStorageClient>(std::move(containerClient));
210
#else
211
    LOG_FATAL("BE is not compiled with azure support, export BUILD_AZURE=ON before building");
212
    return nullptr;
213
#endif
214
0
}
215
216
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> S3ClientFactory::get_aws_credentials_provider(
217
1
        const S3ClientConf& s3_conf) {
218
1
    if (!s3_conf.ak.empty() && !s3_conf.sk.empty()) {
219
1
        Aws::Auth::AWSCredentials aws_cred(s3_conf.ak, s3_conf.sk);
220
1
        DCHECK(!aws_cred.IsExpiredOrEmpty());
221
1
        if (!s3_conf.token.empty()) {
222
0
            aws_cred.SetSessionToken(s3_conf.token);
223
0
        }
224
1
        return std::make_shared<Aws::Auth::SimpleAWSCredentialsProvider>(std::move(aws_cred));
225
1
    }
226
227
0
    if (s3_conf.cred_provider_type == CredProviderType::InstanceProfile) {
228
0
        if (s3_conf.role_arn.empty()) {
229
0
            return std::make_shared<Aws::Auth::InstanceProfileCredentialsProvider>();
230
0
        }
231
232
0
        Aws::Client::ClientConfiguration clientConfiguration =
233
0
                S3ClientFactory::getClientConfiguration();
234
235
0
        if (_ca_cert_file_path.empty()) {
236
0
            _ca_cert_file_path =
237
0
                    get_valid_ca_cert_path(doris::split(config::ca_cert_file_paths, ";"));
238
0
        }
239
0
        if (!_ca_cert_file_path.empty()) {
240
0
            clientConfiguration.caFile = _ca_cert_file_path;
241
0
        }
242
243
0
        auto stsClient = std::make_shared<Aws::STS::STSClient>(
244
0
                std::make_shared<Aws::Auth::InstanceProfileCredentialsProvider>(),
245
0
                clientConfiguration);
246
247
0
        return std::make_shared<Aws::Auth::STSAssumeRoleCredentialsProvider>(
248
0
                s3_conf.role_arn, Aws::String(), s3_conf.external_id,
249
0
                Aws::Auth::DEFAULT_CREDS_LOAD_FREQ_SECONDS, stsClient);
250
0
    }
251
0
    return std::make_shared<Aws::Auth::DefaultAWSCredentialsProviderChain>();
252
0
}
253
254
std::shared_ptr<io::ObjStorageClient> S3ClientFactory::_create_s3_client(
255
2
        const S3ClientConf& s3_conf) {
256
2
    TEST_SYNC_POINT_RETURN_WITH_VALUE(
257
1
            "s3_client_factory::create",
258
1
            std::make_shared<io::S3ObjStorageClient>(std::make_shared<Aws::S3::S3Client>()));
259
1
    Aws::Client::ClientConfiguration aws_config = S3ClientFactory::getClientConfiguration();
260
1
    if (s3_conf.need_override_endpoint) {
261
1
        aws_config.endpointOverride = s3_conf.endpoint;
262
1
    }
263
1
    aws_config.region = s3_conf.region;
264
265
1
    if (_ca_cert_file_path.empty()) {
266
0
        _ca_cert_file_path = get_valid_ca_cert_path(doris::split(config::ca_cert_file_paths, ";"));
267
0
    }
268
269
1
    if (!_ca_cert_file_path.empty()) {
270
1
        aws_config.caFile = _ca_cert_file_path;
271
1
    }
272
273
1
    if (s3_conf.max_connections > 0) {
274
0
        aws_config.maxConnections = s3_conf.max_connections;
275
1
    } else {
276
1
#ifdef BE_TEST
277
        // the S3Client may shared by many threads.
278
        // So need to set the number of connections large enough.
279
1
        aws_config.maxConnections = config::doris_scanner_thread_pool_thread_num;
280
#else
281
        aws_config.maxConnections =
282
                ExecEnv::GetInstance()->scanner_scheduler()->remote_thread_pool_max_thread_num();
283
#endif
284
1
    }
285
286
1
    aws_config.requestTimeoutMs = 30000;
287
1
    if (s3_conf.request_timeout_ms > 0) {
288
0
        aws_config.requestTimeoutMs = s3_conf.request_timeout_ms;
289
0
    }
290
291
1
    if (s3_conf.connect_timeout_ms > 0) {
292
0
        aws_config.connectTimeoutMs = s3_conf.connect_timeout_ms;
293
0
    }
294
295
1
    if (config::s3_client_http_scheme == "http") {
296
1
        aws_config.scheme = Aws::Http::Scheme::HTTP;
297
1
    }
298
299
1
    aws_config.retryStrategy = std::make_shared<S3CustomRetryStrategy>(
300
1
            config::max_s3_client_retry /*scaleFactor = 25*/);
301
302
1
    std::shared_ptr<Aws::S3::S3Client> new_client = std::make_shared<Aws::S3::S3Client>(
303
1
            get_aws_credentials_provider(s3_conf), std::move(aws_config),
304
1
            Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never,
305
1
            s3_conf.use_virtual_addressing);
306
307
1
    auto obj_client = std::make_shared<io::S3ObjStorageClient>(std::move(new_client));
308
1
    LOG_INFO("create one s3 client with {}", s3_conf.to_string());
309
1
    return obj_client;
310
2
}
311
312
Status S3ClientFactory::convert_properties_to_s3_conf(
313
0
        const std::map<std::string, std::string>& prop, const S3URI& s3_uri, S3Conf* s3_conf) {
314
0
    StringCaseMap<std::string> properties(prop.begin(), prop.end());
315
0
    if (auto it = properties.find(S3_AK); it != properties.end()) {
316
0
        s3_conf->client_conf.ak = it->second;
317
0
    }
318
0
    if (auto it = properties.find(S3_SK); it != properties.end()) {
319
0
        s3_conf->client_conf.sk = it->second;
320
0
    }
321
0
    if (auto it = properties.find(S3_TOKEN); it != properties.end()) {
322
0
        s3_conf->client_conf.token = it->second;
323
0
    }
324
0
    if (auto it = properties.find(S3_ENDPOINT); it != properties.end()) {
325
0
        s3_conf->client_conf.endpoint = it->second;
326
0
    }
327
0
    if (auto it = properties.find(S3_NEED_OVERRIDE_ENDPOINT); it != properties.end()) {
328
0
        s3_conf->client_conf.need_override_endpoint = (it->second == "true");
329
0
    }
330
0
    if (auto it = properties.find(S3_REGION); it != properties.end()) {
331
0
        s3_conf->client_conf.region = it->second;
332
0
    }
333
0
    if (auto it = properties.find(S3_MAX_CONN_SIZE); it != properties.end()) {
334
0
        if (!to_int(it->second, s3_conf->client_conf.max_connections)) {
335
0
            return Status::InvalidArgument("invalid {} value \"{}\"", S3_MAX_CONN_SIZE, it->second);
336
0
        }
337
0
    }
338
0
    if (auto it = properties.find(S3_REQUEST_TIMEOUT_MS); it != properties.end()) {
339
0
        if (!to_int(it->second, s3_conf->client_conf.request_timeout_ms)) {
340
0
            return Status::InvalidArgument("invalid {} value \"{}\"", S3_REQUEST_TIMEOUT_MS,
341
0
                                           it->second);
342
0
        }
343
0
    }
344
0
    if (auto it = properties.find(S3_CONN_TIMEOUT_MS); it != properties.end()) {
345
0
        if (!to_int(it->second, s3_conf->client_conf.connect_timeout_ms)) {
346
0
            return Status::InvalidArgument("invalid {} value \"{}\"", S3_CONN_TIMEOUT_MS,
347
0
                                           it->second);
348
0
        }
349
0
    }
350
0
    if (auto it = properties.find(S3_PROVIDER); it != properties.end()) {
351
        // S3 Provider properties should be case insensitive.
352
0
        if (0 == strcasecmp(it->second.c_str(), AZURE_PROVIDER_STRING)) {
353
0
            s3_conf->client_conf.provider = io::ObjStorageType::AZURE;
354
0
        }
355
0
    }
356
357
0
    if (s3_uri.get_bucket().empty()) {
358
0
        return Status::InvalidArgument("Invalid S3 URI {}, bucket is not specified",
359
0
                                       s3_uri.to_string());
360
0
    }
361
0
    s3_conf->bucket = s3_uri.get_bucket();
362
    // For azure's compatibility
363
0
    s3_conf->client_conf.bucket = s3_uri.get_bucket();
364
0
    s3_conf->prefix = "";
365
366
    // See https://sdk.amazonaws.com/cpp/api/LATEST/class_aws_1_1_s3_1_1_s3_client.html
367
0
    s3_conf->client_conf.use_virtual_addressing = true;
368
0
    if (auto it = properties.find(USE_PATH_STYLE); it != properties.end()) {
369
0
        s3_conf->client_conf.use_virtual_addressing = it->second != "true";
370
0
    }
371
372
0
    if (auto it = properties.find(S3_ROLE_ARN); it != properties.end()) {
373
0
        s3_conf->client_conf.cred_provider_type = CredProviderType::InstanceProfile;
374
0
        s3_conf->client_conf.role_arn = it->second;
375
0
    }
376
377
0
    if (auto it = properties.find(S3_EXTERNAL_ID); it != properties.end()) {
378
0
        s3_conf->client_conf.external_id = it->second;
379
0
    }
380
381
0
    if (auto st = is_s3_conf_valid(s3_conf->client_conf); !st.ok()) {
382
0
        return st;
383
0
    }
384
0
    return Status::OK();
385
0
}
386
387
0
static CredProviderType cred_provider_type_from_thrift(TCredProviderType::type cred_provider_type) {
388
0
    switch (cred_provider_type) {
389
0
    case TCredProviderType::DEFAULT:
390
0
        return CredProviderType::Default;
391
0
    case TCredProviderType::SIMPLE:
392
0
        return CredProviderType::Simple;
393
0
    case TCredProviderType::INSTANCE_PROFILE:
394
0
        return CredProviderType::InstanceProfile;
395
0
    default:
396
0
        __builtin_unreachable();
397
0
        LOG(WARNING) << "Invalid TCredProviderType value: " << cred_provider_type
398
0
                     << ", use default instead.";
399
0
        return CredProviderType::Default;
400
0
    }
401
0
}
402
403
0
S3Conf S3Conf::get_s3_conf(const cloud::ObjectStoreInfoPB& info) {
404
0
    S3Conf ret {
405
0
            .bucket = info.bucket(),
406
0
            .prefix = info.prefix(),
407
0
            .client_conf {
408
0
                    .endpoint = info.endpoint(),
409
0
                    .region = info.region(),
410
0
                    .ak = info.ak(),
411
0
                    .sk = info.sk(),
412
0
                    .token {},
413
0
                    .bucket = info.bucket(),
414
0
                    .provider = io::ObjStorageType::AWS,
415
0
                    .use_virtual_addressing =
416
0
                            info.has_use_path_style() ? !info.use_path_style() : true,
417
418
0
                    .role_arn = info.role_arn(),
419
0
                    .external_id = info.external_id(),
420
0
            },
421
0
            .sse_enabled = info.sse_enabled(),
422
0
    };
423
424
0
    if (info.has_cred_provider_type()) {
425
0
        ret.client_conf.cred_provider_type = cred_provider_type_from_pb(info.cred_provider_type());
426
0
    }
427
428
0
    io::ObjStorageType type = io::ObjStorageType::AWS;
429
0
    switch (info.provider()) {
430
0
    case cloud::ObjectStoreInfoPB_Provider_OSS:
431
0
        type = io::ObjStorageType::OSS;
432
0
        break;
433
0
    case cloud::ObjectStoreInfoPB_Provider_S3:
434
0
        type = io::ObjStorageType::AWS;
435
0
        break;
436
0
    case cloud::ObjectStoreInfoPB_Provider_COS:
437
0
        type = io::ObjStorageType::COS;
438
0
        break;
439
0
    case cloud::ObjectStoreInfoPB_Provider_OBS:
440
0
        type = io::ObjStorageType::OBS;
441
0
        break;
442
0
    case cloud::ObjectStoreInfoPB_Provider_BOS:
443
0
        type = io::ObjStorageType::BOS;
444
0
        break;
445
0
    case cloud::ObjectStoreInfoPB_Provider_GCP:
446
0
        type = io::ObjStorageType::GCP;
447
0
        break;
448
0
    case cloud::ObjectStoreInfoPB_Provider_AZURE:
449
0
        type = io::ObjStorageType::AZURE;
450
0
        break;
451
0
    default:
452
0
        __builtin_unreachable();
453
0
        LOG_FATAL("unknown provider type {}, info {}", info.provider(), ret.to_string());
454
0
    }
455
0
    ret.client_conf.provider = type;
456
0
    return ret;
457
0
}
458
459
0
S3Conf S3Conf::get_s3_conf(const TS3StorageParam& param) {
460
0
    S3Conf ret {
461
0
            .bucket = param.bucket,
462
0
            .prefix = param.root_path,
463
0
            .client_conf = {
464
0
                    .endpoint = param.endpoint,
465
0
                    .region = param.region,
466
0
                    .ak = param.ak,
467
0
                    .sk = param.sk,
468
0
                    .token = param.token,
469
0
                    .bucket = param.bucket,
470
0
                    .provider = io::ObjStorageType::AWS,
471
0
                    .max_connections = param.max_conn,
472
0
                    .request_timeout_ms = param.request_timeout_ms,
473
0
                    .connect_timeout_ms = param.conn_timeout_ms,
474
                    // When using cold heat separation in minio, user might use ip address directly,
475
                    // which needs enable use_virtual_addressing to true
476
0
                    .use_virtual_addressing = !param.use_path_style,
477
0
                    .role_arn = param.role_arn,
478
0
                    .external_id = param.external_id,
479
0
            }};
480
481
0
    if (param.__isset.cred_provider_type) {
482
0
        ret.client_conf.cred_provider_type =
483
0
                cred_provider_type_from_thrift(param.cred_provider_type);
484
0
    }
485
486
0
    io::ObjStorageType type = io::ObjStorageType::AWS;
487
0
    switch (param.provider) {
488
0
    case TObjStorageType::UNKNOWN:
489
0
        LOG_INFO("Receive one legal storage resource, set provider type to aws, param detail {}",
490
0
                 ret.to_string());
491
0
        type = io::ObjStorageType::AWS;
492
0
        break;
493
0
    case TObjStorageType::AWS:
494
0
        type = io::ObjStorageType::AWS;
495
0
        break;
496
0
    case TObjStorageType::AZURE:
497
0
        type = io::ObjStorageType::AZURE;
498
0
        break;
499
0
    case TObjStorageType::BOS:
500
0
        type = io::ObjStorageType::BOS;
501
0
        break;
502
0
    case TObjStorageType::COS:
503
0
        type = io::ObjStorageType::COS;
504
0
        break;
505
0
    case TObjStorageType::OBS:
506
0
        type = io::ObjStorageType::OBS;
507
0
        break;
508
0
    case TObjStorageType::OSS:
509
0
        type = io::ObjStorageType::OSS;
510
0
        break;
511
0
    case TObjStorageType::GCP:
512
0
        type = io::ObjStorageType::GCP;
513
0
        break;
514
0
    default:
515
0
        LOG_FATAL("unknown provider type {}, info {}", param.provider, ret.to_string());
516
0
        __builtin_unreachable();
517
0
    }
518
0
    ret.client_conf.provider = type;
519
0
    return ret;
520
0
}
521
522
} // end namespace doris