From f653aba7355adf2e34016c756741902a5104613e Mon Sep 17 00:00:00 2001 From: Janne Nowak Date: Wed, 17 May 2023 18:52:28 +0200 Subject: [PATCH 1/5] added docker health status --- server/model/monitor.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index b5e58c574..cfa006340 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -574,10 +574,17 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Axios Request`); let res = await axios.request(options); - if (res.data.State.Running) { + + if (res.data.State.Health && res.data.State.Health.Status !== "healthy"){ + bean.status = PENDING; + bean.msg = res.data.State.Health.Status; + log.debug("monitor", `[${this.name}] Monitor is ${res.data.State.Health.Status}`); + } + else if (res.data.State.Running) { bean.status = UP; - bean.msg = res.data.State.Status; - } else { + bean.msg = res.data.State.Health? res.data.State.Health.Status:res.data.State.Status; + } + else { throw Error("Container State is " + res.data.State.Status); } } else if (this.type === "mqtt") { From 6b5e179bb064d9e20bc957f7fec09c6054727c7a Mon Sep 17 00:00:00 2001 From: Janne Nowak Date: Wed, 17 May 2023 19:02:34 +0200 Subject: [PATCH 2/5] linting --- server/model/monitor.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index cfa006340..f9a77d067 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -575,16 +575,14 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Axios Request`); let res = await axios.request(options); - if (res.data.State.Health && res.data.State.Health.Status !== "healthy"){ + if (res.data.State.Health && res.data.State.Health.Status !== "healthy") { bean.status = PENDING; bean.msg = res.data.State.Health.Status; log.debug("monitor", `[${this.name}] Monitor is ${res.data.State.Health.Status}`); - } - else if (res.data.State.Running) { + } else if (res.data.State.Running) { bean.status = UP; - bean.msg = res.data.State.Health? res.data.State.Health.Status:res.data.State.Status; - } - else { + bean.msg = res.data.State.Health ? res.data.State.Health.Status : res.data.State.Status; + } else { throw Error("Container State is " + res.data.State.Status); } } else if (this.type === "mqtt") { From 891f09def7c286f5427f9a3db98e43d92ad20820 Mon Sep 17 00:00:00 2001 From: Janne Nowak Date: Wed, 17 May 2023 19:15:10 +0200 Subject: [PATCH 3/5] removed log --- server/model/monitor.js | 1 - 1 file changed, 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index f9a77d067..0b2cab703 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -578,7 +578,6 @@ class Monitor extends BeanModel { if (res.data.State.Health && res.data.State.Health.Status !== "healthy") { bean.status = PENDING; bean.msg = res.data.State.Health.Status; - log.debug("monitor", `[${this.name}] Monitor is ${res.data.State.Health.Status}`); } else if (res.data.State.Running) { bean.status = UP; bean.msg = res.data.State.Health ? res.data.State.Health.Status : res.data.State.Status; From f30f00655f4276b92e047bc869435e33739c67e3 Mon Sep 17 00:00:00 2001 From: Janne Nowak Date: Wed, 17 May 2023 23:18:29 +0200 Subject: [PATCH 4/5] small fix for down containers --- server/model/monitor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 0b2cab703..42fb20c6a 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -575,7 +575,7 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Axios Request`); let res = await axios.request(options); - if (res.data.State.Health && res.data.State.Health.Status !== "healthy") { + if (res.data.State.Health && res.data.State.Health.Status !== "healthy" && res.data.State.Running) { bean.status = PENDING; bean.msg = res.data.State.Health.Status; } else if (res.data.State.Running) { From f604d96c5bc52b984b66d611658456ce2cf9b00a Mon Sep 17 00:00:00 2001 From: Janne Nowak Date: Thu, 18 May 2023 09:55:33 +0200 Subject: [PATCH 5/5] splited if to inner if --- server/model/monitor.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/model/monitor.js b/server/model/monitor.js index 42fb20c6a..9a6ac1d3b 100644 --- a/server/model/monitor.js +++ b/server/model/monitor.js @@ -575,12 +575,14 @@ class Monitor extends BeanModel { log.debug("monitor", `[${this.name}] Axios Request`); let res = await axios.request(options); - if (res.data.State.Health && res.data.State.Health.Status !== "healthy" && res.data.State.Running) { - bean.status = PENDING; - bean.msg = res.data.State.Health.Status; - } else if (res.data.State.Running) { - bean.status = UP; - bean.msg = res.data.State.Health ? res.data.State.Health.Status : res.data.State.Status; + if (res.data.State.Running) { + if (res.data.State.Health && res.data.State.Health.Status !== "healthy") { + bean.status = PENDING; + bean.msg = res.data.State.Health.Status; + } else { + bean.status = UP; + bean.msg = res.data.State.Health ? res.data.State.Health.Status : res.data.State.Status; + } } else { throw Error("Container State is " + res.data.State.Status); }