From 8f921c33857bc8d301d9cdb5b52bcc06aa11963f Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Fri, 8 Apr 2022 15:09:35 +0800 Subject: [PATCH] fix(notify): lock panic when InitializeData --- pkg/notify/models/robot.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/notify/models/robot.go b/pkg/notify/models/robot.go index ff4c0b0beb..c8c8bea870 100644 --- a/pkg/notify/models/robot.go +++ b/pkg/notify/models/robot.go @@ -78,7 +78,8 @@ func (rm *SRobotManager) fetchSystemProjectId(ctx context.Context) (string, erro func (rm *SRobotManager) InitializeData() error { log.Infof("start to init data for notify robot") // init empty projectId robot - systemId, err := rm.fetchSystemProjectId(context.Background()) + ctx := context.WithValue(context.Background(), "from", "init") + systemId, err := rm.fetchSystemProjectId(ctx) if err != nil { return errors.Wrap(err, "unable to fetch system project id") } @@ -149,7 +150,6 @@ func (rm *SRobotManager) InitializeData() error { } robots = append(robots, robot) } - ctx := context.Background() var webhookRobotId string // insert new robot for i := range robots {