Skip to content

Commit

Permalink
container also flapping if avg uptime is less than 15 minutes with at…
Browse files Browse the repository at this point in the history
… least 2 restarts
  • Loading branch information
matt-deboer committed Oct 19, 2017
1 parent 67daf51 commit f70d34a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/ui/src/utils/resource-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,21 @@ export function statusForResource(resource) {
}
}
if (ready && scheduled && initialized) {
let podDuration = Date.now() - Date.parse(resource.status.startTime)
for (let cs of resource.status.containerStatuses) {
// if a container's previous run lasted less than 15 minutes, and the current
// If a container's previous run lasted less than 15 minutes, and the current
// run has been less than 15 minutes, we'll consider the container flapping
// Also if the container's average uptime is less than 15 minutes and it has
// restarted at least twice, we'll consider it flapping
const fifteenMinutes = 1000 * 60 * 15
let lastRun = cs.lastState.terminated
if (!!lastRun) {
let lastDuration = Date.parse(lastRun.finishedAt) - Date.parse(lastRun.startedAt)
let currentDuration = Date.now() - Date.parse(cs.state.running.startedAt)
if (currentDuration < fifteenMinutes && (lastDuration < fifteenMinutes || lastRun.reason !== 'Completed')) {
return 'warning'
} else if (cs.restartCount > 1 && podDuration / cs.restartCount < fifteenMinutes) {
return 'warning'
}
}
}
Expand Down

0 comments on commit f70d34a

Please sign in to comment.