Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: retry posting webhook (#3645)
p0nybd913f098fa5
diff --git a/plugin/webhook/webhook.go b/plugin/webhook/webhook.goindex bbf4f3d6b0..a388bd1111 100644--- a/plugin/webhook/webhook.go+++ b/plugin/webhook/webhook.go@@ -159,6 +159,5 @@ func Post(webhookType string, context Context) error {if !ok {return errors.Errorf("webhook: no applicable receiver for webhook type: %v", webhookType)}-return r.post(context)}diff --git a/server/activity_manager.go b/server/activity_manager.goindex 9052e2ebe0..3713a19f31 100644--- a/server/activity_manager.go+++ b/server/activity_manager.go@@ -104,7 +104,7 @@ func (m *ActivityManager) BatchCreateTaskStatusUpdateApprovalActivity(ctx contexCreatorEmail: anyActivity.Creator.Email,}// Call external webhook endpoint in Go routine to avoid blocking web serving thread.- go postWebhookList(webhookCtx, webhookList, issue)+ go postWebhookList(webhookCtx, webhookList)return nil}@@ -157,23 +157,28 @@ func (m *ActivityManager) CreateActivity(ctx context.Context, create *api.Activireturn activity, nil}// Call external webhook endpoint in Go routine to avoid blocking web serving thread.- go postWebhookList(webhookCtx, webhookList, meta.issue)+ go postWebhookList(webhookCtx, webhookList)return activity, nil}-func postWebhookList(webhookCtx webhook.Context, webhookList []*api.ProjectWebhook, issue *api.Issue) {+func postWebhookList(webhookCtx webhook.Context, webhookList []*api.ProjectWebhook) {for _, hook := range webhookList {webhookCtx.URL = hook.URLwebhookCtx.CreatedTs = time.Now().Unix()- if err := webhook.Post(hook.Type, webhookCtx); err != nil {- // The external webhook endpoint might be invalid which is out of our code control, so we just emit a warning- log.Warn("Failed to post webhook event after changing the issue status",- zap.String("webhook_type", hook.Type),- zap.String("webhook_name", hook.Name),- zap.String("issue_name", issue.Name),- zap.String("status", string(issue.Status)),- zap.Error(err))+ const maxRetries = 3+ for retries := 0; retries < maxRetries; retries++ {+ if err := webhook.Post(hook.Type, webhookCtx); err != nil {+ // The external webhook endpoint might be invalid which is out of our code control, so we just emit a warning+ log.Warn("Failed to post webhook event on activity",+ zap.String("webhook type", hook.Type),+ zap.String("webhook name", hook.Name),+ zap.String("activity type", webhookCtx.ActivityType),+ zap.String("title", webhookCtx.Title),+ zap.Error(err))+ } else {+ break+ }}}}