@@ -8,6 +8,7 @@ const { isChannel, isPrivateDiscordMessage } = require('./utils/channels');
8
8
const fetch = require ( 'node-fetch' ) ;
9
9
const ethers = require ( 'ethers' )
10
10
const CronJob = require ( 'cron' ) . CronJob
11
+ const exec = require ( 'await-exec' )
11
12
12
13
// Minimal ABIs
13
14
@@ -97,6 +98,24 @@ module.exports = robot => {
97
98
// Graph latest block
98
99
message += `${ status ( Math . abs ( graphNumber - blockscoutLatestBlock ) , 12 , 24 ) } Our graph latest block: ${ graphNumber } \n`
99
100
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
+
100
119
// Miner balance
101
120
102
121
output = await balance . json ( )
@@ -131,7 +150,7 @@ module.exports = robot => {
131
150
const message = await getMessage ( ) ;
132
151
if ( message . indexOf ( "🔴" ) != - 1 && ! ongoingIncident ) {
133
152
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 )
135
154
}
136
155
if ( message . indexOf ( "🔴" ) == - 1 && ongoingIncident ) {
137
156
ongoingIncident = false ;
0 commit comments