From f59ccb42916615b223526f6144c85638a1ed5610 Mon Sep 17 00:00:00 2001 From: Thibault Le Ouay Date: Tue, 1 Oct 2024 22:01:51 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20fixing=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/checker/handlers/checker.go | 11 +++++++++++ apps/server/src/checker/index.ts | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/apps/checker/handlers/checker.go b/apps/checker/handlers/checker.go index a2f6e1576c..1bf9723816 100644 --- a/apps/checker/handlers/checker.go +++ b/apps/checker/handlers/checker.go @@ -222,6 +222,17 @@ func (h Handler) HTTPCheckerHandler(c *gin.Context) { CronTimestamp: req.CronTimestamp, }) } + + // This happens when we don't have a degradedAfter + if isSuccessfull && req.DegradedAfter == 0 { + checker.UpdateStatus(ctx, checker.UpdateData{ + MonitorId: req.MonitorID, + Status: "active", + Region: h.Region, + StatusCode: res.Status, + CronTimestamp: req.CronTimestamp, + }) + } } if req.Status == "degraded" { diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts index de13d2f79d..c368c4b297 100644 --- a/apps/server/src/checker/index.ts +++ b/apps/server/src/checker/index.ts @@ -59,8 +59,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt), - ), + isNull(incidentTable.acknowledgedAt) + ) ) .get(); @@ -143,7 +143,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}`, + `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}` ); // If the number of affected regions is greater than half of the total region, we trigger the alerting // 4 of 6 monitor need to fail to trigger an alerting @@ -157,8 +157,8 @@ checkerRoute.post("/updateStatus", async (c) => { eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), isNull(incidentTable.acknowledgedAt), - eq(incidentTable.startedAt, new Date(cronTimestamp)), - ), + eq(incidentTable.startedAt, new Date(cronTimestamp)) + ) ) .get(); @@ -179,7 +179,9 @@ checkerRoute.post("/updateStatus", async (c) => { message, notifType: "alert", cronTimestamp, - incidentId: String(newIncident[0].id), + incidentId: newIncident.length + ? String(newIncident[0]?.id) + : `${cronTimestamp}`, }); if (newIncident.length > 0) { @@ -237,7 +239,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}`, + `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}` ); // // If the number of affected regions is greater than half of the total region, we trigger the alerting // // 4 of 6 monitor need to fail to trigger an alerting @@ -249,8 +251,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt), - ), + isNull(incidentTable.acknowledgedAt) + ) ) .get(); if (incident) { From 6bc61af48da293f848e5055979d60f8c0b55e55b Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 20:03:17 +0000 Subject: [PATCH 2/2] ci: apply automated fixes --- apps/server/src/checker/index.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/server/src/checker/index.ts b/apps/server/src/checker/index.ts index c368c4b297..3050d933c8 100644 --- a/apps/server/src/checker/index.ts +++ b/apps/server/src/checker/index.ts @@ -59,8 +59,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt) - ) + isNull(incidentTable.acknowledgedAt), + ), ) .get(); @@ -143,7 +143,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}` + `🤓 MonitorID ${monitorId} incident current affected ${nbAffectedRegion} total region ${numberOfRegions}`, ); // If the number of affected regions is greater than half of the total region, we trigger the alerting // 4 of 6 monitor need to fail to trigger an alerting @@ -157,8 +157,8 @@ checkerRoute.post("/updateStatus", async (c) => { eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), isNull(incidentTable.acknowledgedAt), - eq(incidentTable.startedAt, new Date(cronTimestamp)) - ) + eq(incidentTable.startedAt, new Date(cronTimestamp)), + ), ) .get(); @@ -239,7 +239,7 @@ checkerRoute.post("/updateStatus", async (c) => { const numberOfRegions = monitor.regions.length; console.log( - `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}` + `🤓 MonitorId ${monitorId} recovering incident current ${nbAffectedRegion} total region ${numberOfRegions}`, ); // // If the number of affected regions is greater than half of the total region, we trigger the alerting // // 4 of 6 monitor need to fail to trigger an alerting @@ -251,8 +251,8 @@ checkerRoute.post("/updateStatus", async (c) => { and( eq(incidentTable.monitorId, Number(monitorId)), isNull(incidentTable.resolvedAt), - isNull(incidentTable.acknowledgedAt) - ) + isNull(incidentTable.acknowledgedAt), + ), ) .get(); if (incident) {