Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
114 commits
Select commit Hold shift + click to select a range
9866cf8
PullRequest: 349 fix: hung when start the cluster
Junkrat77 Feb 17, 2025
095cdd8
PullRequest: 351 fix: daemon startup fails when the PID in daemon.pid…
Junkrat77 Feb 17, 2025
34e57c8
PullRequest: 352 fix: upgrade failed
Junkrat77 Feb 17, 2025
94027f3
PullRequest: 350 rewrite the logic of set tenant variable
Junkrat77 Feb 18, 2025
9f23d2e
PullRequest: 354 fix agent status
Junkrat77 Mar 3, 2025
4070e81
PullRequest: 355 feat: support ipv6
frf12 Mar 3, 2025
d96347f
PullRequest: 357 fix: bugs of sp_ipv6
Junkrat77 Mar 3, 2025
e1dd129
PullRequest: 358 use default rpc_port if not set when scale out
Junkrat77 Mar 4, 2025
43dd332
PullRequest: 353 sp obproxy
Junkrat77 Mar 6, 2025
cd4f61b
fix openapi definitions errors
chris-sun-star Mar 25, 2025
6d7c936
keep post method to match existing sdk code
chris-sun-star Mar 25, 2025
c5f09c8
change wrong method for scale out
chris-sun-star Mar 25, 2025
0e4e293
add config put method back
chris-sun-star Mar 27, 2025
a4e7f14
Merge pull request #7 from chris-sun-star/openapi-definition
chris-sun-star Apr 8, 2025
6783191
PullRequest: 360 fix: panic when start agent with invalid ipv6 address
Junkrat77 Apr 10, 2025
d4e1d2e
PullRequest: 362 fix: hung when restart agent
Junkrat77 Apr 10, 2025
ff1fb9d
PullRequest: 361 fix the maintenance of obproxy
Junkrat77 Apr 10, 2025
e11001a
PullRequest: 364 mask password
Junkrat77 Apr 10, 2025
2637769
PullRequest: 363 clear oceanbase password when be SINGLE
Junkrat77 Apr 10, 2025
9fc8a8d
PullRequest: 366 fix: delete obproxy version in sqlite
Junkrat77 Apr 10, 2025
9cf72de
PullRequest: 365 chore: mask password
Junkrat77 Apr 10, 2025
22831f3
PullRequest: 367 add isObproxyAgent in info and return nil when bin/o…
Junkrat77 Apr 10, 2025
737982a
PullRequest: 368 ore: update version to 4.2.6.0
Junkrat77 Apr 10, 2025
6003876
PullRequest: 369 chore: add attributes for obproxy task
Junkrat77 Apr 10, 2025
f6cf0ad
PullRequest: 371 fix: auto migrate sqlite table when exist non-exist …
Junkrat77 Apr 10, 2025
626a7eb
PullRequest: 376 api-def
Apr 10, 2025
87a599d
PullRequest: 377 user-db-api
Apr 14, 2025
f52556b
PullRequest: 379 chore: add read_only in TenantInfo
Junkrat77 Apr 15, 2025
ee46dca
PullRequest: 384 feat: add API([GET] /api/v1/obcluster/charsets) to g…
Junkrat77 Apr 17, 2025
80886dd
PullRequest: 381 feat: add API for uploading package which won't requ…
Junkrat77 Apr 17, 2025
7956bc6
PullRequest: 386 chore(): 前端代码/1
Apr 18, 2025
deae4d0
PullRequest: 387 chore(): 前端代码/2
Apr 18, 2025
47c84c1
PullRequest: 388 chore(): 前端代码/3
Apr 18, 2025
db5727f
PullRequest: 386 chore(): 前端代码/1
Apr 18, 2025
b93fcf0
PullRequest: 387 chore(): 前端代码/2
Apr 18, 2025
870bb87
PullRequest: 388 chore(): 前端代码/3
Apr 18, 2025
5993e18
PullRequest: 389 chore(): 配置文件更新
Apr 18, 2025
acb2193
PullRequest: 390 【前端】feat: 更新接口 & 新增软件包上传进度条 & 完善创建租户和软件包列表
Apr 18, 2025
c612755
PullRequest: 389 chore(): 配置文件更新
Apr 18, 2025
3d9bcca
PullRequest: 390 【前端】feat: 更新接口 & 新增软件包上传进度条 & 完善创建租户和软件包列表
Apr 18, 2025
a0fd449
PullRequest: 392 change license of frontend files to apache 2.0
Apr 18, 2025
1de427c
PullRequest: 391 fix: 屏蔽无效接口 & 优化软件包列表展示
Apr 18, 2025
f2f33b0
PullRequest: 393 improve: 优化交互展示 & 优化登录 & 前端控制 password 来模拟退出登录
Apr 18, 2025
f9e904f
PullRequest: 394 fix: 修复参数禁选、交互 & 修复全局租户详情接口参数错误导致的 401 & 修复任务日志操作接口错误
Apr 19, 2025
249dc47
PullRequest: 395 fix: 软件包上传交互优化 & 副本单位换算 & 任务日志展示优化
Apr 19, 2025
a64aaf2
PullRequest: 396 fix: 优化升级判断 & 调整日志接口字段
Apr 19, 2025
41347d3
PullRequest: 397 improve: 优化界面展示 & 修复副本 memory 单位
Apr 19, 2025
4e83229
PullRequest: 399 fix: 数据库替换 charset 接口
Apr 19, 2025
652a8d1
PullRequest: 398 fix(): 租户root密码相关逻辑
Apr 19, 2025
a6086e6
PullRequest: 400 fix(): 更新onsuccess
Apr 19, 2025
9f16fef
PullRequest: 401 improve: 优化上传文件错误处理
Apr 19, 2025
d525f90
PullRequest: 403 fix(): 用户删除 API 修正
Apr 21, 2025
f7df68f
PullRequest: 382 implement user and database management apis
Apr 22, 2025
0e32aa5
PullRequest: 378 support ob-dashboard
Junkrat77 Apr 22, 2025
a2530b0
PullRequest: 406 test-package-dashboard
Apr 22, 2025
7a82621
PullRequest: 402 fix: 支持测试环境关闭加密 & 修正租户筛选、排序 & 删除租户后延迟跳转
Apr 22, 2025
f2d5343
PullRequest: 383 feat: add task apis for ob-dashboard
Junkrat77 Apr 22, 2025
a102ec3
PullRequest: 407 fix(): 用户活跃会话展示修正
Apr 22, 2025
23dc56d
PullRequest: 408 fix: tenant value is null in cluster parameters info
Junkrat77 Apr 22, 2025
7ada79c
PullRequest: 411 feat: 优化 publicKey 获取 & 关闭加密逻辑更新
Apr 23, 2025
386bd14
PullRequest: 409 fear: auto forward to avtive agent when need to conn…
Junkrat77 Apr 23, 2025
1394cb4
PullRequest: 410 optz the speed of getObclusterParameters
Junkrat77 Apr 23, 2025
c811d90
PullRequest: 413 fix(): Tenant pre-check fails, the interface will n…
Apr 23, 2025
e3ffb81
PullRequest: 414 fix: Fix cluster, tenant and task bugs
Apr 23, 2025
caa995c
PullRequest: 412 ignore meta tenant
Junkrat77 Apr 23, 2025
23dde22
PullRequest: 415 add build frontend tester command; fix wrong inner u…
Apr 23, 2025
5729bbe
PullRequest: 416 persist password after create tenant
Apr 24, 2025
821af35
PullRequest: 418 fix(): Fixed the issue that the sys tenant database …
Apr 24, 2025
6de7367
PullRequest: 421 fix: Fix cluster parameter modification, cluster tot…
Apr 24, 2025
fb276bf
PullRequest: 423 feat: Encrypted storage
Apr 24, 2025
7b55aeb
PullRequest: 419 delete duplicate package info
Apr 24, 2025
c660600
PullRequest: 420 add query param mode in /api/v1/tenants/overview
Apr 24, 2025
24ee3da
PullRequest: 422 fix: return unexpect error instead of 404
Apr 24, 2025
1db4c26
PullRequest: 426 optz: add sql_port in AgentStatus
Apr 24, 2025
084134e
PullRequest: 420 add query param mode in /api/v1/tenants/overview
Junkrat77 Apr 24, 2025
54eae28
PullRequest: 422 fix: return unexpect error instead of 404
Junkrat77 Apr 24, 2025
f30374c
PullRequest: 426 optz: add sql_port in AgentStatus
Junkrat77 Apr 24, 2025
792c43f
PullRequest: 425 check password before persist
Apr 24, 2025
4016d89
PullRequest: 424 chore: modify the message of 'start maintenace error'
Apr 24, 2025
084d8e8
PullRequest: 427 feat: add API: [GET] /api/v1/task/dag/agent/main_dag…
Apr 24, 2025
45c13ff
PullRequest: 424 chore: modify the message of 'start maintenace error'
Junkrat77 Apr 24, 2025
a327cd9
PullRequest: 427 feat: add API: [GET] /api/v1/task/dag/agent/main_dag…
Junkrat77 Apr 24, 2025
7ab9239
PullRequest: 428 fix: minor bug
Junkrat77 Apr 25, 2025
ae03a0e
PullRequest: 429 fix: panic when create or drop tenant
Junkrat77 Apr 25, 2025
350265d
PullRequest: 431 fix(): text correction
Apr 25, 2025
315eea8
PullRequest: 434 fix: Optimize global error prompts and task details …
Apr 25, 2025
e57af9b
PullRequest: 433 add architecture in obcluster/info API
Junkrat77 Apr 25, 2025
727a1c1
PullRequest: 432 add tenant charset
Junkrat77 Apr 25, 2025
9c34de7
PullRequest: 436 fix: update hardware architecture display in Upgrade…
Apr 27, 2025
eca6950
PullRequest: 385 fix: clean up obshell.pid failed when obshell.pid ex…
Junkrat77 Apr 27, 2025
7671401
PullRequest: 437 add no route for /api/v1
Apr 27, 2025
9e1c7aa
PullRequest: 438 fix: panic when occur bind json error
Apr 27, 2025
00e38de
PullRequest: 439 panic when exist inactive observer
Apr 27, 2025
9e6e8bf
PullRequest: 435 check agent and observer status before upgrade ocean…
Apr 27, 2025
10d6d1f
PullRequest: 437 add no route for /api/v1
Junkrat77 Apr 27, 2025
d40c421
PullRequest: 438 fix: panic when occur bind json error
Junkrat77 Apr 27, 2025
d9948d4
PullRequest: 439 panic when exist inactive observer
Junkrat77 Apr 27, 2025
799a989
PullRequest: 435 check agent and observer status before upgrade ocean…
Apr 27, 2025
bb2b91c
PullRequest: 440 fix: fixed error handling and optimized code logic i…
Apr 27, 2025
268ae4f
PullRequest: 441 feat: set global_index_auto_split_policy to 'ALL' wh…
Junkrat77 Apr 27, 2025
d578031
PullRequest: 443 fix css file
Apr 27, 2025
aa5658f
PullRequest: 444 fix(): Add Readonly type to new Tenant and new Replica
Apr 27, 2025
1d98d06
PullRequest: 445 fix spec
Junkrat77 Apr 27, 2025
209412c
PullRequest: 442 check agent status before upgrade agent
Apr 27, 2025
c055e75
PullRequest: 447 fix: updated task graph to use domId for node identi…
Apr 27, 2025
20ea2d9
PullRequest: 449 fix: optimized cluster DAG & unit spec layout with b…
Apr 28, 2025
6247be8
PullRequest: 448 add API to get unit config limit and organize the de…
Apr 28, 2025
83d5e89
PullRequest: 450 fix: dependency update to fix login configuration
Apr 28, 2025
f5838fd
PullRequest: 451 optz swagger info
Apr 28, 2025
5c0da5c
PullRequest: 453 feat: added Popconfirm/cond editing & form logic imp…
Apr 28, 2025
cf27413
PullRequest: 452 fix: check if tenant has been locked before connect
Apr 28, 2025
b85176d
PullRequest: 454 fix(): Tenant locked state not calling the pre-check…
Apr 28, 2025
b15b396
PullRequest: 455 fix: remove dumplicate item in whitelist
Apr 28, 2025
de141ac
Chore(deps-dev): Bump axios from 0.21.4 to 0.30.0 in /frontend
dependabot[bot] Apr 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
11 changes: 7 additions & 4 deletions .aci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,22 @@ jobs:
script: |
#!/bin/bash
if [[ `uname -m` == aarch64 ]]; then
wget https://studygolang.com/dl/golang/go1.20.6.linux-arm64.tar.gz --no-check-certificate
wget https://studygolang.com/dl/golang/go1.23.6.linux-arm64.tar.gz --no-check-certificate
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.20.6.linux-arm64.tar.gz
tar -C /usr/local -xzf go1.23.6.linux-arm64.tar.gz
cp /usr/local/go/bin/go /usr/local/bin/
else
wget https://studygolang.com/dl/golang/go1.20.6.linux-amd64.tar.gz --no-check-certificate
wget https://studygolang.com/dl/golang/go1.23.6.linux-amd64.tar.gz --no-check-certificate
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.20.6.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.23.6.linux-amd64.tar.gz
cp /usr/local/go/bin/go /usr/local/bin/
fi
export PATH=/usr/local/go/bin:$PATH
go env -w GOPROXY=https://goproxy.cn GOPATH="/usr/local"
go install github.com/go-bindata/go-bindata/[email protected]+incompatible
cd "${BASE_WORKSPACE}/codeWorkspace"
mkdir -p frontend/dist
touch frontend/dist/index.html
make pre-build build-with-swagger

