Skip to content

Commit 9a58aae

Browse files
committed
fix(cluster): 尝试解决创建集群超时的问题
1 parent e90240a commit 9a58aae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

internal/api/v1/cluster/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (h *Handler) CreateCluster() iris.Handler {
111111
txOptions := common.DBOptions{DB: tx}
112112
req.Cluster.Status.Phase = clusterStatusSaved
113113
if err := h.clusterService.Create(&req.Cluster, txOptions); err != nil {
114+
tx.Rollback()
114115
ctx.StatusCode(iris.StatusInternalServerError)
115116
ctx.Values().Set("message", err.Error())
116117
return
@@ -125,11 +126,13 @@ func (h *Handler) CreateCluster() iris.Handler {
125126
}
126127
notAllowed, err := checkRequiredPermissions(client, requiredPermissions)
127128
if err != nil {
129+
tx.Rollback()
128130
ctx.StatusCode(iris.StatusInternalServerError)
129131
ctx.Values().Set("message", err.Error())
130132
return
131133
}
132134
if notAllowed != "" {
135+
tx.Rollback()
133136
ctx.StatusCode(iris.StatusInternalServerError)
134137
ctx.Values().Set("message", []string{"permission %s required", notAllowed})
135138
return

0 commit comments

Comments
 (0)