@@ -35,6 +35,7 @@ const miningABI = require('./abis/IReputationMiningCycle.json');
35
35
36
36
let ongoingGenericIncident = false ;
37
37
let ongoingGraphIncident = false ;
38
+ let ongoingQAIncident = false ;
38
39
39
40
module . exports = robot => {
40
41
const { brain, messageChannel } = robot
@@ -54,6 +55,11 @@ module.exports = robot => {
54
55
let message = ""
55
56
// Get latest block from graph
56
57
const graphNumberRes = getGraphLatestBlock ( "https://xdai.colony.io/graph/subgraphs/name/joinColony/subgraph" )
58
+
59
+ // Get latest block from QA graph
60
+
61
+ const qaGraphNumberRes = getGraphLatestBlock ( "http://thegraph-query-red-network-100:8000/subgraphs/name/joinColony/subgraph" )
62
+
57
63
// Get latest block from blockscout
58
64
const blockscoutRes = fetch ( "https://blockscout.com/xdai/mainnet/api?module=block&action=eth_block_number" )
59
65
@@ -99,7 +105,7 @@ module.exports = robot => {
99
105
} )
100
106
} )
101
107
102
- const [ graphNumber , blockScoutBlock , RPCBlock , balance , xdaichainRpcBlock ] = await Promise . all ( [ graphNumberRes , blockscoutRes , rpcRes , balanceRes , xdaichainRpcRes ] )
108
+ const [ graphNumber , qaGraphNumber , blockScoutBlock , RPCBlock , balance , xdaichainRpcBlock ] = await Promise . all ( [ graphNumberRes , qaGraphNumberRes , blockscoutRes , rpcRes , balanceRes , xdaichainRpcRes ] )
103
109
104
110
output = await blockScoutBlock . json ( )
105
111
const blockscoutLatestBlock = parseInt ( output . result , 16 )
@@ -145,6 +151,34 @@ module.exports = robot => {
145
151
}
146
152
}
147
153
154
+ // QA Graph latest block
155
+ smallestQAGraphDiscrepancy = Math . min (
156
+ Math . abs ( qaGraphNumber - blockscoutLatestBlock ) ,
157
+ Math . abs ( qaGraphNumber - xdaichainLatestBlock )
158
+ )
159
+
160
+ if ( ( blockscoutLatestBlock - qaGraphNumber ) >= 48 && ! ongoingQAIncident ) {
161
+ ongoingQAIncident = true ;
162
+ try { // Try and restart the qa graph digest pod
163
+ // By the time this happens, the deployments script should have authed us
164
+ // QA colour is red
165
+ const colour = "red"
166
+ // Get production graph digest node
167
+ res = await exec ( `kubectl get pods --sort-by=.metadata.creationTimestamp | grep digest-${ colour } | tail -n1 | awk '{print $1}' | tr -d '\n'` )
168
+ const qaGraphDigest = res . stdout ;
169
+ // delete it
170
+ await exec ( `kubectl delete pod ${ qaGraphDigest } ` )
171
+ await channel . send ( `**Attempted to restart QA subgraph as it appeared ${ smallestQAGraphDiscrepancy } blocks behind.**` )
172
+ } catch ( err ) {
173
+ console . log ( err )
174
+ await channel . send ( "**Attempted restart of QA graph failed - check logs.**\n" )
175
+ }
176
+ } else if ( ( blockscoutLatestBlock - qaGraphNumber ) < 48 && ongoingQAIncident ) {
177
+ ongoingQAIncident = false ;
178
+ await channel . send ( `QA subgraph appears fixed` )
179
+ }
180
+
181
+
148
182
// Miner balance
149
183
150
184
output = await balance . json ( )
0 commit comments