fix: 修复/api/v1/tenants/kv/storage-engine-config接口不返回华为云obs配置导致创建知识库弹窗存储引擎华为云OBS未正确显示不可用标识
fix: 修复租户default_provider为空时降级至local,而local未被允许时导致创建知识库报错: Storage provider is not allowed by STORAGE_ALLOW_LIST
This commit is contained in:
committed by
lyingbug
parent
e3b7ad98c2
commit
b3bb60f03c
@@ -559,6 +559,17 @@ func (h *SystemHandler) isKS3Configured(c *gin.Context) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// isOBSConfigured checks whether OBS connection info is available from tenant config or env.
|
||||
func (h *SystemHandler) isOBSConfigured(c *gin.Context) bool {
|
||||
if v, exists := c.Get(types.TenantInfoContextKey.String()); exists {
|
||||
if tenant, ok := v.(*types.Tenant); ok && tenant != nil && tenant.StorageEngineConfig != nil && tenant.StorageEngineConfig.OBS != nil {
|
||||
obsConf := tenant.StorageEngineConfig.OBS
|
||||
return obsConf.Endpoint != "" && obsConf.Region != "" && obsConf.AccessKey != "" && obsConf.SecretKey != "" && obsConf.BucketName != ""
|
||||
}
|
||||
}
|
||||
return h.isOBSEnvAvailable()
|
||||
}
|
||||
|
||||
// isTOSEnvAvailable checks whether TOS env vars are set.
|
||||
func (h *SystemHandler) isTOSEnvAvailable() bool {
|
||||
return os.Getenv("TOS_ENDPOINT") != "" &&
|
||||
@@ -568,9 +579,18 @@ func (h *SystemHandler) isTOSEnvAvailable() bool {
|
||||
os.Getenv("TOS_BUCKET_NAME") != ""
|
||||
}
|
||||
|
||||
// isOBSEnvAvailable checks whether OBS env vars are set.
|
||||
func (h *SystemHandler) isOBSEnvAvailable() bool {
|
||||
return os.Getenv("OBS_ENDPOINT") != "" &&
|
||||
os.Getenv("OBS_REGION") != "" &&
|
||||
os.Getenv("OBS_ACCESS_KEY") != "" &&
|
||||
os.Getenv("OBS_SECRET_KEY") != "" &&
|
||||
os.Getenv("OBS_BUCKET_NAME") != ""
|
||||
}
|
||||
|
||||
// StorageEngineStatusItem describes one storage engine's availability and description.
|
||||
type StorageEngineStatusItem struct {
|
||||
Name string `json:"name"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3"
|
||||
Name string `json:"name"` // "local", "minio", "cos", "tos", "s3", "oss", "ks3", "obs"
|
||||
Allowed bool `json:"allowed"`
|
||||
Available bool `json:"available"` // whether the engine can be used
|
||||
Description string `json:"description"` // short description for UI
|
||||
@@ -598,6 +618,7 @@ func (h *SystemHandler) GetStorageEngineStatus(c *gin.Context) {
|
||||
s3Configured := h.isS3Configured(c)
|
||||
ossConfigured := h.isOSSConfigured(c)
|
||||
ks3Configured := h.isKS3Configured(c)
|
||||
obsConfigured := h.isOBSConfigured(c)
|
||||
allowed := getAllowedStorageProviders()
|
||||
allowedProviders := make([]string, 0, len(supportedStorageProviders))
|
||||
for _, provider := range getSupportedStorageProviders() {
|
||||
@@ -613,6 +634,7 @@ func (h *SystemHandler) GetStorageEngineStatus(c *gin.Context) {
|
||||
{Name: "s3", Allowed: allowed["s3"], Available: s3Configured, Description: "AWS S3 与兼容对象存储服务,适合公有云与混合云部署"},
|
||||
{Name: "oss", Allowed: allowed["oss"], Available: ossConfigured, Description: "阿里云对象存储服务,适合公有云部署,支持 S3 兼容协议"},
|
||||
{Name: "ks3", Allowed: allowed["ks3"], Available: ks3Configured, Description: "金山云对象存储服务,适合公有云部署"},
|
||||
{Name: "obs", Allowed: allowed["obs"], Available: obsConfigured, Description: "华为云对象存储服务,适合公有云部署"},
|
||||
}
|
||||
c.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
|
||||
Reference in New Issue
Block a user