forked from argoproj/argo-cd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add health-checks for eck elastic beat (argoproj#16563)
* feat: add health-checks for eck elastic beat Signed-off-by: ebuildy <ebuildy@gmail.com> * fix tests Signed-off-by: ebuildy <ebuildy@gmail.com> --------- Signed-off-by: ebuildy <ebuildy@gmail.com>
- Loading branch information
Showing
9 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
resource_customizations/beat.k8s.elastic.co/Beat/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
local hs = {} | ||
|
||
if obj.status ~= nil and (obj.status.health ~= nil or obj.status.expectedNodes ~= nil) then | ||
if obj.status.health == "red" then | ||
hs.status = "Degraded" | ||
hs.message = "Elastic Beat status is Red" | ||
return hs | ||
elseif obj.status.health == "green" then | ||
hs.status = "Healthy" | ||
hs.message = "Elastic Beat status is Green" | ||
return hs | ||
elseif obj.status.health == "yellow" then | ||
if obj.status.availableNodes ~= nil and obj.status.expectedNodes ~= nil then | ||
hs.status = "Progressing" | ||
hs.message = "Elastic Beat status is deploying, there is " .. obj.status.availableNodes .. " instance(s) on " .. obj.status.expectedNodes .. " expected" | ||
return hs | ||
else | ||
hs.status = "Progressing" | ||
hs.message = "Elastic Beat phase is progressing" | ||
return hs | ||
end | ||
elseif obj.status.health == nil then | ||
hs.status = "Progressing" | ||
hs.message = "Elastic Beat phase is progressing" | ||
return hs | ||
end | ||
end | ||
|
||
hs.status = "Unknown" | ||
hs.message = "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues" | ||
return hs |
29 changes: 29 additions & 0 deletions
29
resource_customizations/beat.k8s.elastic.co/Beat/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
tests: | ||
- healthStatus: | ||
status: Healthy | ||
message: "Elastic Beat status is Green" | ||
inputPath: testdata/ready_green.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Elastic Beat phase is progressing" | ||
inputPath: testdata/ready_yellow_single_node.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Elastic Beat status is deploying, there is 1 instance(s) on 2 expected" | ||
inputPath: testdata/ready_yellow.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: "Elastic Beat phase is progressing" | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: "Elastic Beat status is Red" | ||
inputPath: testdata/ready_red.yaml | ||
- healthStatus: | ||
status: Unknown | ||
message: "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues" | ||
inputPath: testdata/unknown.yaml | ||
- healthStatus: | ||
status: Unknown | ||
message: "Elastic Beat status is unknown. Ensure your ArgoCD is current and then check for/file a bug report: https://github.com/argoproj/argo-cd/issues" | ||
inputPath: testdata/invalid.yaml |
12 changes: 12 additions & 0 deletions
12
resource_customizations/beat.k8s.elastic.co/Beat/testdata/invalid.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
expectedNodes: 1 | ||
health: invalid | ||
observedGeneration: 1 | ||
version: 8.8.1 |
11 changes: 11 additions & 0 deletions
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/progressing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
expectedNodes: 1 | ||
observedGeneration: 1 | ||
version: 8.8.1 |
13 changes: 13 additions & 0 deletions
13
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_green.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
expectedNodes: 1 | ||
availableNodes: 1 | ||
health: green | ||
observedGeneration: 1 | ||
version: 8.8.1 |
10 changes: 10 additions & 0 deletions
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_red.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
expectedNodes: 1 | ||
health: red |
11 changes: 11 additions & 0 deletions
11
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
availableNodes: 1 | ||
expectedNodes: 2 | ||
health: yellow |
10 changes: 10 additions & 0 deletions
10
resource_customizations/beat.k8s.elastic.co/Beat/testdata/ready_yellow_single_node.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: | ||
expectedNodes: 1 | ||
health: yellow |
8 changes: 8 additions & 0 deletions
8
resource_customizations/beat.k8s.elastic.co/Beat/testdata/unknown.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
apiVersion: beat.k8s.elastic.co/v1beta1 | ||
kind: Beat | ||
metadata: | ||
name: quickstart | ||
spec: | ||
version: 8.8.8 | ||
type: metricbeat | ||
status: {} |