Skip to content

Commit

Permalink
when uninstalling set the alarm metadata to inactive
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreLamarre committed Oct 26, 2023
1 parent 1e3d978 commit c0cf95f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions plugins/alerting/pkg/alerting/alarms/v1/teardown.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package alarms

import (
"context"
"errors"
"fmt"

"github.com/rancher/opni/pkg/alerting/drivers/cortex"
Expand All @@ -22,13 +23,20 @@ func (p *AlarmServerComponent) teardownCondition(
cleanup bool,
) (retErr error) {
defer func() {
if cleanup && retErr == nil {
condStorage, err := p.conditionStorage.GetContext(ctx)
if err != nil {
condStorage, err := p.conditionStorage.GetContext(ctx)
if err != nil {
retErr = errors.Join(retErr, err)
}
if cleanup && retErr == nil { // user has requested a delete
if err := condStorage.Group(req.GroupId).Delete(ctx, id); err != nil {
retErr = err
return
}
if err := condStorage.Group(req.GroupId).Delete(ctx, id); err != nil {
} else if !cleanup && retErr == nil { // user has requested an uninstall without purging data
if req.Metadata == nil {
req.Metadata = map[string]string{}
}
req.Metadata[metadataInactiveAlarm] = "true"
if err := condStorage.Group(req.GroupId).Put(ctx, id, req); err != nil {
retErr = err
}
}
Expand Down

0 comments on commit c0cf95f

Please sign in to comment.