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:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ __pycache__
|
|||||||
**/node_modules/
|
**/node_modules/
|
||||||
static/build/
|
static/build/
|
||||||
*-secret
|
*-secret
|
||||||
|
npm-debug.log*
|
||||||
|
|||||||
4
app.py
4
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'}}})
|
containers.append({'name': 'myapp', 'image': 'foo/bar/{}'.format(j), 'resources': {'requests': {'cpu': '100m', 'memory': '100Mi'}}})
|
||||||
status = {'phase': phase}
|
status = {'phase': phase}
|
||||||
if phase == 'Running':
|
if phase == 'Running':
|
||||||
if j % 10 == 0:
|
if j % 13 == 0:
|
||||||
status['containerStatuses'] = [{'ready': False, 'state': {'waiting': {'reason': 'CrashLoopBackOff'}}}]
|
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})
|
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})
|
nodes.append({'name': 'node-{}'.format(i), 'labels': labels, 'status': {'capacity': {'cpu': '4', 'memory': '32Gi', 'pods': '110'}}, 'pods': pods})
|
||||||
unassigned_pods = []
|
unassigned_pods = []
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export class Pod extends PIXI.Graphics {
|
|||||||
const containerStatuses = this.pod.status.containerStatuses || []
|
const containerStatuses = this.pod.status.containerStatuses || []
|
||||||
var ready = 0
|
var ready = 0
|
||||||
var running = 0
|
var running = 0
|
||||||
|
var restarts = 0
|
||||||
for (const containerStatus of containerStatuses) {
|
for (const containerStatus of containerStatuses) {
|
||||||
if (containerStatus.ready) {
|
if (containerStatus.ready) {
|
||||||
ready++
|
ready++
|
||||||
@@ -91,6 +92,7 @@ export class Pod extends PIXI.Graphics {
|
|||||||
if (containerStatus.state.running) {
|
if (containerStatus.state.running) {
|
||||||
running++
|
running++
|
||||||
}
|
}
|
||||||
|
restarts += containerStatus.restartCount || 0
|
||||||
}
|
}
|
||||||
const allReady = ready >= containerStatuses.length
|
const allReady = ready >= containerStatuses.length
|
||||||
const allRunning = running >= containerStatuses.length
|
const allRunning = running >= containerStatuses.length
|
||||||
@@ -120,6 +122,9 @@ export class Pod extends PIXI.Graphics {
|
|||||||
// "CrashLoopBackOff"
|
// "CrashLoopBackOff"
|
||||||
s += ': ' + containerStatus.state[key].reason
|
s += ': ' + containerStatus.state[key].reason
|
||||||
}
|
}
|
||||||
|
if (containerStatus.restartCount) {
|
||||||
|
s += ' (' + containerStatus.restartCount + ' restarts)'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
s += '\nCPU:'
|
s += '\nCPU:'
|
||||||
s += '\n Requested: ' + (resources.cpu.requested / FACTORS.m).toFixed(0) + ' m'
|
s += '\n Requested: ' + (resources.cpu.requested / FACTORS.m).toFixed(0) + ' m'
|
||||||
@@ -181,6 +186,16 @@ export class Pod extends PIXI.Graphics {
|
|||||||
}
|
}
|
||||||
newTick = this.terminating
|
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) {
|
if (newTick) {
|
||||||
this.tick = newTick
|
this.tick = newTick
|
||||||
PIXI.ticker.shared.add(this.tick, this)
|
PIXI.ticker.shared.add(this.tick, this)
|
||||||
|
|||||||
Reference in New Issue
Block a user