[release-11.6.3] CloudMigrations: Omit autoincremented id for alert snapshots (#106638)

CloudMigrations: Omit autoincremented id for alert snapshots (#106598)

If you tried to migrate alerts from two differente sources/on-prem instances,
the autoincremented numeric id would be the same, and since we were creating
the resource in cloud with that same id (the API accepts it), it would
return an error "conflicting alert rule found" because that id is the primary key on the table.

We simply omit the numeric id now and let the API for the cloud instance generate it.

(cherry picked from commit a1f2693fd8)

Co-authored-by: Matheus Macabu <macabu@users.noreply.github.com>
pull/106653/head
grafana-delivery-bot[bot] 2 weeks ago committed by GitHub
parent e35e880e89
commit 0a757fae39
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      pkg/services/cloudmigration/cloudmigrationimpl/snapshot_mgmt_alerts.go

@ -135,7 +135,6 @@ type alertRule struct {
Title string `json:"title"` Title string `json:"title"`
ExecErrState string `json:"execErrState"` ExecErrState string `json:"execErrState"`
Data []definitions.AlertQuery `json:"data"` Data []definitions.AlertQuery `json:"data"`
ID int64 `json:"id"`
For model.Duration `json:"for"` For model.Duration `json:"for"`
OrgID int64 `json:"orgID"` OrgID int64 `json:"orgID"`
IsPaused bool `json:"isPaused"` IsPaused bool `json:"isPaused"`
@ -158,7 +157,6 @@ func (s *Service) getAlertRules(ctx context.Context, signedInUser *user.SignedIn
} }
provisionedAlertRules = append(provisionedAlertRules, alertRule{ provisionedAlertRules = append(provisionedAlertRules, alertRule{
ID: rule.ID,
UID: rule.UID, UID: rule.UID,
OrgID: rule.OrgID, OrgID: rule.OrgID,
FolderUID: rule.NamespaceUID, FolderUID: rule.NamespaceUID,
@ -208,7 +206,6 @@ func (s *Service) getAlertRuleGroups(ctx context.Context, signedInUser *user.Sig
} }
provisionedAlertRules = append(provisionedAlertRules, alertRule{ provisionedAlertRules = append(provisionedAlertRules, alertRule{
ID: rule.ID,
UID: rule.UID, UID: rule.UID,
OrgID: rule.OrgID, OrgID: rule.OrgID,
FolderUID: rule.NamespaceUID, FolderUID: rule.NamespaceUID,

Loading…
Cancel
Save