Merge pull request #54 from hjacobs/show-restarts

#50 indicate pod restarts as red "ticks" and show number in tooltip
This commit is contained in:
Henning Jacobs
2016-12-22 14:12:58 +01:00
committed by GitHub
3 changed files with 19 additions and 1 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ __pycache__
**/node_modules/
static/build/
*-secret
npm-debug.log*

4
app.py
View File

@@ -122,8 +122,10 @@ def generate_mock_cluster_data(index: int):
containers.append({'name': 'myapp', 'image': 'foo/bar/{}'.format(j), 'resources': {'requests': {'cpu': '100m', 'memory': '100Mi'}}})
status = {'phase': phase}
if phase == 'Running':
if j % 10 == 0:
if j % 13 == 0:
status['containerStatuses'] = [{'ready': False, 'state': {'waiting': {'reason': 'CrashLoopBackOff'}}}]
elif j % 7 == 0:
status['containerStatuses'] = [{'ready': True, 'state': {'running': {}}, 'restartCount': 3}]
pods.append({'name': 'my-pod-{}'.format(j), 'namespace': 'kube-system' if j < 3 else 'default', 'labels': labels, 'status': status, 'containers': containers})
nodes.append({'name': 'node-{}'.format(i), 'labels': labels, 'status': {'capacity': {'cpu': '4', 'memory': '32Gi', 'pods': '110'}}, 'pods': pods})
unassigned_pods = []

View File

@@ -84,6 +84,7 @@ export class Pod extends PIXI.Graphics {
const containerStatuses = this.pod.status.containerStatuses || []
var ready = 0
var running = 0
var restarts = 0
for (const containerStatus of containerStatuses) {
if (containerStatus.ready) {
ready++
@@ -91,6 +92,7 @@ export class Pod extends PIXI.Graphics {
if (containerStatus.state.running) {
running++
}
restarts += containerStatus.restartCount || 0
}
const allReady = ready >= containerStatuses.length
const allRunning = running >= containerStatuses.length
@@ -120,6 +122,9 @@ export class Pod extends PIXI.Graphics {
// "CrashLoopBackOff"
s += ': ' + containerStatus.state[key].reason
}
if (containerStatus.restartCount) {
s += ' (' + containerStatus.restartCount + ' restarts)'
}
}
s += '\nCPU:'
s += '\n Requested: ' + (resources.cpu.requested / FACTORS.m).toFixed(0) + ' m'
@@ -181,6 +186,16 @@ export class Pod extends PIXI.Graphics {
}
newTick = this.terminating
}
if (restarts) {
this.lineStyle(2, 0xff9999, 1)
for (let i=0; i<Math.min(restarts, 4); i++) {
this.moveTo(10, i*3 - 1)
this.lineTo(10, i*3 + 1)
}
}
if (newTick) {
this.tick = newTick
PIXI.ticker.shared.add(this.tick, this)