mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
enhance: Support MinIO TLS connection (#31311)
issue: https://github.com/milvus-io/milvus/issues/30709 pr: #31292 Signed-off-by: yhmo <yihua.mo@zilliz.com> Co-authored-by: Chen Rao <chenrao317328@163.com>
This commit is contained in:
parent
cf5109ec17
commit
c81909bfab
@ -68,7 +68,9 @@ minio:
|
|||||||
port: 9000 # Port of MinIO/S3
|
port: 9000 # Port of MinIO/S3
|
||||||
accessKeyID: minioadmin # accessKeyID of MinIO/S3
|
accessKeyID: minioadmin # accessKeyID of MinIO/S3
|
||||||
secretAccessKey: minioadmin # MinIO/S3 encryption string
|
secretAccessKey: minioadmin # MinIO/S3 encryption string
|
||||||
useSSL: false # Access to MinIO/S3 with SSL
|
ssl:
|
||||||
|
enabled: false # Access to MinIO/S3 with SSL
|
||||||
|
tlsCACert: /path/to/public.crt # path to your CACert file, ignore when it is empty
|
||||||
bucketName: a-bucket # Bucket name in MinIO/S3
|
bucketName: a-bucket # Bucket name in MinIO/S3
|
||||||
rootPath: files # The root path where the message is stored in MinIO/S3
|
rootPath: files # The root path where the message is stored in MinIO/S3
|
||||||
# Whether to useIAM role to access S3/GCS instead of access/secret keys
|
# Whether to useIAM role to access S3/GCS instead of access/secret keys
|
||||||
|
|||||||
@ -87,6 +87,7 @@ typedef struct CStorageConfig {
|
|||||||
const char* log_level;
|
const char* log_level;
|
||||||
const char* region;
|
const char* region;
|
||||||
bool useSSL;
|
bool useSSL;
|
||||||
|
const char* sslCACert;
|
||||||
bool useIAM;
|
bool useIAM;
|
||||||
bool useVirtualHost;
|
bool useVirtualHost;
|
||||||
int64_t requestTimeoutMs;
|
int64_t requestTimeoutMs;
|
||||||
|
|||||||
@ -487,6 +487,7 @@ NewBuildIndexInfo(CBuildIndexInfo* c_build_index_info,
|
|||||||
storage_config.cloud_provider =
|
storage_config.cloud_provider =
|
||||||
std::string(c_storage_config.cloud_provider);
|
std::string(c_storage_config.cloud_provider);
|
||||||
storage_config.useSSL = c_storage_config.useSSL;
|
storage_config.useSSL = c_storage_config.useSSL;
|
||||||
|
storage_config.sslCACert = c_storage_config.sslCACert;
|
||||||
storage_config.useIAM = c_storage_config.useIAM;
|
storage_config.useIAM = c_storage_config.useIAM;
|
||||||
storage_config.region = c_storage_config.region;
|
storage_config.region = c_storage_config.region;
|
||||||
storage_config.useVirtualHost = c_storage_config.useVirtualHost;
|
storage_config.useVirtualHost = c_storage_config.useVirtualHost;
|
||||||
|
|||||||
@ -55,12 +55,15 @@ generateConfig(const StorageConfig& storage_config) {
|
|||||||
|
|
||||||
if (storage_config.useSSL) {
|
if (storage_config.useSSL) {
|
||||||
config.scheme = Aws::Http::Scheme::HTTPS;
|
config.scheme = Aws::Http::Scheme::HTTPS;
|
||||||
config.verifySSL = true;
|
|
||||||
} else {
|
} else {
|
||||||
config.scheme = Aws::Http::Scheme::HTTP;
|
config.scheme = Aws::Http::Scheme::HTTP;
|
||||||
config.verifySSL = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!storage_config.sslCACert.empty()) {
|
||||||
|
config.caPath = ConvertToAwsString(storage_config.sslCACert);
|
||||||
|
}
|
||||||
|
config.verifySSL = false;
|
||||||
|
|
||||||
if (!storage_config.region.empty()) {
|
if (!storage_config.region.empty()) {
|
||||||
config.region = ConvertToAwsString(storage_config.region);
|
config.region = ConvertToAwsString(storage_config.region);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -324,12 +324,15 @@ MinioChunkManager::MinioChunkManager(const StorageConfig& storage_config)
|
|||||||
|
|
||||||
if (storage_config.useSSL) {
|
if (storage_config.useSSL) {
|
||||||
config.scheme = Aws::Http::Scheme::HTTPS;
|
config.scheme = Aws::Http::Scheme::HTTPS;
|
||||||
config.verifySSL = true;
|
|
||||||
} else {
|
} else {
|
||||||
config.scheme = Aws::Http::Scheme::HTTP;
|
config.scheme = Aws::Http::Scheme::HTTP;
|
||||||
config.verifySSL = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!storage_config.sslCACert.empty()) {
|
||||||
|
config.caPath = ConvertToAwsString(storage_config.sslCACert);
|
||||||
|
}
|
||||||
|
config.verifySSL = false;
|
||||||
|
|
||||||
config.requestTimeoutMs = storage_config.requestTimeoutMs == 0
|
config.requestTimeoutMs = storage_config.requestTimeoutMs == 0
|
||||||
? DEFAULT_CHUNK_MANAGER_REQUEST_TIMEOUT_MS
|
? DEFAULT_CHUNK_MANAGER_REQUEST_TIMEOUT_MS
|
||||||
: storage_config.requestTimeoutMs;
|
: storage_config.requestTimeoutMs;
|
||||||
|
|||||||
@ -96,6 +96,7 @@ struct StorageConfig {
|
|||||||
std::string log_level = "warn";
|
std::string log_level = "warn";
|
||||||
std::string region = "";
|
std::string region = "";
|
||||||
bool useSSL = false;
|
bool useSSL = false;
|
||||||
|
std::string sslCACert = "";
|
||||||
bool useIAM = false;
|
bool useIAM = false;
|
||||||
bool useVirtualHost = false;
|
bool useVirtualHost = false;
|
||||||
int64_t requestTimeoutMs = 3000;
|
int64_t requestTimeoutMs = 3000;
|
||||||
@ -108,6 +109,7 @@ struct StorageConfig {
|
|||||||
<< ", cloud_provider=" << cloud_provider
|
<< ", cloud_provider=" << cloud_provider
|
||||||
<< ", iam_endpoint=" << iam_endpoint << ", log_level=" << log_level
|
<< ", iam_endpoint=" << iam_endpoint << ", log_level=" << log_level
|
||||||
<< ", region=" << region << ", useSSL=" << std::boolalpha << useSSL
|
<< ", region=" << region << ", useSSL=" << std::boolalpha << useSSL
|
||||||
|
<< ", sslCACert=" << sslCACert.size() // only print cert length
|
||||||
<< ", useIAM=" << std::boolalpha << useIAM
|
<< ", useIAM=" << std::boolalpha << useIAM
|
||||||
<< ", useVirtualHost=" << std::boolalpha << useVirtualHost
|
<< ", useVirtualHost=" << std::boolalpha << useVirtualHost
|
||||||
<< ", requestTimeoutMs=" << requestTimeoutMs << "]";
|
<< ", requestTimeoutMs=" << requestTimeoutMs << "]";
|
||||||
|
|||||||
@ -71,6 +71,7 @@ InitRemoteChunkManagerSingleton(CStorageConfig c_storage_config) {
|
|||||||
std::string(c_storage_config.cloud_provider);
|
std::string(c_storage_config.cloud_provider);
|
||||||
storage_config.log_level = std::string(c_storage_config.log_level);
|
storage_config.log_level = std::string(c_storage_config.log_level);
|
||||||
storage_config.useSSL = c_storage_config.useSSL;
|
storage_config.useSSL = c_storage_config.useSSL;
|
||||||
|
storage_config.sslCACert = std::string(c_storage_config.sslCACert);
|
||||||
storage_config.useIAM = c_storage_config.useIAM;
|
storage_config.useIAM = c_storage_config.useIAM;
|
||||||
storage_config.useVirtualHost = c_storage_config.useVirtualHost;
|
storage_config.useVirtualHost = c_storage_config.useVirtualHost;
|
||||||
storage_config.region = c_storage_config.region;
|
storage_config.region = c_storage_config.region;
|
||||||
|
|||||||
@ -30,6 +30,7 @@ get_default_storage_config(bool useIam) {
|
|||||||
"K1SZFPTOtr/KBHBeksoGMGw==";
|
"K1SZFPTOtr/KBHBeksoGMGw==";
|
||||||
auto rootPath = "files";
|
auto rootPath = "files";
|
||||||
auto useSSL = false;
|
auto useSSL = false;
|
||||||
|
auto sslCACert = "";
|
||||||
auto iamEndPoint = "";
|
auto iamEndPoint = "";
|
||||||
auto bucketName = "a-bucket";
|
auto bucketName = "a-bucket";
|
||||||
|
|
||||||
@ -44,6 +45,7 @@ get_default_storage_config(bool useIam) {
|
|||||||
"error",
|
"error",
|
||||||
"",
|
"",
|
||||||
useSSL,
|
useSSL,
|
||||||
|
sslCACert,
|
||||||
useIam};
|
useIam};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,8 @@ class MinioChunkManagerTest : public testing::Test {
|
|||||||
// auto accessKey = "";
|
// auto accessKey = "";
|
||||||
// auto accessValue = "";
|
// auto accessValue = "";
|
||||||
// auto rootPath = "files";
|
// auto rootPath = "files";
|
||||||
// auto useSSL = true;
|
// auto useSSL = false;
|
||||||
|
// auto sslCACert = "";
|
||||||
// auto useIam = true;
|
// auto useIam = true;
|
||||||
// auto iamEndPoint = "";
|
// auto iamEndPoint = "";
|
||||||
// auto bucketName = "vdc-infra-poc";
|
// auto bucketName = "vdc-infra-poc";
|
||||||
@ -63,6 +64,7 @@ class MinioChunkManagerTest : public testing::Test {
|
|||||||
// logLevel,
|
// logLevel,
|
||||||
// region,
|
// region,
|
||||||
// useSSL,
|
// useSSL,
|
||||||
|
// sslCACert,
|
||||||
// useIam};
|
// useIam};
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|||||||
@ -41,6 +41,7 @@ get_default_remote_storage_config() {
|
|||||||
storage_config.storage_type = "remote";
|
storage_config.storage_type = "remote";
|
||||||
storage_config.cloud_provider = "";
|
storage_config.cloud_provider = "";
|
||||||
storage_config.useSSL = false;
|
storage_config.useSSL = false;
|
||||||
|
storage_config.sslCACert = "";
|
||||||
storage_config.useIAM = false;
|
storage_config.useIAM = false;
|
||||||
return storage_config;
|
return storage_config;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ get_azure_storage_config() {
|
|||||||
"error",
|
"error",
|
||||||
"",
|
"",
|
||||||
false,
|
false,
|
||||||
|
"",
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
30000};
|
30000};
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -256,6 +257,14 @@ func Test_garbageCollector_scan(t *testing.T) {
|
|||||||
// initialize unit test sso env
|
// initialize unit test sso env
|
||||||
func initUtOSSEnv(bucket, root string, n int) (mcm *storage.MinioChunkManager, inserts []string, stats []string, delta []string, other []string, err error) {
|
func initUtOSSEnv(bucket, root string, n int) (mcm *storage.MinioChunkManager, inserts []string, stats []string, delta []string, other []string, err error) {
|
||||||
paramtable.Init()
|
paramtable.Init()
|
||||||
|
|
||||||
|
if Params.MinioCfg.UseSSL.GetAsBool() && len(Params.MinioCfg.SslCACert.GetValue()) > 0 {
|
||||||
|
err := os.Setenv("SSL_CERT_FILE", Params.MinioCfg.SslCACert.GetValue())
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, nil, nil, nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cli, err := minio.New(Params.MinioCfg.Address.GetValue(), &minio.Options{
|
cli, err := minio.New(Params.MinioCfg.Address.GetValue(), &minio.Options{
|
||||||
Creds: credentials.NewStaticV4(Params.MinioCfg.AccessKeyID.GetValue(), Params.MinioCfg.SecretAccessKey.GetValue(), ""),
|
Creds: credentials.NewStaticV4(Params.MinioCfg.AccessKeyID.GetValue(), Params.MinioCfg.SecretAccessKey.GetValue(), ""),
|
||||||
Secure: Params.MinioCfg.UseSSL.GetAsBool(),
|
Secure: Params.MinioCfg.UseSSL.GetAsBool(),
|
||||||
|
|||||||
@ -319,6 +319,7 @@ func (ib *indexBuilder) process(buildID UniqueID) bool {
|
|||||||
AccessKeyID: Params.MinioCfg.AccessKeyID.GetValue(),
|
AccessKeyID: Params.MinioCfg.AccessKeyID.GetValue(),
|
||||||
SecretAccessKey: Params.MinioCfg.SecretAccessKey.GetValue(),
|
SecretAccessKey: Params.MinioCfg.SecretAccessKey.GetValue(),
|
||||||
UseSSL: Params.MinioCfg.UseSSL.GetAsBool(),
|
UseSSL: Params.MinioCfg.UseSSL.GetAsBool(),
|
||||||
|
SslCACert: Params.MinioCfg.SslCACert.GetValue(),
|
||||||
BucketName: Params.MinioCfg.BucketName.GetValue(),
|
BucketName: Params.MinioCfg.BucketName.GetValue(),
|
||||||
RootPath: Params.MinioCfg.RootPath.GetValue(),
|
RootPath: Params.MinioCfg.RootPath.GetValue(),
|
||||||
UseIAM: Params.MinioCfg.UseIAM.GetAsBool(),
|
UseIAM: Params.MinioCfg.UseIAM.GetAsBool(),
|
||||||
|
|||||||
@ -30,6 +30,7 @@ func (m *chunkMgrFactory) NewChunkManager(ctx context.Context, config *indexpb.S
|
|||||||
storage.AccessKeyID(config.GetAccessKeyID()),
|
storage.AccessKeyID(config.GetAccessKeyID()),
|
||||||
storage.SecretAccessKeyID(config.GetSecretAccessKey()),
|
storage.SecretAccessKeyID(config.GetSecretAccessKey()),
|
||||||
storage.UseSSL(config.GetUseSSL()),
|
storage.UseSSL(config.GetUseSSL()),
|
||||||
|
storage.SslCACert(config.GetSslCACert()),
|
||||||
storage.BucketName(config.GetBucketName()),
|
storage.BucketName(config.GetBucketName()),
|
||||||
storage.UseIAM(config.GetUseIAM()),
|
storage.UseIAM(config.GetUseIAM()),
|
||||||
storage.CloudProvider(config.GetCloudProvider()),
|
storage.CloudProvider(config.GetCloudProvider()),
|
||||||
|
|||||||
@ -240,6 +240,7 @@ message StorageConfig {
|
|||||||
string region = 11;
|
string region = 11;
|
||||||
string cloud_provider = 12;
|
string cloud_provider = 12;
|
||||||
int64 request_timeout_ms = 13;
|
int64 request_timeout_ms = 13;
|
||||||
|
string sslCACert = 14;
|
||||||
}
|
}
|
||||||
|
|
||||||
message OptionalFieldInfo {
|
message OptionalFieldInfo {
|
||||||
|
|||||||
@ -19,6 +19,7 @@ package accesslog
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -39,6 +40,7 @@ type config struct {
|
|||||||
accessKeyID string
|
accessKeyID string
|
||||||
secretAccessKeyID string
|
secretAccessKeyID string
|
||||||
useSSL bool
|
useSSL bool
|
||||||
|
sslCACert string
|
||||||
createBucket bool
|
createBucket bool
|
||||||
useIAM bool
|
useIAM bool
|
||||||
iamEndpoint string
|
iamEndpoint string
|
||||||
@ -78,6 +80,7 @@ func NewMinioHandler(ctx context.Context, cfg *paramtable.MinioConfig, rootPath
|
|||||||
accessKeyID: cfg.AccessKeyID.GetValue(),
|
accessKeyID: cfg.AccessKeyID.GetValue(),
|
||||||
secretAccessKeyID: cfg.SecretAccessKey.GetValue(),
|
secretAccessKeyID: cfg.SecretAccessKey.GetValue(),
|
||||||
useSSL: cfg.UseSSL.GetAsBool(),
|
useSSL: cfg.UseSSL.GetAsBool(),
|
||||||
|
sslCACert: cfg.SslCACert.GetValue(),
|
||||||
createBucket: true,
|
createBucket: true,
|
||||||
useIAM: cfg.UseIAM.GetAsBool(),
|
useIAM: cfg.UseIAM.GetAsBool(),
|
||||||
iamEndpoint: cfg.IAMEndpoint.GetValue(),
|
iamEndpoint: cfg.IAMEndpoint.GetValue(),
|
||||||
@ -104,6 +107,14 @@ func newMinioClient(ctx context.Context, cfg config) (*minio.Client, error) {
|
|||||||
} else {
|
} else {
|
||||||
creds = credentials.NewStaticV4(cfg.accessKeyID, cfg.secretAccessKeyID, "")
|
creds = credentials.NewStaticV4(cfg.accessKeyID, cfg.secretAccessKeyID, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cfg.useSSL && len(cfg.sslCACert) > 0 {
|
||||||
|
err := os.Setenv("SSL_CERT_FILE", cfg.sslCACert)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minioClient, err := minio.New(cfg.address, &minio.Options{
|
minioClient, err := minio.New(cfg.address, &minio.Options{
|
||||||
Creds: creds,
|
Creds: creds,
|
||||||
Secure: cfg.useSSL,
|
Secure: cfg.useSSL,
|
||||||
|
|||||||
@ -33,6 +33,8 @@ func TestMinioHandler_ConnectError(t *testing.T) {
|
|||||||
params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
|
params.Init(paramtable.NewBaseTable(paramtable.SkipRemote(true)))
|
||||||
params.Save(params.MinioCfg.UseIAM.Key, "true")
|
params.Save(params.MinioCfg.UseIAM.Key, "true")
|
||||||
params.Save(params.MinioCfg.Address.Key, "")
|
params.Save(params.MinioCfg.Address.Key, "")
|
||||||
|
params.Save(params.MinioCfg.UseSSL.Key, "true")
|
||||||
|
params.Save(params.MinioCfg.SslCACert.Key, "/tmp/dummy.crt")
|
||||||
|
|
||||||
_, err := NewMinioHandler(
|
_, err := NewMinioHandler(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
|
|||||||
@ -724,6 +724,7 @@ func NewTestChunkManagerFactory(params *paramtable.ComponentParam, rootPath stri
|
|||||||
storage.AccessKeyID(params.MinioCfg.AccessKeyID.GetValue()),
|
storage.AccessKeyID(params.MinioCfg.AccessKeyID.GetValue()),
|
||||||
storage.SecretAccessKeyID(params.MinioCfg.SecretAccessKey.GetValue()),
|
storage.SecretAccessKeyID(params.MinioCfg.SecretAccessKey.GetValue()),
|
||||||
storage.UseSSL(params.MinioCfg.UseSSL.GetAsBool()),
|
storage.UseSSL(params.MinioCfg.UseSSL.GetAsBool()),
|
||||||
|
storage.SslCACert(params.MinioCfg.SslCACert.GetValue()),
|
||||||
storage.BucketName(params.MinioCfg.BucketName.GetValue()),
|
storage.BucketName(params.MinioCfg.BucketName.GetValue()),
|
||||||
storage.UseIAM(params.MinioCfg.UseIAM.GetAsBool()),
|
storage.UseIAM(params.MinioCfg.UseIAM.GetAsBool()),
|
||||||
storage.CloudProvider(params.MinioCfg.CloudProvider.GetValue()),
|
storage.CloudProvider(params.MinioCfg.CloudProvider.GetValue()),
|
||||||
@ -1171,6 +1172,7 @@ func genStorageConfig() *indexpb.StorageConfig {
|
|||||||
RootPath: paramtable.Get().MinioCfg.RootPath.GetValue(),
|
RootPath: paramtable.Get().MinioCfg.RootPath.GetValue(),
|
||||||
IAMEndpoint: paramtable.Get().MinioCfg.IAMEndpoint.GetValue(),
|
IAMEndpoint: paramtable.Get().MinioCfg.IAMEndpoint.GetValue(),
|
||||||
UseSSL: paramtable.Get().MinioCfg.UseSSL.GetAsBool(),
|
UseSSL: paramtable.Get().MinioCfg.UseSSL.GetAsBool(),
|
||||||
|
SslCACert: paramtable.Get().MinioCfg.SslCACert.GetValue(),
|
||||||
UseIAM: paramtable.Get().MinioCfg.UseIAM.GetAsBool(),
|
UseIAM: paramtable.Get().MinioCfg.UseIAM.GetAsBool(),
|
||||||
StorageType: paramtable.Get().CommonCfg.StorageType.GetValue(),
|
StorageType: paramtable.Get().CommonCfg.StorageType.GetValue(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,6 +23,7 @@ func NewChunkManagerFactoryWithParam(params *paramtable.ComponentParam) *ChunkMa
|
|||||||
AccessKeyID(params.MinioCfg.AccessKeyID.GetValue()),
|
AccessKeyID(params.MinioCfg.AccessKeyID.GetValue()),
|
||||||
SecretAccessKeyID(params.MinioCfg.SecretAccessKey.GetValue()),
|
SecretAccessKeyID(params.MinioCfg.SecretAccessKey.GetValue()),
|
||||||
UseSSL(params.MinioCfg.UseSSL.GetAsBool()),
|
UseSSL(params.MinioCfg.UseSSL.GetAsBool()),
|
||||||
|
SslCACert(params.MinioCfg.SslCACert.GetValue()),
|
||||||
BucketName(params.MinioCfg.BucketName.GetValue()),
|
BucketName(params.MinioCfg.BucketName.GetValue()),
|
||||||
UseIAM(params.MinioCfg.UseIAM.GetAsBool()),
|
UseIAM(params.MinioCfg.UseIAM.GetAsBool()),
|
||||||
CloudProvider(params.MinioCfg.CloudProvider.GetValue()),
|
CloudProvider(params.MinioCfg.CloudProvider.GetValue()),
|
||||||
|
|||||||
@ -38,12 +38,14 @@ func newMinIOChunkManager(ctx context.Context, bucketName string, rootPath strin
|
|||||||
accessKeyID := Params.MinioCfg.AccessKeyID.GetValue()
|
accessKeyID := Params.MinioCfg.AccessKeyID.GetValue()
|
||||||
secretAccessKey := Params.MinioCfg.SecretAccessKey.GetValue()
|
secretAccessKey := Params.MinioCfg.SecretAccessKey.GetValue()
|
||||||
useSSL := Params.MinioCfg.UseSSL.GetAsBool()
|
useSSL := Params.MinioCfg.UseSSL.GetAsBool()
|
||||||
|
sslCACert := Params.MinioCfg.SslCACert.GetValue()
|
||||||
client, err := NewMinioChunkManager(ctx,
|
client, err := NewMinioChunkManager(ctx,
|
||||||
RootPath(rootPath),
|
RootPath(rootPath),
|
||||||
Address(endPoint),
|
Address(endPoint),
|
||||||
AccessKeyID(accessKeyID),
|
AccessKeyID(accessKeyID),
|
||||||
SecretAccessKeyID(secretAccessKey),
|
SecretAccessKeyID(secretAccessKey),
|
||||||
UseSSL(useSSL),
|
UseSSL(useSSL),
|
||||||
|
SslCACert(sslCACert),
|
||||||
BucketName(bucketName),
|
BucketName(bucketName),
|
||||||
UseIAM(false),
|
UseIAM(false),
|
||||||
CloudProvider("aws"),
|
CloudProvider("aws"),
|
||||||
@ -69,11 +71,13 @@ func TestMinIOCMFail(t *testing.T) {
|
|||||||
accessKeyID := Params.MinioCfg.AccessKeyID.GetValue()
|
accessKeyID := Params.MinioCfg.AccessKeyID.GetValue()
|
||||||
secretAccessKey := Params.MinioCfg.SecretAccessKey.GetValue()
|
secretAccessKey := Params.MinioCfg.SecretAccessKey.GetValue()
|
||||||
useSSL := Params.MinioCfg.UseSSL.GetAsBool()
|
useSSL := Params.MinioCfg.UseSSL.GetAsBool()
|
||||||
|
sslCACert := Params.MinioCfg.SslCACert.GetValue()
|
||||||
client, err := NewMinioChunkManager(ctx,
|
client, err := NewMinioChunkManager(ctx,
|
||||||
Address("9.9.9.9:invalid"),
|
Address("9.9.9.9:invalid"),
|
||||||
AccessKeyID(accessKeyID),
|
AccessKeyID(accessKeyID),
|
||||||
SecretAccessKeyID(secretAccessKey),
|
SecretAccessKeyID(secretAccessKey),
|
||||||
UseSSL(useSSL),
|
UseSSL(useSSL),
|
||||||
|
SslCACert(sslCACert),
|
||||||
BucketName("test"),
|
BucketName("test"),
|
||||||
CreateBucket(true),
|
CreateBucket(true),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -105,6 +106,14 @@ func newMinioClient(ctx context.Context, c *config) (*minio.Client, error) {
|
|||||||
creds = credentials.NewStaticV4(c.accessKeyID, c.secretAccessKeyID, "")
|
creds = credentials.NewStaticV4(c.accessKeyID, c.secretAccessKeyID, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if c.useSSL && len(c.sslCACert) > 0 {
|
||||||
|
err := os.Setenv("SSL_CERT_FILE", c.sslCACert)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
minioOpts := &minio.Options{
|
minioOpts := &minio.Options{
|
||||||
BucketLookup: bucketLookupType,
|
BucketLookup: bucketLookupType,
|
||||||
Creds: creds,
|
Creds: creds,
|
||||||
|
|||||||
@ -201,6 +201,15 @@ func TestMinioObjectStorage(t *testing.T) {
|
|||||||
config.useIAM = false
|
config.useIAM = false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("test ssl", func(t *testing.T) {
|
||||||
|
var err error
|
||||||
|
config.useSSL = true
|
||||||
|
config.sslCACert = "/tmp/dummy.crt"
|
||||||
|
_, err = newMinioObjectStorageWithConfig(ctx, &config)
|
||||||
|
assert.Error(t, err)
|
||||||
|
config.useSSL = false
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("test cloud provider", func(t *testing.T) {
|
t.Run("test cloud provider", func(t *testing.T) {
|
||||||
var err error
|
var err error
|
||||||
cloudProvider := config.cloudProvider
|
cloudProvider := config.cloudProvider
|
||||||
|
|||||||
@ -7,6 +7,7 @@ type config struct {
|
|||||||
accessKeyID string
|
accessKeyID string
|
||||||
secretAccessKeyID string
|
secretAccessKeyID string
|
||||||
useSSL bool
|
useSSL bool
|
||||||
|
sslCACert string
|
||||||
createBucket bool
|
createBucket bool
|
||||||
rootPath string
|
rootPath string
|
||||||
useIAM bool
|
useIAM bool
|
||||||
@ -54,6 +55,12 @@ func UseSSL(useSSL bool) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SslCACert(sslCACert string) Option {
|
||||||
|
return func(c *config) {
|
||||||
|
c.sslCACert = sslCACert
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CreateBucket(createBucket bool) Option {
|
func CreateBucket(createBucket bool) Option {
|
||||||
return func(c *config) {
|
return func(c *config) {
|
||||||
c.createBucket = createBucket
|
c.createBucket = createBucket
|
||||||
|
|||||||
@ -44,6 +44,7 @@ func newRemoteChunkManager(ctx context.Context, cloudProvider string, bucketName
|
|||||||
AccessKeyID(Params.MinioCfg.AccessKeyID.GetValue()),
|
AccessKeyID(Params.MinioCfg.AccessKeyID.GetValue()),
|
||||||
SecretAccessKeyID(Params.MinioCfg.SecretAccessKey.GetValue()),
|
SecretAccessKeyID(Params.MinioCfg.SecretAccessKey.GetValue()),
|
||||||
UseSSL(Params.MinioCfg.UseSSL.GetAsBool()),
|
UseSSL(Params.MinioCfg.UseSSL.GetAsBool()),
|
||||||
|
SslCACert(Params.MinioCfg.SslCACert.GetValue()),
|
||||||
BucketName(bucketName),
|
BucketName(bucketName),
|
||||||
UseIAM(Params.MinioCfg.UseIAM.GetAsBool()),
|
UseIAM(Params.MinioCfg.UseIAM.GetAsBool()),
|
||||||
CloudProvider(cloudProvider),
|
CloudProvider(cloudProvider),
|
||||||
|
|||||||
@ -51,6 +51,7 @@ func NewBuildIndexInfo(config *indexpb.StorageConfig) (*BuildIndexInfo, error) {
|
|||||||
cIamEndPoint := C.CString(config.IAMEndpoint)
|
cIamEndPoint := C.CString(config.IAMEndpoint)
|
||||||
cRegion := C.CString(config.Region)
|
cRegion := C.CString(config.Region)
|
||||||
cCloudProvider := C.CString(config.CloudProvider)
|
cCloudProvider := C.CString(config.CloudProvider)
|
||||||
|
cSslCACert := C.CString(config.SslCACert)
|
||||||
defer C.free(unsafe.Pointer(cAddress))
|
defer C.free(unsafe.Pointer(cAddress))
|
||||||
defer C.free(unsafe.Pointer(cBucketName))
|
defer C.free(unsafe.Pointer(cBucketName))
|
||||||
defer C.free(unsafe.Pointer(cAccessKey))
|
defer C.free(unsafe.Pointer(cAccessKey))
|
||||||
@ -60,6 +61,7 @@ func NewBuildIndexInfo(config *indexpb.StorageConfig) (*BuildIndexInfo, error) {
|
|||||||
defer C.free(unsafe.Pointer(cIamEndPoint))
|
defer C.free(unsafe.Pointer(cIamEndPoint))
|
||||||
defer C.free(unsafe.Pointer(cRegion))
|
defer C.free(unsafe.Pointer(cRegion))
|
||||||
defer C.free(unsafe.Pointer(cCloudProvider))
|
defer C.free(unsafe.Pointer(cCloudProvider))
|
||||||
|
defer C.free(unsafe.Pointer(cSslCACert))
|
||||||
storageConfig := C.CStorageConfig{
|
storageConfig := C.CStorageConfig{
|
||||||
address: cAddress,
|
address: cAddress,
|
||||||
bucket_name: cBucketName,
|
bucket_name: cBucketName,
|
||||||
@ -70,6 +72,7 @@ func NewBuildIndexInfo(config *indexpb.StorageConfig) (*BuildIndexInfo, error) {
|
|||||||
iam_endpoint: cIamEndPoint,
|
iam_endpoint: cIamEndPoint,
|
||||||
cloud_provider: cCloudProvider,
|
cloud_provider: cCloudProvider,
|
||||||
useSSL: C.bool(config.UseSSL),
|
useSSL: C.bool(config.UseSSL),
|
||||||
|
sslCACert: cSslCACert,
|
||||||
useIAM: C.bool(config.UseIAM),
|
useIAM: C.bool(config.UseIAM),
|
||||||
region: cRegion,
|
region: cRegion,
|
||||||
useVirtualHost: C.bool(config.UseVirtualHost),
|
useVirtualHost: C.bool(config.UseVirtualHost),
|
||||||
|
|||||||
@ -436,6 +436,7 @@ func genStorageConfig() *indexpb.StorageConfig {
|
|||||||
RootPath: params.MinioCfg.RootPath.GetValue(),
|
RootPath: params.MinioCfg.RootPath.GetValue(),
|
||||||
IAMEndpoint: params.MinioCfg.IAMEndpoint.GetValue(),
|
IAMEndpoint: params.MinioCfg.IAMEndpoint.GetValue(),
|
||||||
UseSSL: params.MinioCfg.UseSSL.GetAsBool(),
|
UseSSL: params.MinioCfg.UseSSL.GetAsBool(),
|
||||||
|
SslCACert: params.MinioCfg.SslCACert.GetValue(),
|
||||||
UseIAM: params.MinioCfg.UseIAM.GetAsBool(),
|
UseIAM: params.MinioCfg.UseIAM.GetAsBool(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -75,6 +75,7 @@ func InitRemoteChunkManager(params *paramtable.ComponentParam) error {
|
|||||||
cCloudProvider := C.CString(params.MinioCfg.CloudProvider.GetValue())
|
cCloudProvider := C.CString(params.MinioCfg.CloudProvider.GetValue())
|
||||||
cLogLevel := C.CString(params.MinioCfg.LogLevel.GetValue())
|
cLogLevel := C.CString(params.MinioCfg.LogLevel.GetValue())
|
||||||
cRegion := C.CString(params.MinioCfg.Region.GetValue())
|
cRegion := C.CString(params.MinioCfg.Region.GetValue())
|
||||||
|
cSslCACert := C.CString(params.MinioCfg.SslCACert.GetValue())
|
||||||
defer C.free(unsafe.Pointer(cAddress))
|
defer C.free(unsafe.Pointer(cAddress))
|
||||||
defer C.free(unsafe.Pointer(cBucketName))
|
defer C.free(unsafe.Pointer(cBucketName))
|
||||||
defer C.free(unsafe.Pointer(cAccessKey))
|
defer C.free(unsafe.Pointer(cAccessKey))
|
||||||
@ -85,6 +86,7 @@ func InitRemoteChunkManager(params *paramtable.ComponentParam) error {
|
|||||||
defer C.free(unsafe.Pointer(cLogLevel))
|
defer C.free(unsafe.Pointer(cLogLevel))
|
||||||
defer C.free(unsafe.Pointer(cRegion))
|
defer C.free(unsafe.Pointer(cRegion))
|
||||||
defer C.free(unsafe.Pointer(cCloudProvider))
|
defer C.free(unsafe.Pointer(cCloudProvider))
|
||||||
|
defer C.free(unsafe.Pointer(cSslCACert))
|
||||||
storageConfig := C.CStorageConfig{
|
storageConfig := C.CStorageConfig{
|
||||||
address: cAddress,
|
address: cAddress,
|
||||||
bucket_name: cBucketName,
|
bucket_name: cBucketName,
|
||||||
@ -95,6 +97,7 @@ func InitRemoteChunkManager(params *paramtable.ComponentParam) error {
|
|||||||
iam_endpoint: cIamEndPoint,
|
iam_endpoint: cIamEndPoint,
|
||||||
cloud_provider: cCloudProvider,
|
cloud_provider: cCloudProvider,
|
||||||
useSSL: C.bool(params.MinioCfg.UseSSL.GetAsBool()),
|
useSSL: C.bool(params.MinioCfg.UseSSL.GetAsBool()),
|
||||||
|
sslCACert: cSslCACert,
|
||||||
useIAM: C.bool(params.MinioCfg.UseIAM.GetAsBool()),
|
useIAM: C.bool(params.MinioCfg.UseIAM.GetAsBool()),
|
||||||
log_level: cLogLevel,
|
log_level: cLogLevel,
|
||||||
region: cRegion,
|
region: cRegion,
|
||||||
|
|||||||
@ -1032,6 +1032,7 @@ type MinioConfig struct {
|
|||||||
AccessKeyID ParamItem `refreshable:"false"`
|
AccessKeyID ParamItem `refreshable:"false"`
|
||||||
SecretAccessKey ParamItem `refreshable:"false"`
|
SecretAccessKey ParamItem `refreshable:"false"`
|
||||||
UseSSL ParamItem `refreshable:"false"`
|
UseSSL ParamItem `refreshable:"false"`
|
||||||
|
SslCACert ParamItem `refreshable:"false"`
|
||||||
BucketName ParamItem `refreshable:"false"`
|
BucketName ParamItem `refreshable:"false"`
|
||||||
RootPath ParamItem `refreshable:"false"`
|
RootPath ParamItem `refreshable:"false"`
|
||||||
UseIAM ParamItem `refreshable:"false"`
|
UseIAM ParamItem `refreshable:"false"`
|
||||||
@ -1094,8 +1095,9 @@ func (p *MinioConfig) Init(base *BaseTable) {
|
|||||||
p.SecretAccessKey.Init(base.mgr)
|
p.SecretAccessKey.Init(base.mgr)
|
||||||
|
|
||||||
p.UseSSL = ParamItem{
|
p.UseSSL = ParamItem{
|
||||||
Key: "minio.useSSL",
|
Key: "minio.ssl.enabled",
|
||||||
Version: "2.0.0",
|
FallbackKeys: []string{"minio.useSSL"},
|
||||||
|
Version: "2.3.12",
|
||||||
DefaultValue: "false",
|
DefaultValue: "false",
|
||||||
PanicIfEmpty: true,
|
PanicIfEmpty: true,
|
||||||
Doc: "Access to MinIO/S3 with SSL",
|
Doc: "Access to MinIO/S3 with SSL",
|
||||||
@ -1103,6 +1105,14 @@ func (p *MinioConfig) Init(base *BaseTable) {
|
|||||||
}
|
}
|
||||||
p.UseSSL.Init(base.mgr)
|
p.UseSSL.Init(base.mgr)
|
||||||
|
|
||||||
|
p.SslCACert = ParamItem{
|
||||||
|
Key: "minio.ssl.tlsCACert",
|
||||||
|
Version: "2.3.12",
|
||||||
|
Doc: "path to your CACert file",
|
||||||
|
Export: true,
|
||||||
|
}
|
||||||
|
p.SslCACert.Init(base.mgr)
|
||||||
|
|
||||||
p.BucketName = ParamItem{
|
p.BucketName = ParamItem{
|
||||||
Key: "minio.bucketName",
|
Key: "minio.bucketName",
|
||||||
Version: "2.0.0",
|
Version: "2.0.0",
|
||||||
|
|||||||
@ -191,6 +191,8 @@ func TestServiceParam(t *testing.T) {
|
|||||||
|
|
||||||
assert.Equal(t, Params.UseSSL.GetAsBool(), false)
|
assert.Equal(t, Params.UseSSL.GetAsBool(), false)
|
||||||
|
|
||||||
|
assert.NotEmpty(t, Params.SslCACert.GetValue())
|
||||||
|
|
||||||
assert.Equal(t, Params.UseIAM.GetAsBool(), false)
|
assert.Equal(t, Params.UseIAM.GetAsBool(), false)
|
||||||
|
|
||||||
assert.Equal(t, Params.CloudProvider.GetValue(), "aws")
|
assert.Equal(t, Params.CloudProvider.GetValue(), "aws")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user