Skip to content

Commit 4f869f4

Browse files
committed
Add retry on Delete silence
Signed-off-by: Eunice Kim <[email protected]>
1 parent 2cd304b commit 4f869f4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* [ENHANCEMENT] Query Frontend/Scheduler: Time check in query priority now considers overall data select time window (including range selectors, modifiers and lookback delta). #5758
2424
* [ENHANCEMENT] Querier: Added `querier.store-gateway-query-stats-enabled` to enable or disable store gateway query stats log. #5749
2525
* [ENHANCEMENT] Upgrade to go 1.21.6. #5765
26+
* [ENHANCEMENT] AlertManager: Retrying AlertManager Delete Silence on error #5794
2627
* [BUGFIX] Distributor: Do not use label with empty values for sharding #5717
2728
* [BUGFIX] Query Frontend: queries with negative offset should check whether it is cacheable or not. #5719
2829
* [BUGFIX] Redis Cache: pass `cache_size` config correctly. #5734

pkg/alertmanager/distributor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,14 @@ func (d *Distributor) doUnary(userID string, w http.ResponseWriter, r *http.Requ
247247
// we forward the request to only only of the alertmanagers.
248248

249249
var instances []ring.InstanceDesc
250-
if req.GetMethod() == "GET" {
250+
if req.GetMethod() == "GET" || req.GetMethod() == "DELETE" {
251251
instances = replicationSet.Instances
252252
// Randomize the list of instances to not always query the same one.
253253
rand.Shuffle(len(instances), func(i, j int) {
254254
instances[i], instances[j] = instances[j], instances[i]
255255
})
256256
} else {
257-
//Picking 1 instance at Random for Non-Get Unary Read requests, as shuffling through large number of instances might increase complexity
257+
//Picking 1 instance at Random for Non-Get and Non-Delete Unary Read requests, as shuffling through large number of instances might increase complexity
258258
randN := rand.Intn(len(replicationSet.Instances))
259259
instances = replicationSet.Instances[randN : randN+1]
260260
}

pkg/alertmanager/distributor_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,24 @@ func TestDistributor_DistributeRequest(t *testing.T) {
200200
expStatusCode: http.StatusOK,
201201
expectedTotalCalls: 1,
202202
route: "/silence/id",
203+
}, {
204+
name: "Delete /silence/id should try all alert managers on error",
205+
numAM: 3,
206+
numHappyAM: 0,
207+
replicationFactor: 3,
208+
isDelete: true,
209+
expStatusCode: http.StatusInternalServerError,
210+
expectedTotalCalls: 3,
211+
route: "/silence/id",
212+
}, {
213+
name: "Delete /silence/id is sent to 3 AM when 2 are not happy",
214+
numAM: 3,
215+
numHappyAM: 1,
216+
replicationFactor: 3,
217+
isDelete: true,
218+
expStatusCode: http.StatusOK,
219+
expectedTotalCalls: 3,
220+
route: "/silence/id",
203221
}, {
204222
name: "Read /status is sent to only 1 AM",
205223
numAM: 5,

0 commit comments

Comments
 (0)