mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
Simplify inconsistent silence update behavior
The old silence update behavior resulted in duplicated silences after e.g. updating a typo in a silence comment. I have to admit that I don't understand the idea behind the old logic, but I couldn't see a use case for creating a second silence when clicking on "Edit". The new behavior is very simple and will simply always delete an existing silence and replace it with the updated behavior. Fixes #188.
This commit is contained in:
parent
9729d2db16
commit
7385ac95fa
@ -417,20 +417,12 @@ angular.module('am.controllers').controller('SilenceCreateCtrl', function($scope
|
||||
};
|
||||
|
||||
$scope.create = function() {
|
||||
var now = new Date;
|
||||
// Go through conditions that go against immutability of historic silences.
|
||||
var createNew = !angular.equals(origSilence.matchers, $scope.silence.matchers);
|
||||
createNew = createNew || $scope.silence.elapsed;
|
||||
createNew = createNew || ($scope.silence.active && (origSilence.startsAt == $scope.silence.startsAt || origSilence.endsAt == $scope.silence.endsAt));
|
||||
|
||||
if (createNew) {
|
||||
if (origSilence.id) {
|
||||
$scope.silence.id = undefined;
|
||||
}
|
||||
|
||||
Silence.create($scope.silence, function(data) {
|
||||
// If the modifications require creating a new silence,
|
||||
// we expire/delete the old one.
|
||||
if (createNew && origSilence.id && !$scope.silence.elapsed) {
|
||||
if (origSilence.id) {
|
||||
Silence.delete({id: origSilence.id},
|
||||
function(data) {
|
||||
// Only trigger reload after after old silence was deleted.
|
||||
|
Loading…
Reference in New Issue
Block a user