From 8778ebfe9d83f5a8ab60410f74fef8f50da5db10 Mon Sep 17 00:00:00 2001 From: Henning Jacobs Date: Thu, 22 Dec 2016 14:08:12 +0100 Subject: [PATCH 1/2] #50 indicate pod restarts as red "ticks" and show number in tooltip --- .gitignore | 1 + app/src/pod.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index a98e69f..9cc8fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__ **/node_modules/ static/build/ *-secret +npm-debug.log* diff --git a/app/src/pod.js b/app/src/pod.js index e60eae4..4ab1386 100644 --- a/app/src/pod.js +++ b/app/src/pod.js @@ -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 Date: Thu, 22 Dec 2016 14:10:42 +0100 Subject: [PATCH 2/2] #50 add restarts to mock data --- app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 58c732f..555d975 100755 --- a/app.py +++ b/app.py @@ -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 = []