Skip to content

Commit 36cc2d1

Browse files
fix(health): CRD health check message (#23690) (cherry-pick #23691) (#23738)
Signed-off-by: Michael Crenshaw <[email protected]> Co-authored-by: Michael Crenshaw <[email protected]>
1 parent 9db5e25 commit 36cc2d1

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

resource_customizations/apiextensions.k8s.io/CustomResourceDefinition/health.lua

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,36 @@ if #obj.status.conditions == 0 then
2020
end
2121

2222
local isEstablished
23-
local isTerminating
24-
local namesNotAccepted
25-
local hasViolations
2623
local conditionMsg = ""
2724

2825
for _, condition in pairs(obj.status.conditions) do
2926

3027
-- Check if CRD is terminating
3128
if condition.type == "Terminating" and condition.status == "True" then
32-
isTerminating = true
33-
conditionMsg = condition.message
29+
hs.status = "Progressing"
30+
hs.message = "CRD is terminating: " .. condition.message
31+
return hs
3432
end
3533

3634
-- Check if K8s has accepted names for this CRD
3735
if condition.type == "NamesAccepted" and condition.status == "False" then
38-
namesNotAccepted = true
39-
conditionMsg = condition.message
36+
hs.status = "Degraded"
37+
hs.message = "CRD names have not been accepted: " .. condition.message
38+
return hs
39+
end
40+
41+
-- Checking if CRD has violations
42+
if condition.type == "NonStructuralSchema" and condition.status == "True" then
43+
hs.status = "Degraded"
44+
hs.message = "Schema violations found: " .. condition.message
45+
return hs
4046
end
4147

4248
-- Checking if CRD is established
4349
if condition.type == "Established" and condition.status == "True" then
4450
isEstablished = true
4551
conditionMsg = condition.message
4652
end
47-
48-
-- Checking if CRD has violations
49-
if condition.type == "NonStructuralSchema" and condition.status == "True" then
50-
hasViolations = true
51-
conditionMsg = condition.message
52-
end
53-
54-
end
55-
56-
if isTerminating then
57-
hs.status = "Progressing"
58-
hs.message = "CRD is terminating: " .. conditionMsg
59-
return hs
60-
end
61-
62-
if namesNotAccepted then
63-
hs.status = "Degraded"
64-
hs.message = "CRD names have not been accepted: " .. conditionMsg
65-
return hs
6653
end
6754

6855
if not isEstablished then
@@ -71,12 +58,6 @@ if not isEstablished then
7158
return hs
7259
end
7360

74-
if hasViolations then
75-
hs.status = "Degraded"
76-
hs.message = "Schema violations found: " .. conditionMsg
77-
return hs
78-
end
79-
8061
hs.status = "Healthy"
8162
hs.message = "CRD is healthy"
8263
return hs

resource_customizations/apiextensions.k8s.io/CustomResourceDefinition/testdata/crd-v1-non-structual-degraded.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ status:
4747
reason: NoConflicts
4848
status: 'True'
4949
type: NamesAccepted
50-
- lastTransitionTime: '2024-05-19T23:35:28Z'
51-
message: the initial names have been accepted
52-
reason: InitialNamesAccepted
53-
status: 'True'
54-
type: Established
5550
- lastTransitionTime: '2024-10-26T19:44:57Z'
5651
message: 'spec.preserveUnknownFields: Invalid value: true: must be false'
5752
reason: Violations
5853
status: 'True'
5954
type: NonStructuralSchema
55+
- lastTransitionTime: '2024-05-19T23:35:28Z'
56+
message: the initial names have been accepted
57+
reason: InitialNamesAccepted
58+
status: 'True'
59+
type: Established
6060
storedVersions:
6161
- v1alpha1

0 commit comments

Comments
 (0)