Skip to content

Commit 2a199bc

Browse files
zelig81crenshaw-dev
andauthoredSep 18, 2024··
feat(health): add healthchecks for Gloo resources (#11379)
* feat(custom healthchecks): add healthchecks for Gloo resources Signed-off-by: Ilya Gorban <zelig81@users.noreply.github.com> * fix(gloo custom healthchecks): fix healthcheck and add older cases Signed-off-by: Ilya Gorban <zelig81@users.noreply.github.com> * feat(custom healthchecks): fix tabulation in Gloo resources lua files Signed-off-by: Ilya Gorban <zelig81@users.noreply.github.com> --------- Signed-off-by: Ilya Gorban <zelig81@users.noreply.github.com> Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
1 parent 7d28c89 commit 2a199bc

File tree

110 files changed

+2030
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+2030
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
hs = {
2+
status = "Progressing",
3+
message = "Update in progress"
4+
}
5+
6+
function getStatus(status)
7+
-- Accepted
8+
if status.state == "Accepted" or status.state == 1 then
9+
hs.status = "Healthy"
10+
hs.message = "The resource has been validated"
11+
return hs
12+
end
13+
14+
-- Warning
15+
if status.state == "Warning" or status.state == 3 then
16+
hs.status = "Degraded"
17+
hs.message = status.reason
18+
return hs
19+
end
20+
21+
-- Pending
22+
if status.state == "Pending" or status.state == 0 then
23+
hs.status = "Suspended"
24+
hs.message = "The resource has not yet been validated"
25+
return hs
26+
end
27+
28+
-- Rejected
29+
if status.state == "Rejected" or status.state == 2 then
30+
hs.status = "Degraded"
31+
hs.message = status.reason
32+
return hs
33+
end
34+
35+
return hs
36+
end
37+
38+
if obj.status ~= nil then
39+
-- Namespaced version of status
40+
if obj.status.statuses ~= nil then
41+
for i, namespace in pairs(obj.status.statuses) do
42+
hs = getStatus(namespace)
43+
if hs.status ~= "Progressing" then
44+
return hs
45+
end
46+
end
47+
end
48+
49+
-- Older non-namespaced version of status
50+
if obj.status.state ~= nil then
51+
hs = getStatus(obj.status)
52+
end
53+
end
54+
return hs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
tests:
2+
- healthStatus:
3+
status: Degraded
4+
message: "message that will describe all the reasons for warning"
5+
inputPath: testdata/gloo-warning.yaml
6+
- healthStatus:
7+
status: Suspended
8+
message: "The resource has not yet been validated"
9+
inputPath: testdata/gloo-pending.yaml
10+
- healthStatus:
11+
status: Healthy
12+
message: "The resource has been validated"
13+
inputPath: testdata/gloo-accepted.yaml
14+
- healthStatus:
15+
status: Degraded
16+
message: "message that will describe all the reasons for rejection"
17+
inputPath: testdata/gloo-rejected.yaml
18+
- healthStatus:
19+
status: Degraded
20+
message: "message that will describe all the reasons for warning"
21+
inputPath: testdata/non-namespaced-gloo-warning.yaml
22+
- healthStatus:
23+
status: Suspended
24+
message: "The resource has not yet been validated"
25+
inputPath: testdata/non-namespaced-gloo-pending.yaml
26+
- healthStatus:
27+
status: Healthy
28+
message: "The resource has been validated"
29+
inputPath: testdata/non-namespaced-gloo-accepted.yaml
30+
- healthStatus:
31+
status: Degraded
32+
message: "message that will describe all the reasons for rejection"
33+
inputPath: testdata/non-namespaced-gloo-rejected.yaml
34+
- healthStatus:
35+
status: Progressing
36+
message: "Update in progress"
37+
inputPath: testdata/gloo-no-status.yaml

0 commit comments

Comments
 (0)
Please sign in to comment.