Skip to content

Commit 4e63bc7

Browse files
solomon-kibretSolomon Kibret
andauthored
feat: Adding ExtensionService health-check (#23576)
Signed-off-by: Solomon Kibret <[email protected]> Co-authored-by: Solomon Kibret <[email protected]>
1 parent 1941597 commit 4e63bc7

File tree

6 files changed

+141
-0
lines changed

6 files changed

+141
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
-- Status reporting information detailed here
2+
-- ExtensionService status conditions api information here: https://projectcontour.io/docs/v1.18.0/config/api/#projectcontour.io/v1alpha1.ExtensionServiceStatus
3+
4+
hs = {
5+
status = "Progressing",
6+
message = "Waiting for status",
7+
}
8+
9+
if obj.status then
10+
if obj.status.conditions then
11+
for _, cond in ipairs(obj.status.conditions) do
12+
if obj.metadata.generation == cond.observedGeneration then -- This must match so that we don't report a resource as healthy even though its status is stale
13+
if cond.type == "Valid" and cond.status == "True" then -- Contour will update a single condition, Valid, that is in normal-true polarity.
14+
hs.status = "Healthy"
15+
hs.message = cond.message
16+
return hs
17+
elseif cond.type == "Valid" and cond.status == "False" then
18+
hs.status = "Degraded"
19+
hs.message = cond.message
20+
return hs
21+
end
22+
end
23+
end
24+
end
25+
end
26+
27+
return hs
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests:
2+
- healthStatus:
3+
status: Healthy
4+
message: "Valid ExtensionService"
5+
inputPath: testdata/healthy.yaml
6+
- healthStatus:
7+
status: Progressing
8+
message: 'Waiting for status'
9+
inputPath: testdata/progressing.yaml
10+
- healthStatus:
11+
status: Degraded
12+
message: 'At least one error present, see Errors for details'
13+
inputPath: testdata/degraded.yaml
14+
- healthStatus:
15+
status: Progressing
16+
message: 'Waiting for status'
17+
inputPath: testdata/generation.yaml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: projectcontour.io/v1alpha1
2+
kind: ExtensionService
3+
metadata:
4+
generation: 1
5+
name: example
6+
spec:
7+
circuitBreakerPolicy:
8+
maxConnections: 102400
9+
maxPendingRequests: 1024000
10+
maxRequests: 102400
11+
maxRetries: 102400
12+
protocol: h2c
13+
services:
14+
- name: doesnt-exist
15+
port: 9091
16+
timeoutPolicy:
17+
response: 1s
18+
status:
19+
conditions:
20+
- errors:
21+
- message: 'Spec.Routes unresolved service reference: service "doesnt-exist" not found'
22+
reason: ServiceUnresolvedReference
23+
status: "True"
24+
type: ServiceError
25+
lastTransitionTime: '2024-08-08T16:53:29Z'
26+
message: At least one error present, see Errors for details
27+
observedGeneration: 1
28+
reason: ErrorPresent
29+
status: 'False'
30+
type: Valid
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: projectcontour.io/v1alpha1
2+
kind: ExtensionService
3+
metadata:
4+
generation: 2
5+
name: example
6+
spec:
7+
circuitBreakerPolicy:
8+
maxConnections: 102400
9+
maxPendingRequests: 1024000
10+
maxRequests: 102400
11+
maxRetries: 102400
12+
protocol: h2c
13+
services:
14+
- name: grpc-server
15+
port: 9091
16+
timeoutPolicy:
17+
response: 1s
18+
status:
19+
conditions:
20+
- lastTransitionTime: '2024-08-08T16:53:29Z'
21+
message: Valid ExtensionService
22+
observedGeneration: 1
23+
reason: Valid
24+
status: 'True'
25+
type: Valid
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
apiVersion: projectcontour.io/v1alpha1
2+
kind: ExtensionService
3+
metadata:
4+
generation: 1
5+
name: example
6+
spec:
7+
circuitBreakerPolicy:
8+
maxConnections: 102400
9+
maxPendingRequests: 1024000
10+
maxRequests: 102400
11+
maxRetries: 102400
12+
protocol: h2c
13+
services:
14+
- name: grpc-server
15+
port: 9091
16+
timeoutPolicy:
17+
response: 1s
18+
status:
19+
conditions:
20+
- lastTransitionTime: '2024-08-08T16:53:29Z'
21+
message: Valid ExtensionService
22+
observedGeneration: 1
23+
reason: Valid
24+
status: 'True'
25+
type: Valid
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: projectcontour.io/v1alpha1
2+
kind: ExtensionService
3+
metadata:
4+
generation: 1
5+
name: example
6+
spec:
7+
circuitBreakerPolicy:
8+
maxConnections: 102400
9+
maxPendingRequests: 1024000
10+
maxRequests: 102400
11+
maxRetries: 102400
12+
protocol: h2c
13+
services:
14+
- name: grpc-server
15+
port: 9091
16+
timeoutPolicy:
17+
response: 1s

0 commit comments

Comments
 (0)