Skip to content

Commit

Permalink
fix(cluster): 尝试解决创建集群超时的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ssongliu committed Jan 12, 2022
1 parent e90240a commit 9a58aae
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/api/v1/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (h *Handler) CreateCluster() iris.Handler {
txOptions := common.DBOptions{DB: tx}
req.Cluster.Status.Phase = clusterStatusSaved
if err := h.clusterService.Create(&req.Cluster, txOptions); err != nil {
tx.Rollback()
ctx.StatusCode(iris.StatusInternalServerError)
ctx.Values().Set("message", err.Error())
return
Expand All @@ -125,11 +126,13 @@ func (h *Handler) CreateCluster() iris.Handler {
}
notAllowed, err := checkRequiredPermissions(client, requiredPermissions)
if err != nil {
tx.Rollback()
ctx.StatusCode(iris.StatusInternalServerError)
ctx.Values().Set("message", err.Error())
return
}
if notAllowed != "" {
tx.Rollback()
ctx.StatusCode(iris.StatusInternalServerError)
ctx.Values().Set("message", []string{"permission %s required", notAllowed})
return
Expand Down

0 comments on commit 9a58aae

Please sign in to comment.