Skip to content

Commit 900939b

Browse files
authored
release: v6.4.0
2 parents 1f16426 + 11f6a5a commit 900939b

File tree

18 files changed

+1449
-22
lines changed

18 files changed

+1449
-22
lines changed

LICENSES/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Third-Party Licenses
2+
3+
This directory contains license files for third-party components used in this project.
4+
5+
## Directory Structure
6+
7+
- `apache/` - Apache Software Foundation licensed components
8+
- `apecloud/` - ApeCloud licensed components
9+
- `minio/` - MinIO licensed components
10+
- `rancher/` - Rancher licensed components
11+
12+
## Purpose
13+
14+
These licenses are maintained to ensure compliance with the licensing requirements of all third-party software integrated into this project.

LICENSES/apecloud/kubeblocks/LICENSE

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

api/api_routers/version2/v2Routers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,9 @@ func (v2 *V2) tenantNameRouter() chi.Router {
474474
r.Post("/servicecheck", controller.Check)
475475
r.Get("/image-repositories", controller.RegistryImageRepositories)
476476
r.Get("/image-tags", controller.RegistryImageTags)
477+
//tar包镜像解析和导入
478+
r.Post("/image/load", controller.LoadTarImage)
479+
r.Get("/image/load/{load_id}", controller.GetTarLoadResult)
477480
r.Get("/servicecheck/{uuid}", controller.GetServiceCheckInfo)
478481
r.Get("/resources", controller.GetManager().SingleTenantResources)
479482
r.Get("/services", controller.GetManager().ServicesInfo)

api/controller/apigateway/api_gateway_route.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,18 @@ func (g Struct) GetTCPBindDomains(w http.ResponseWriter, r *http.Request) {
124124

125125
k := k8s.Default().Clientset.CoreV1()
126126
serviceAlias := r.URL.Query().Get("service_alias")
127+
port := r.URL.Query().Get("port")
127128
// Only keep the value before the comma
128129
if idx := strings.Index(serviceAlias, ","); idx != -1 {
129130
serviceAlias = serviceAlias[:idx]
130131
}
131132
labelSelector := fmt.Sprintf("tcp=true,service_alias=%v,outer=true", serviceAlias)
132133

134+
// If port is specified, filter by port label to get only the specific port's NodePort
135+
if port != "" {
136+
labelSelector = fmt.Sprintf("tcp=true,service_alias=%v,outer=true,port=%v", serviceAlias, port)
137+
}
138+
133139
list, err := k.Services(tenant.Namespace).List(r.Context(), v1.ListOptions{
134140
LabelSelector: labelSelector,
135141
})
@@ -567,16 +573,33 @@ func (g Struct) DeleteTCPRoute(w http.ResponseWriter, r *http.Request) {
567573
name := chi.URLParam(r, "name")
568574

569575
k := k8s.Default().Clientset.CoreV1()
570-
err := k.Services(tenant.Namespace).Delete(r.Context(), name, v1.DeleteOptions{})
576+
577+
// Get the Service first to verify it exists and log its labels for debugging
578+
service, err := k.Services(tenant.Namespace).Get(r.Context(), name, v1.GetOptions{})
571579
if err != nil {
572580
if errors.IsNotFound(err) {
581+
logrus.Infof("Service %s not found, treating as already deleted", name)
573582
httputil.ReturnSuccess(r, w, name)
574-
} else {
575-
logrus.Errorf("delete route error %s", err.Error())
576-
httputil.ReturnBcodeError(r, w, bcode.ErrRouteDelete)
583+
return
577584
}
585+
logrus.Errorf("failed to get service %s: %v", name, err)
586+
httputil.ReturnBcodeError(r, w, bcode.ErrRouteDelete)
578587
return
579588
}
589+
590+
// Log the Service details for debugging
591+
logrus.Infof("Deleting TCP route Service: %s, labels: %v, port: %v",
592+
name, service.Labels, service.Spec.Ports[0].Port)
593+
594+
// Delete the Service
595+
err = k.Services(tenant.Namespace).Delete(r.Context(), name, v1.DeleteOptions{})
596+
if err != nil {
597+
logrus.Errorf("delete route error %s", err.Error())
598+
httputil.ReturnBcodeError(r, w, bcode.ErrRouteDelete)
599+
return
600+
}
601+
602+
logrus.Infof("Successfully deleted TCP route Service: %s", name)
580603
httputil.ReturnSuccess(r, w, name)
581604
}
582605

api/controller/tar_image.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
2+
// RAINBOND, Application Management Platform
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version. For any non-GPL usage of Rainbond,
8+
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9+
// must be obtained first.
10+
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
package controller
20+
21+
import (
22+
"net/http"
23+
24+
"github.com/go-chi/chi"
25+
"github.com/goodrain/rainbond/api/handler"
26+
api_model "github.com/goodrain/rainbond/api/model"
27+
ctxutil "github.com/goodrain/rainbond/api/util/ctx"
28+
httputil "github.com/goodrain/rainbond/util/http"
29+
)
30+
31+
// LoadTarImage 开始解析tar包镜像
32+
func LoadTarImage(w http.ResponseWriter, r *http.Request) {
33+
// swagger:operation POST /v2/tenants/{tenant_name}/image/load v2 loadTarImage
34+
//
35+
// 开始解析tar包镜像
36+
//
37+
// load tar image
38+
//
39+
// ---
40+
// consumes:
41+
// - application/json
42+
//
43+
// produces:
44+
// - application/json
45+
//
46+
// responses:
47+
// default:
48+
// schema:
49+
// "$ref": "#/responses/commandResponse"
50+
// description: 统一返回格式
51+
var req api_model.LoadTarImageReq
52+
ok := httputil.ValidatorRequestStructAndErrorResponse(r, w, &req, nil)
53+
if !ok {
54+
return
55+
}
56+
57+
tenantID := r.Context().Value(ctxutil.ContextKey("tenant_id")).(string)
58+
59+
tarHandler := handler.GetTarImageHandle()
60+
if tarHandler == nil {
61+
httputil.ReturnError(r, w, 503, "tar image handler is not initialized")
62+
return
63+
}
64+
65+
res, errS := tarHandler.LoadTarImage(tenantID, req)
66+
if errS != nil {
67+
errS.Handle(r, w)
68+
return
69+
}
70+
httputil.ReturnSuccess(r, w, res)
71+
}
72+
73+
// GetTarLoadResult 查询tar包解析结果
74+
func GetTarLoadResult(w http.ResponseWriter, r *http.Request) {
75+
// swagger:operation GET /v2/tenants/{tenant_name}/image/load/{load_id} v2 getTarLoadResult
76+
//
77+
// 查询tar包解析结果
78+
//
79+
// get tar load result
80+
//
81+
// ---
82+
// produces:
83+
// - application/json
84+
//
85+
// responses:
86+
// default:
87+
// schema:
88+
// "$ref": "#/responses/commandResponse"
89+
// description: 统一返回格式
90+
loadID := chi.URLParam(r, "load_id")
91+
92+
tarHandler := handler.GetTarImageHandle()
93+
if tarHandler == nil {
94+
httputil.ReturnError(r, w, 503, "tar image handler is not initialized")
95+
return
96+
}
97+
98+
res, errS := tarHandler.GetTarLoadResult(loadID)
99+
if errS != nil {
100+
errS.Handle(r, w)
101+
return
102+
}
103+
httputil.ReturnSuccess(r, w, res)
104+
}

api/eventlog/db/eventFilePlugin.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,14 @@ func (m *EventFilePlugin) downloadWithRetry(eventID, localPath string) error {
204204
maxRetries := 3
205205
retryDelay := time.Second
206206

207+
// 构造正确的 S3 路径:从 localPath 中提取相对于根目录的路径
208+
// localPath 格式: /grdata/logs/eventlog/eventID.log
209+
// 需要构造成: grdata/logs/eventlog/eventID.log (去掉开头的 /)
210+
s3Path := path.Join("grdata", "logs", "eventlog", eventID+".log")
211+
207212
for attempt := 1; attempt <= maxRetries; attempt++ {
208213
err := storage.Default().StorageCli.DownloadFileToDir(
209-
path.Join("grdata", localPath),
214+
s3Path,
210215
path.Join(m.HomePath, "eventlog"),
211216
)
212217
if err == nil {

api/handler/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ func InitAPIHandle() error {
5353
defApplicationHandler = NewApplicationHandler()
5454
defRegistryAuthSecretHandler = CreateRegistryAuthSecretManager()
5555
defNodesHandler = NewNodesHandler()
56+
57+
// 初始化 TarImageHandle
58+
// 镜像的加载和推送在 builder 服务中异步完成
59+
CreateTarImageHandle(mq.Default().MqClient)
60+
logrus.Info("tar image handler initialized successfully")
61+
5662
return nil
5763
}
5864

api/handler/service.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ func (s *ServiceAction) ServiceCreate(sc *apimodel.ServiceStruct) error {
673673
AllowExpansion: volumn.AllowExpansion,
674674
// VolumeProviderName 使用的存储驱动别名
675675
VolumeProviderName: volumn.VolumeProviderName,
676+
// Mode 配置文件权限模式
677+
Mode: volumn.Mode,
676678
}
677679
v.ServiceID = ts.ServiceID
678680
if volumn.VolumeType == "" {

api/handler/tar_image_handler.go

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
2+
// RAINBOND, Application Management Platform
3+
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version. For any non-GPL usage of Rainbond,
8+
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
9+
// must be obtained first.
10+
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU General Public License for more details.
15+
16+
// You should have received a copy of the GNU General Public License
17+
// along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
19+
package handler
20+
21+
import (
22+
"encoding/json"
23+
"fmt"
24+
25+
"github.com/goodrain/rainbond/api/model"
26+
"github.com/goodrain/rainbond/api/util"
27+
"github.com/goodrain/rainbond/db"
28+
"github.com/goodrain/rainbond/mq/client"
29+
"github.com/google/uuid"
30+
"github.com/sirupsen/logrus"
31+
)
32+
33+
// TarImageHandle tar包镜像处理
34+
type TarImageHandle struct {
35+
MQClient client.MQClient
36+
}
37+
38+
var tarImageHandle *TarImageHandle
39+
40+
// GetTarImageHandle 获取tar镜像处理handler
41+
func GetTarImageHandle() *TarImageHandle {
42+
if tarImageHandle == nil {
43+
logrus.Error("TarImageHandle is not initialized")
44+
}
45+
return tarImageHandle
46+
}
47+
48+
// CreateTarImageHandle 创建tar镜像处理handler
49+
func CreateTarImageHandle(mqClient client.MQClient) {
50+
tarImageHandle = &TarImageHandle{
51+
MQClient: mqClient,
52+
}
53+
}
54+
55+
// LoadTarImage 开始异步解析tar包镜像
56+
func (t *TarImageHandle) LoadTarImage(tenantID string, req model.LoadTarImageReq) (*model.LoadTarImageResp, *util.APIHandleError) {
57+
loadID := uuid.New().String()
58+
59+
logrus.Infof("[LoadTarImage] Starting, load_id: %s, tenant_id: %s, event_id: %s, tar_file_path: %s",
60+
loadID, tenantID, req.EventID, req.TarFilePath)
61+
62+
// 构建任务发送到MQ
63+
task := client.TaskStruct{
64+
Topic: "builder",
65+
TaskType: "load-tar-image",
66+
TaskBody: map[string]interface{}{
67+
"event_id": req.EventID,
68+
"tar_file_path": req.TarFilePath,
69+
"load_id": loadID,
70+
"tenant_id": tenantID,
71+
},
72+
}
73+
74+
logrus.Infof("[LoadTarImage] Sending task to MQ, topic: %s, task_type: %s, task_body: %+v",
75+
task.Topic, task.TaskType, task.TaskBody)
76+
77+
// 发送任务到消息队列
78+
err := t.MQClient.SendBuilderTopic(task)
79+
if err != nil {
80+
logrus.Errorf("[LoadTarImage] Failed to send task to MQ: %v", err)
81+
return nil, util.CreateAPIHandleError(500, fmt.Errorf("启动解析任务失败"))
82+
}
83+
84+
logrus.Infof("[LoadTarImage] Task sent successfully to MQ, load_id: %s, event_id: %s", loadID, req.EventID)
85+
86+
return &model.LoadTarImageResp{
87+
LoadID: loadID,
88+
Status: "loading",
89+
}, nil
90+
}
91+
92+
// GetTarLoadResult 查询tar包解析结果
93+
func (t *TarImageHandle) GetTarLoadResult(loadID string) (*model.TarLoadResult, *util.APIHandleError) {
94+
// 从etcd查询结果
95+
key := fmt.Sprintf("/rainbond/tarload/%s", loadID)
96+
logrus.Infof("[GetTarLoadResult] Querying etcd for load_id: %s, key: %s", loadID, key)
97+
98+
res, err := db.GetManager().KeyValueDao().Get(key)
99+
if err != nil || res == nil {
100+
if err != nil {
101+
logrus.Infof("[GetTarLoadResult] Key not found in etcd (task may still be processing): load_id: %s, error: %v", loadID, err)
102+
} else {
103+
logrus.Infof("[GetTarLoadResult] Result is nil for load_id: %s (task may still be processing)", loadID)
104+
}
105+
// 如果没找到结果,可能还在处理中
106+
return &model.TarLoadResult{
107+
LoadID: loadID,
108+
Status: "loading",
109+
Message: "正在解析中...",
110+
}, nil
111+
}
112+
113+
logrus.Infof("[GetTarLoadResult] Found result in etcd for load_id: %s, value length: %d bytes", loadID, len(res.V))
114+
115+
// 解析结果
116+
var result model.TarLoadResult
117+
if err := json.Unmarshal([]byte(res.V), &result); err != nil {
118+
logrus.Errorf("[GetTarLoadResult] Failed to decode result for load_id: %s, error: %v, raw_value: %s", loadID, err, res.V)
119+
return nil, util.CreateAPIHandleError(500, fmt.Errorf("解析结果格式错误"))
120+
}
121+
122+
logrus.Infof("[GetTarLoadResult] Successfully decoded result for load_id: %s, status: %s", loadID, result.Status)
123+
124+
return &result, nil
125+
}

api/model/model.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,8 @@ type TenantServiceVolumeStruct struct {
440440
AllowExpansion bool `json:"allow_expansion"`
441441
// VolumeProviderName 使用的存储驱动别名
442442
VolumeProviderName string `json:"volume_provider_name"`
443+
// Mode 配置文件权限模式
444+
Mode *int32 `json:"mode"`
443445
// NFSServer NFS存储服务地址
444446
NFSServer string `json:"nfs_server"`
445447
// NFSPath NFS存储服务路径

0 commit comments

Comments
 (0)