规范检查:
Expand Down
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,47 @@ vendor
# macOS files
.DS_Store

# frontend
/frontend/pids
/frontend/logs
/frontend/node_modules
/frontend/npm-debug.log
/frontend/coverage/
/frontend/build/
/frontend/run
/frontend/.basement
/frontend/src/.umi
/frontend/src/.umi-production
/frontend/speed-measure.json
/frontend/dist
/frontend/unuseful-locale-key.txt
/frontend/docs.zip
/frontend/config.local.ts



.idea/*
*.iml
.vscode/*
.OWNERS
.meta
etc/
log_obshell/
run/

# frontend
/frontend/pids
/frontend/logs
/frontend/node_modules
/frontend/npm-debug.log
/frontend/coverage/
/frontend/build/
/frontend/run
/frontend/.basement
/frontend/src/.umi
/frontend/src/.umi-production
/frontend/speed-measure.json
/frontend/dist
/frontend/unuseful-locale-key.txt
/frontend/docs.zip
/frontend/config.local.ts
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@ build-release: set-release-flags obshell buildsucc

build-with-swagger: enable-swagger build-release

build-for-test: pre-build enable-swagger set-disable-encryption-flags build-debug

frontend-dep:
npm i -g pnpm@7

frontend-build:
cd frontend && pnpm i && pnpm build && cd ../

frontend-build-tester:
cd frontend && pnpm i && pnpm build:tester && cd ../

rpm:
cd ./rpm && VERSION=$(VERSION) RELEASE=$(RELEASE) NAME=$(NAME) OBSHELL_RELEASE=$(OBSHELL_RELEASE) rpmbuild -bb obshell.spec

set-disable-encryption-flags:
@echo Build with encryption disabled flags
$(eval LDFLAGS += $(LDFLAGS_DISABLE_ENCRYPTION))

set-debug-flags:
@echo Build with debug flags
$(eval LDFLAGS += $(LDFLAGS_DEBUG))
Expand Down
3 changes: 2 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PROCESSOR=2
VERSION=4.2.5.0
VERSION=4.2.6.0
NAME=obshell
RELEASE=0
DIST=0
Expand Down Expand Up @@ -27,6 +27,7 @@ LDFLAGS += -X "github.com/oceanbase/obshell/agent/config.GitCommitTime=$(shell g
LDFLAGS += -X "github.com/oceanbase/obshell/agent/config.BuildFlags=${BUILD_FLAG}"
LDFLAGS_DEBUG = -X "github.com/oceanbase/obshell/agent/config.Mode=debug"
LDFLAGS_RELEASE = -X "github.com/oceanbase/obshell/agent/config.Mode=release"
LDFLAGS_DISABLE_ENCRYPTION = -X "github.com/oceanbase/obshell/agent/config.EncryptionDisabled=true"
OBSHELL_LDFLAGS = $(LDFLAGS) -X "github.com/oceanbase/obshell/agent/config.CurProcess=obshell"

GOFILES ?= $(shell git ls-files '*.go')
Expand Down
70 changes: 43 additions & 27 deletions agent/api/agent_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,26 @@ var (
agentService = agentservice.AgentService{}
)

// @Summary join the specified agent
// @Description join the specified agent
// @Tags agent
// @Accept application/json
// @Produce application/json
// @Param X-OCS-Header header string true "Authorization"
// @Param body body param.JoinApiParam true "agent info with zone name"
// @Success 200 object http.OcsAgentResponse{data=task.DagDetailDTO}
// @Failure 400 object http.OcsAgentResponse
// @Failure 500 object http.OcsAgentResponse
// @Router /api/v1/agent [post]
// @Router /api/v1/agent/join [post]
// @Summary join the specified agent
// @Description join the specified agent
// @Tags agent
// @Accept application/json
// @Produce application/json
// @Param X-OCS-Header header string true "Authorization"
// @Param body body param.JoinApiParam true "agent info with zone name"
// @Success 200 object http.OcsAgentResponse{data=task.DagDetailDTO}
// @Failure 400 object http.OcsAgentResponse
// @Failure 500 object http.OcsAgentResponse
// @Router /api/v1/agent [post]
// @Router /api/v1/agent/join [post]
func agentJoinHandler(c *gin.Context) {
var param param.JoinApiParam
if err := c.BindJSON(&param); err != nil {
common.SendResponse(c, nil, err)
return
}
if !meta.OCS_AGENT.IsSingleAgent() {
common.SendResponse(c, nil, errors.Occurf(errors.ErrBadRequest, "%s:%d is not single agent", meta.OCS_AGENT.GetIp(), meta.OCS_AGENT.GetPort()))
common.SendResponse(c, nil, errors.Occurf(errors.ErrBadRequest, "%s is not single agent", meta.OCS_AGENT.String()))
return
}

Expand All @@ -78,15 +78,21 @@ func agentJoinHandler(c *gin.Context) {
param.AgentInfo.String(), agentStatus.Version, meta.OCS_AGENT.String(), constant.VERSION_RELEASE))
return
}
if obVersion, err := binary.GetMyOBVersion(); err != nil {
if obVersion, _, err := binary.GetMyOBVersion(); err != nil {
common.SendResponse(c, nil, errors.Occurf(errors.ErrUnexpected, "get ob version failed: %s", err.Error()))
return
} else if obVersion != agentStatus.OBVersion {
common.SendResponse(c, nil, errors.Occurf(errors.ErrBadRequest, "ob version is not consistent between %s(%s) and %s(%s)",
param.AgentInfo.String(), agentStatus.OBVersion, meta.OCS_AGENT.String(), obVersion))
return
}
dag, err = agent.CreateJoinMasterDag(param.AgentInfo, param.ZoneName)
// send token to master early.
if err = agent.SendTokenToMaster(param.AgentInfo, param.MasterPassword); err != nil {
common.SendResponse(c, nil, errors.Occur(errors.ErrTaskCreateFailed, err))
return
}

dag, err = agent.CreateJoinMasterDag(param.AgentInfo, param.ZoneName, param.MasterPassword)
}

if err != nil {
Expand All @@ -96,18 +102,18 @@ func agentJoinHandler(c *gin.Context) {
common.SendResponse(c, task.NewDagDetailDTO(dag), nil)
}

// @Summary remove the specified agent
// @Description remove the specified agent
// @Tags agent
// @Accept application/json
// @Produce application/json
// @Param X-OCS-Header header string true "Authorization"
// @Param body body meta.AgentInfo true "agent info"
// @Success 200 object http.OcsAgentResponse{data=task.DagDetailDTO}
// @Failure 400 object http.OcsAgentResponse
// @Failure 500 object http.OcsAgentResponse
// @Router /api/v1/agent [delete]
// @Router /api/v1/agent/remove [post]
// @Summary remove the specified agent
// @Description remove the specified agent
// @Tags agent
// @Accept application/json
// @Produce application/json
// @Param X-OCS-Header header string true "Authorization"
// @Param body body meta.AgentInfo true "agent info"
// @Success 200 object http.OcsAgentResponse{data=task.DagDetailDTO}
// @Failure 400 object http.OcsAgentResponse
// @Failure 500 object http.OcsAgentResponse
// @Router /api/v1/agent [delete]
// @Router /api/v1/agent/remove [post]
func agentRemoveHandler(c *gin.Context) {
var param meta.AgentInfo
if err := c.BindJSON(&param); err != nil {
Expand Down Expand Up @@ -178,3 +184,13 @@ func agentRemoveHandler(c *gin.Context) {
}
common.SendResponse(c, task.NewDagDetailDTO(dag), nil)
}

func agentSetPasswordHandler(c *gin.Context) {
var param param.SetAgentPasswordParam
if err := c.BindJSON(&param); err != nil {
common.SendResponse(c, nil, err)
return
}

common.SendResponse(c, nil, agentService.SetAgentPassword(param.Password))
}
53 changes: 47 additions & 6 deletions agent/api/agent_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,49 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
}
r.Use(
gin.CustomRecovery(common.Recovery), // gin's crash-free middleware
common.PostHandlers("/debug/pprof", "/swagger"),
common.BodyDecrypt(), // decrypt request body
common.PostHandlers("/debug/pprof", "/swagger",
// get all obcluster parameters
constant.URI_API_V1+constant.URI_OBCLUSTER_GROUP+constant.URI_PARAMETERS,
),
common.HeaderDecrypt(),
common.BodyDecrypt(constant.URI_API_V1+constant.URI_PACKAGE), // decrypt request body
common.PaddingBody(), // if the response body is empty, the response body is padded with "{}"

common.PreHandlers(
constant.URI_API_V1+constant.URI_UPGRADE+constant.URI_PACKAGE,
constant.URI_API_V1+constant.URI_OBCLUSTER_GROUP+constant.URI_CONFIG,
constant.URI_API_V1+constant.URI_OBCLUSTER_GROUP+constant.URI_BACKUP+constant.URI_CONFIG,
constant.URI_API_V1+constant.URI_TENANT_GROUP+constant.URI_PATH_PARAM_NAME+constant.URI_BACKUP+constant.URI_CONFIG,
constant.URI_API_V1+constant.URI_TENANT_GROUP+constant.URI_RESTORE,
constant.URI_API_V1+constant.URI_RESTORE+constant.URI_WINDOWS,
// init cluster
constant.URI_OB_API_PREFIX+constant.URI_INIT,
constant.URI_TASK_RPC_PREFIX+constant.URI_SUB_TASK,
// create tenant
constant.URI_API_V1+constant.URI_TENANT_GROUP,
// set tenant password
constant.URI_TENANT_API_PREFIX+constant.URI_PATH_PARAM_NAME+constant.URI_ROOTPASSWORD,
// create user
constant.URI_TENANT_API_PREFIX+constant.URI_PATH_PARAM_NAME+constant.URI_USER,
// delete user
constant.URI_TENANT_API_PREFIX+constant.URI_PATH_PARAM_NAME+constant.URI_USER+constant.URI_PATH_PARAM_USER,
// add obproxy
constant.URI_OBPROXY_API_PREFIX,
// set tenant variable
constant.URI_TENANT_API_PREFIX+constant.URI_PATH_PARAM_NAME+constant.URI_VARIABLES,
// set agent password
constant.URI_AGENT_API_PREFIX+constant.URI_PASSWORD,
// join master
constant.URI_AGENT_API_PREFIX+constant.URI_JOIN,
constant.URI_AGENT_API_PREFIX,
// scale out
constant.URI_API_V1+constant.URI_OB_GROUP+constant.URI_SCALE_OUT,
// send token
constant.URI_AGENT_RPC_PREFIX+constant.URI_TOKEN,
// upload obproxy package
constant.URI_OBPROXY_API_PREFIX+constant.URI_PACKAGE,
constant.URI_API_V1+constant.URI_PACKAGE,
// persist tenant root password
constant.URI_PATH_PARAM_NAME+constant.URI_ROOTPASSWORD+constant.URI_PERSIST,
),
common.SetContentType,
)
Expand All @@ -63,6 +92,7 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
r.Use(common.SetLocalRouteFlag)
} else {
initSwagger(r)
initFrontendRouter(r)
}

// groups
Expand All @@ -81,6 +111,7 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
pool := v1.Group(constant.URI_POOL_GROUP)
recyclebin := v1.Group(constant.URI_RECYCLEBIN_GROUP)
zone := v1.Group(constant.URI_ZONE_GROUP)
pkg := v1.Group(constant.URI_PACKAGE)

if !isLocalRoute {
ob.Use(common.Verify())
Expand All @@ -107,6 +138,7 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
InitTenantRoutes(v1, isLocalRoute)
InitBackupRoutes(v1, isLocalRoute)
InitRestoreRoutes(v1, isLocalRoute)
InitObproxyRoutes(v1, isLocalRoute)

// ob routes
ob.POST(constant.URI_INIT, obInitHandler)
Expand All @@ -116,6 +148,7 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
ob.POST(constant.URI_SCALE_OUT, obClusterScaleOutHandler)
ob.POST(constant.URI_SCALE_IN, obClusterScaleInHandler)
ob.POST(constant.URI_UPGRADE, obUpgradeHandler)
ob.GET(constant.URI_UPGRADE+constant.URI_ROUTE, obPkgUpgradeRouteHandler)
ob.POST(constant.URI_UPGRADE+constant.URI_CHECK, obUpgradeCheckHandler)
ob.GET(constant.URI_AGENTS, obAgentsHandler)

Expand All @@ -126,13 +159,19 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
agent.POST(constant.URI_REMOVE, agentRemoveHandler)
agent.POST(constant.URI_UPGRADE, agentUpgradeHandler)
agent.POST(constant.URI_UPGRADE+constant.URI_CHECK, agentUpgradeCheckHandler)
agent.POST(constant.URI_PASSWORD, agentSetPasswordHandler)

// agents routes
agents.GET(constant.URI_STATUS, GetAllAgentStatus(s))

// obcluster routes
obcluster.PUT(constant.URI_CONFIG, obclusterConfigHandler(true))
obcluster.POST(constant.URI_CONFIG, obclusterConfigHandler(true))
obcluster.GET(constant.URI_INFO, obclusterInfoHandler)
obcluster.GET(constant.URI_PARAMETERS, obclusterParametersHandler)
obcluster.PATCH(constant.URI_PARAMETERS, obclusterSetParametersHandler)
obcluster.GET(constant.URI_CHARSETS, getObclusterCharsets)
obcluster.GET(constant.URI_UNIT_CONFIG_LIMIT, checkClusterAgentWrapper(getUnitConfigLimitHandler))

// observer routes
observer.PUT(constant.URI_CONFIG, obServerConfigHandler(true))
Expand All @@ -144,9 +183,12 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {

// upgrade routes
upgrade.POST(constant.URI_PACKAGE, pkgUploadHandler)
upgrade.GET(constant.URI_PACKAGE+constant.URI_INFO, pkgInfoHandler)
upgrade.POST(constant.URI_PARAMS+constant.URI_BACKUP, paramsBackupHandler)
upgrade.POST(constant.URI_PARAMS+constant.URI_RESTORE, paramsRestoreHandler)

pkg.POST("", common.VerifyFile(), newPkgUploadHandler)

// unit routes
unit.POST("", unitConfigCreateHandler)
unit.DELETE(constant.URI_PATH_PARAM_NAME, unitConfigDropHandler)
Expand All @@ -161,9 +203,8 @@ func InitOcsAgentRoutes(s *http2.State, r *gin.Engine, isLocalRoute bool) {
recyclebin.GET(constant.URI_TENANTS, recyclebinListTenantHandler)
recyclebin.DELETE(constant.URI_TENANT_GROUP+constant.URI_PATH_PARAM_NAME, recyclebinPurgeTenantHandler)
recyclebin.POST(constant.URI_TENANT_GROUP+constant.URI_PATH_PARAM_NAME, recyclebinFlashbackTenantHandler)

r.NoRoute(func(c *gin.Context) {
err := errors.Occur(errors.ErrBadRequest, "404 not found")
common.SendResponse(c, nil, err)
common.SendResponse(c, nil, errors.Occur(errors.ErrBadRequest, "404 not found"))
return
})
}
Loading