Skip to content

Commit

Permalink
Add retry on Delete silence
Browse files Browse the repository at this point in the history
Signed-off-by: Eunice Kim <[email protected]>
  • Loading branch information
euniceek committed Mar 1, 2024
1 parent eafc37a commit 3a0168c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/alertmanager/distributor.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (d *Distributor) doUnary(userID string, w http.ResponseWriter, r *http.Requ
// we forward the request to only only of the alertmanagers.

var instances []ring.InstanceDesc
if req.GetMethod() == "GET" {
if req.GetMethod() == "GET" || req.GetMethod() == "DELETE" {
instances = replicationSet.Instances
// Randomize the list of instances to not always query the same one.
rand.Shuffle(len(instances), func(i, j int) {
Expand Down
18 changes: 18 additions & 0 deletions pkg/alertmanager/distributor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,24 @@ func TestDistributor_DistributeRequest(t *testing.T) {
expStatusCode: http.StatusOK,
expectedTotalCalls: 1,
route: "/silence/id",
}, {
name: "Delete /silence/id should try all alert managers on error",
numAM: 3,
numHappyAM: 0,
replicationFactor: 3,
isDelete: true,
expStatusCode: http.StatusInternalServerError,
expectedTotalCalls: 3,
route: "/silence/id",
}, {
name: "Delete /silence/id is sent to 3 AM when 2 are not happy",
numAM: 3,
numHappyAM: 1,
replicationFactor: 3,
isDelete: true,
expStatusCode: http.StatusOK,
expectedTotalCalls: 3,
route: "/silence/id",
}, {
name: "Read /status is sent to only 1 AM",
numAM: 5,
Expand Down

0 comments on commit 3a0168c

Please sign in to comment.