Skip to content

Commit

Permalink
fix(monitoring): do the switch for dev mode to not send alert
Browse files Browse the repository at this point in the history
Signed-off-by: Wen Zhou <wenzhou@redhat.com>
  • Loading branch information
zdtsw committed Oct 25, 2023
1 parent 70e398f commit 001cad1
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion controllers/dscinitialization/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,41 @@ func configureAlertManager(ctx context.Context, dsciInit *dsci.DSCInitialization
"<smtp_port>": string(smtpSecret.Data["port"]),
"<smtp_username>": string(smtpSecret.Data["username"]),
"<smtp_password>": string(smtpSecret.Data["password"]),
"@devshift.net": "@rhmw.io",
})
if err != nil {
r.Log.Error(err, "error to inject data to alertmanager-configs.yaml")
return err
}
// r.Log.Info("Success: inject alertmanage-configs.yaml")

// special handling for dev-mod
consolelinkDomain, err := common.GetDomain(r.Client, NameConsoleLink, NamespaceConsoleLink)
if err != nil {
return fmt.Errorf("error getting console route URL : %v", err)
}
if strings.Contains(consolelinkDomain, "devshift.org") {
err = common.ReplaceStringsInFile(filepath.Join(alertManagerPath, "alertmanager-configs.yaml"),
map[string]string{
"@devshift.net": "@rhmw.io",
})
if err != nil {
r.Log.Error(err, "error to replace data for dev mode1 to alertmanager-configs.yaml")
return err
}
}
if strings.Contains(consolelinkDomain, "aisrhods") {
err = common.ReplaceStringsInFile(filepath.Join(alertManagerPath, "alertmanager-configs.yaml"),
map[string]string{
"receiver: PagerDuty": "receiver: alerts-sink",
})
if err != nil {
r.Log.Error(err, "error to replace data for dev mode2 to alertmanager-configs.yaml")
return err
}
}

// r.Log.Info("Success: inject alertmanage-configs.yaml for dev mode")

operatorNs, err := upgrade.GetOperatorNamespace()
if err != nil {
r.Log.Error(err, "error getting operator namespace for smtp secret")
Expand Down

0 comments on commit 001cad1

Please sign in to comment.