@@ -8,6 +8,7 @@ const { isChannel, isPrivateDiscordMessage } = require('./utils/channels');
88const fetch = require ( 'node-fetch' ) ;
99const ethers = require ( 'ethers' )
1010const CronJob = require ( 'cron' ) . CronJob
11+ const exec = require ( 'await-exec' )
1112
1213// Minimal ABIs
1314
@@ -97,6 +98,24 @@ module.exports = robot => {
9798 // Graph latest block
9899 message += `${ status ( Math . abs ( graphNumber - blockscoutLatestBlock ) , 12 , 24 ) } Our graph latest block: ${ graphNumber } \n`
99100
101+ if ( ( blockscoutLatestBlock - graphNumber ) > 24 ) {
102+ try { // Try and restart the graph digest pod
103+ // By the time this happens, the deployments script should have authed us
104+ // Get production colour
105+ let res = await exec ( "kubectl get svc nginx-prod-2 -o yaml | grep colour: | awk '{print $2}' | tr -d '\n'" )
106+ const productionColour = res . stdout ;
107+ // Get production graph digest node
108+ res = await exec ( `kubectl get pods --sort-by=.metadata.creationTimestamp | grep digest-${ productionColour } | tail -n1 | awk '{print $1}' | tr -d '\n'` )
109+ const productionGraphDigest = res . stdout ;
110+ // delete it
111+ await exec ( `kubectl delete pod ${ productionGraphDigest } ` )
112+ message += "**I have tried to restart the graph. If successful, incident will resolve itself shortly**\n"
113+ } catch ( err ) {
114+ console . log ( err )
115+ message += "**Attempted restart of graph failed - check logs. I will not try again for this incident**\n"
116+ }
117+ }
118+
100119 // Miner balance
101120
102121 output = await balance . json ( )
@@ -131,7 +150,7 @@ module.exports = robot => {
131150 const message = await getMessage ( ) ;
132151 if ( message . indexOf ( "🔴" ) != - 1 && ! ongoingIncident ) {
133152 ongoingIncident = true ;
134- channel . send ( "There appears to be an incident. Someone smarter than me needs to handle it. \n" + message )
153+ channel . send ( "There appears to be an incident. \n" + message )
135154 }
136155 if ( message . indexOf ( "🔴" ) == - 1 && ongoingIncident ) {
137156 ongoingIncident = false ;
0 commit comments