diff --git a/html5/index.html b/html5/index.html
index a19efdf..8a68255 100644
--- a/html5/index.html
+++ b/html5/index.html
@@ -244,7 +244,7 @@ experiments:
@@ -306,12 +306,14 @@ experiments:
$('#alert_placeholder3').replaceWith(alert_div_webtail + 'Stopping log tail
');
log_tail_switch = false;
log_tail_div.style.display = "none";
+ disableLogTail();
} else {
$('#alert_placeholder3').replaceWith(alert_div_webtail + 'Starting log tail');
$("#logConsoleButton").text("Stop Logs Tail");
log_tail_switch = true;
log_tail_div.style.display = "block";
- setRedisLogRegex();
+ setLogRegex();
+ enableTail();
}
}
diff --git a/html5/kubeinvaders.js b/html5/kubeinvaders.js
index 22d8324..b9a96f6 100644
--- a/html5/kubeinvaders.js
+++ b/html5/kubeinvaders.js
@@ -208,34 +208,47 @@ function getCurrentChaosContainer() {
oReq.send();
}
-function setRedisLogRegex() {
- $('#alert_placeholder3').replaceWith(alert_div + 'Setting Regular Expression for filtering log source (by pod name)');
+function enableLogTail() {
+ var oReq = new XMLHttpRequest();
+ oReq.open("POST", "https://" + clu_endpoint + "/kube/chaos/containers?action=enable_logs_tail", true);
- if (log_tail_switch) {
- var oReq = new XMLHttpRequest();
- oReq.open("GET", "https://" + clu_endpoint + "/kube/chaos/containers?action=disable_logs_tail", true);
+ oReq.onreadystatechange = function () {
+ if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
+ $('#alert_placeholder3').replaceWith(alert_div + 'Logs tail started ');
+ }
+ };;
+ oReq.setRequestHeader("Content-Type", "application/json");
+ // TODO: send payload for auth...
+ oReq.send({});
+}
- oReq.onreadystatechange = function () {
- if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
- $('#alert_placeholder3').replaceWith(alert_div + 'Logs tail stopped ');
- }
- };;
+function disableLogTail() {
+ var oReq = new XMLHttpRequest();
+ oReq.open("POST", "https://" + clu_endpoint + "/kube/chaos/containers?action=disable_log_tail", true);
- oReq.send()
+ oReq.onreadystatechange = function () {
+ if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
+ $('#alert_placeholder3').replaceWith(alert_div + 'Logs tail stopped ');
+ }
+ };;
+ oReq.setRequestHeader("Content-Type", "application/json");
+ // TODO: send payload for auth...
+ oReq.send({});
+}
- } else {
- var oReq = new XMLHttpRequest();
- oReq.open("POST", "https://" + clu_endpoint + "/kube/chaos/containers?action=enable_logs_tail", true);
+function setLogRegex() {
+ $('#alert_placeholder3').replaceWith(alert_div + 'Setting regex for filtering log source (by pod name)');
+ var oReq = new XMLHttpRequest();
+ oReq.open("POST", "https://" + clu_endpoint + "/kube/chaos/containers?action=set_log_regex", true);
- oReq.onreadystatechange = function () {
- if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
- $('#alert_placeholder3').replaceWith(alert_div + 'Logs tail started');
- }
- };;
+ oReq.onreadystatechange = function () {
+ if (this.readyState === XMLHttpRequest.DONE && this.status === 200) {
+ $('#alert_placeholder3').replaceWith(alert_div + 'Logs tail started');
+ }
+ };;
- oReq.setRequestHeader("Content-Type", "application/json");
- oReq.send($('#logConsoleRegex').val())
- }
+ oReq.setRequestHeader("Content-Type", "application/json");
+ oReq.send($('#logConsoleRegex').val());
}
function setChaosContainer() {
diff --git a/scripts/chaos-containers.lua b/scripts/chaos-containers.lua
index 123ad33..a42c756 100644
--- a/scripts/chaos-containers.lua
+++ b/scripts/chaos-containers.lua
@@ -33,14 +33,19 @@ elseif ngx.var.request_method == "POST" and action == 'set' then
red:set("chaos_container", body_data)
ngx.say("New chaos container definition has been configured in Redis")
return ngx.exit(ngx.status)
-elseif ngx.var.request_method == "POST" and action == "enable_logs_tail" then
+
+elseif ngx.var.request_method == "POST" and action == "set_log_regex" then
local body_data = ngx.req.get_body_data()
red:set("log_pod_regex", body_data)
- red:set("logs_enabled", "1")
ngx.say("New container definition has been saved in Redis")
return ngx.exit(ngx.status)
-elseif ngx.var.request_method == "GET" and action == "disable_logs_tail" then
+
+elseif ngx.var.request_method == "POST" and action == "enable_logs_tail" then
+ local body_data = ngx.req.get_body_data()
+ red:set("logs_enabled", "1")
+ return ngx.exit(ngx.status)
+
+elseif ngx.var.request_method == "POST" and action == "disable_logs_tail" then
red:set("logs_enabled", "0")
- ngx.say("New container definition has been saved in Redis")
return ngx.exit(ngx.status)
end