diff --git a/html/index.html b/html/index.html index 53f16e7..6d53f18 100644 --- a/html/index.html +++ b/html/index.html @@ -697,7 +697,7 @@ k8s_jobs:
-

version: 2024-12-24 09:45:04

+

version: 2024-12-25 10:23:42

diff --git a/html/js/kubeinvaders.js b/html/js/kubeinvaders.js index 298d1b4..759123e 100644 --- a/html/js/kubeinvaders.js +++ b/html/js/kubeinvaders.js @@ -345,44 +345,40 @@ function deletePods(pod_name) { oReq.send(); } +function addNodeAndVMstoPods() { + if (chaos_vms && virtualMachines && virtualMachines.length > 0) { + pods = pods.concat(virtualMachines); + } + + if (nodes && nodes.length > 0) { + pods = pods.concat(nodes); + } + return pods; +} + + + function getPods() { if (chaos_pods) { var oReq = new XMLHttpRequest(); oReq.onload = function () { - new_pods = JSON.parse(this.responseText)["items"]; - + let new_pods = JSON.parse(this.responseText)["items"]; + // Pod might just be killed in game, but not terminated in k8s yet. for (i=0; i alien.name == new_pods[i].name && alien.status == "killed")) { new_pods[i].status = "killed"; } } - - if (chaos_vms && virtualMachines && virtualMachines.length > 0) { - pods = new_pods.concat(virtualMachines); - } - - if (nodes && nodes.length > 0) { - pods = new_pods.concat(nodes); - } - else { - pods = new_pods; - } - + pods = new_pods; + addNodeAndVMstoPods(); };; oReq.open("GET", k8s_url + "/kube/pods?action=list&namespace=" + namespace); oReq.send(); } else { - if (nodes && nodes.length > 0) { - pods = nodes; - } else { - pods = []; - } - - if (chaos_vms && virtualMachines && virtualMachines.length > 0) { - pods = pods.concat(virtualMachines); - } + pods = []; + addNodeAndVMstoPods(); } } @@ -855,10 +851,10 @@ window.setInterval(function setAliens() { }, 1000) window.setInterval(function backgroundTasks() { - + console.log("Nodes:", nodes); console.log("Virtual Machines:", virtualMachines); + console.log("chaos_vms flag:", chaos_vms); console.log("Pods:", pods); - if (!codename_configured) { chaosProgram = $('#chaosProgramTextArea').val();