Skip to content

Commit 50f7f4d

Browse files
committed
Treat graph incidents separately in alerting
1 parent cc9d7b9 commit 50f7f4d

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

scripts/status.js

+16-9
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const SKUNKWORKS_CHANNEL = '720952130562687016';
3333
const networkABI = require('./abis/IColonyNetwork.json');
3434
const miningABI = require('./abis/IReputationMiningCycle.json');
3535

36-
let ongoingIncident = false;
36+
let ongoingGenericIncident = false;
37+
let ongoingGraphIncident = false;
3738

3839
module.exports = robot => {
3940
const { brain, messageChannel } = robot
@@ -50,7 +51,7 @@ module.exports = robot => {
5051
}
5152

5253
async function getMessage() {
53-
message = ""
54+
let message = ""
5455
// Get latest block from graph
5556
const graphNumberRes = getGraphLatestBlock("https://xdai.colony.io/graph/subgraphs/name/joinColony/subgraph")
5657
// Get latest block from blockscout
@@ -126,7 +127,7 @@ module.exports = robot => {
126127

127128
message += `${status(smallestGraphDiscrepancy, 24, 48)} Our graph latest block: ${graphNumber}\n`
128129

129-
if ((blockscoutLatestBlock - graphNumber) >= 48 && !ongoingIncident){
130+
if ((blockscoutLatestBlock - graphNumber) >= 48 && !ongoingGraphIncident){
130131
try { // Try and restart the graph digest pod
131132
// By the time this happens, the deployments script should have authed us
132133
// Get production colour
@@ -170,18 +171,24 @@ module.exports = robot => {
170171
const message = await getMessage();
171172
channel.send(message)
172173
if (message.indexOf("🔴") == -1){
173-
ongoingIncident = false;
174+
ongoingGenericIncident = false;
175+
ongoingGraphIncident = false;
174176
}
175177
})
176178

177179
async function checkStatus(){
178180
const message = await getMessage();
179-
if (message.indexOf("🔴") != -1 && !ongoingIncident){
180-
ongoingIncident = true;
181-
channel.send("There appears to be an incident. \n" + message)
181+
if (message.indexOf("🔴 Our graph latest block") != -1 && !ongoingGraphIncident) {
182+
ongoingGraphIncident = true;
183+
channel.send("There appears to be an incident with the graph. \n" + message)
184+
} else if (message.indexOf("🔴") != -1 && !ongoingGenericIncident){
185+
ongoingGenericIncident = true;
186+
channel.send("There appears to be a generic incident. \n" + message)
182187
}
183-
if (message.indexOf("🔴") == -1 && ongoingIncident){
184-
ongoingIncident = false;
188+
189+
if (message.indexOf("🔴") == -1 && (ongoingGenericIncident || ongoingGraphIncident)) {
190+
ongoingGenericIncident = false;
191+
ongoingGraphIncident = false;
185192
channel.send("Incident appears resolved.\n" + message)
186193
}
187194
}

0 commit comments

Comments
 (0)