From 9a58aaeee308817c5e529e95eb11f4a7ecbb3500 Mon Sep 17 00:00:00 2001 From: ssongliu Date: Wed, 12 Jan 2022 14:08:10 +0800 Subject: [PATCH] =?UTF-8?q?fix(cluster):=20=E5=B0=9D=E8=AF=95=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E5=88=9B=E5=BB=BA=E9=9B=86=E7=BE=A4=E8=B6=85=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/v1/cluster/cluster.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/api/v1/cluster/cluster.go b/internal/api/v1/cluster/cluster.go index 5ae32ef6b..21a5392ac 100644 --- a/internal/api/v1/cluster/cluster.go +++ b/internal/api/v1/cluster/cluster.go @@ -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 @@ -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