feat: Adding ExtensionService health-check (#23576)

Signed-off-by: Solomon Kibret <solomon.kibret@gmail.com>
Co-authored-by: Solomon Kibret <solomon.kibret@gmail.com>
This commit is contained in:
solomon-kibret
2025-07-24 06:39:22 -04:00
committed by GitHub
parent 19415979e8
commit 4e63bc7563
6 changed files with 141 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
-- Status reporting information detailed here
-- ExtensionService status conditions api information here: https://projectcontour.io/docs/v1.18.0/config/api/#projectcontour.io/v1alpha1.ExtensionServiceStatus
hs = {
status = "Progressing",
message = "Waiting for status",
}
if obj.status then
if obj.status.conditions then
for _, cond in ipairs(obj.status.conditions) do
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
if cond.type == "Valid" and cond.status == "True" then -- Contour will update a single condition, Valid, that is in normal-true polarity.
hs.status = "Healthy"
hs.message = cond.message
return hs
elseif cond.type == "Valid" and cond.status == "False" then
hs.status = "Degraded"
hs.message = cond.message
return hs
end
end
end
end
end
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "Valid ExtensionService"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Progressing
message: 'Waiting for status'
inputPath: testdata/progressing.yaml
- healthStatus:
status: Degraded
message: 'At least one error present, see Errors for details'
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: 'Waiting for status'
inputPath: testdata/generation.yaml

View File

@@ -0,0 +1,30 @@
apiVersion: projectcontour.io/v1alpha1
kind: ExtensionService
metadata:
generation: 1
name: example
spec:
circuitBreakerPolicy:
maxConnections: 102400
maxPendingRequests: 1024000
maxRequests: 102400
maxRetries: 102400
protocol: h2c
services:
- name: doesnt-exist
port: 9091
timeoutPolicy:
response: 1s
status:
conditions:
- errors:
- message: 'Spec.Routes unresolved service reference: service "doesnt-exist" not found'
reason: ServiceUnresolvedReference
status: "True"
type: ServiceError
lastTransitionTime: '2024-08-08T16:53:29Z'
message: At least one error present, see Errors for details
observedGeneration: 1
reason: ErrorPresent
status: 'False'
type: Valid

View File

@@ -0,0 +1,25 @@
apiVersion: projectcontour.io/v1alpha1
kind: ExtensionService
metadata:
generation: 2
name: example
spec:
circuitBreakerPolicy:
maxConnections: 102400
maxPendingRequests: 1024000
maxRequests: 102400
maxRetries: 102400
protocol: h2c
services:
- name: grpc-server
port: 9091
timeoutPolicy:
response: 1s
status:
conditions:
- lastTransitionTime: '2024-08-08T16:53:29Z'
message: Valid ExtensionService
observedGeneration: 1
reason: Valid
status: 'True'
type: Valid

View File

@@ -0,0 +1,25 @@
apiVersion: projectcontour.io/v1alpha1
kind: ExtensionService
metadata:
generation: 1
name: example
spec:
circuitBreakerPolicy:
maxConnections: 102400
maxPendingRequests: 1024000
maxRequests: 102400
maxRetries: 102400
protocol: h2c
services:
- name: grpc-server
port: 9091
timeoutPolicy:
response: 1s
status:
conditions:
- lastTransitionTime: '2024-08-08T16:53:29Z'
message: Valid ExtensionService
observedGeneration: 1
reason: Valid
status: 'True'
type: Valid

View File

@@ -0,0 +1,17 @@
apiVersion: projectcontour.io/v1alpha1
kind: ExtensionService
metadata:
generation: 1
name: example
spec:
circuitBreakerPolicy:
maxConnections: 102400
maxPendingRequests: 1024000
maxRequests: 102400
maxRetries: 102400
protocol: h2c
services:
- name: grpc-server
port: 9091
timeoutPolicy:
response: 1s