mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Add health status for OpenFaaS functions (#18015)
Adds test-case for Progressing, Degraded, Healthy and Suspended, to avoid users having to update their Argo ConfigMaps by hand. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
31
resource_customizations/openfaas.com/Function/health.lua
Normal file
31
resource_customizations/openfaas.com/Function/health.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
hs = {}
|
||||
if obj.status ~= nil then
|
||||
if obj.status.conditions ~= nil then
|
||||
for i, condition in ipairs(obj.status.conditions) do
|
||||
if condition.type == "Ready" and condition.status == "False" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = condition.message
|
||||
return hs
|
||||
end
|
||||
if condition.type == "Stalled" and condition.status == "True" then
|
||||
hs.status = "Degraded"
|
||||
hs.message = condition.message
|
||||
return hs
|
||||
end
|
||||
if condition.type == "Ready" and condition.status == "True" then
|
||||
if obj.status.replicas ~= nil and obj.status.replicas > 0 then
|
||||
hs.status = "Healthy"
|
||||
hs.message = condition.message
|
||||
else
|
||||
hs.status = "Suspended"
|
||||
hs.message = "No replicas available"
|
||||
end
|
||||
return hs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for Function"
|
||||
return hs
|
||||
@@ -0,0 +1,17 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: "Waiting for Function"
|
||||
inputPath: testdata/progressing.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "Secret missing: secrets \"missing-secret\" not found"
|
||||
inputPath: testdata/degraded_no_secret.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: "Deployment and service reconciled"
|
||||
inputPath: testdata/healthy.yaml
|
||||
- healthStatus:
|
||||
status: Suspended
|
||||
message: "No replicas available"
|
||||
inputPath: testdata/suspended_zero_replicas.yaml
|
||||
48
resource_customizations/openfaas.com/Function/testdata/degraded_no_secret.yaml
vendored
Normal file
48
resource_customizations/openfaas.com/Function/testdata/degraded_no_secret.yaml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"apiVersion": "openfaas.com/v1",
|
||||
"kind": "Function",
|
||||
"metadata": {
|
||||
"annotations": {
|
||||
"kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"openfaas.com/v1\",\"kind\":\"Function\",\"metadata\":{\"annotations\":{},\"name\":\"env\",\"namespace\":\"openfaas-fn\"},\"spec\":{\"annotations\":{},\"environment\":{\"fprocess\":\"env\",\"test\":\"yes\"},\"image\":\"ghcr.io/openfaas/alpine:latest\",\"labels\":{},\"name\":\"env\",\"secrets\":[\"missing-secret\"]}}\n"
|
||||
},
|
||||
"creationTimestamp": "2024-04-29T13:42:46Z",
|
||||
"generation": 1,
|
||||
"name": "env",
|
||||
"namespace": "openfaas-fn",
|
||||
"resourceVersion": "580675",
|
||||
"uid": "7a00bc7b-eb01-4f6a-b5f7-7893422ace7d"
|
||||
},
|
||||
"spec": {
|
||||
"annotations": {},
|
||||
"environment": {
|
||||
"fprocess": "env",
|
||||
"test": "yes"
|
||||
},
|
||||
"image": "ghcr.io/openfaas/alpine:latest",
|
||||
"labels": {},
|
||||
"name": "env",
|
||||
"secrets": [
|
||||
"missing-secret"
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"conditions": [
|
||||
{
|
||||
"lastTransitionTime": "2024-04-29T13:42:46Z",
|
||||
"message": "Function queued for creation",
|
||||
"observedGeneration": 1,
|
||||
"reason": "Reconciling",
|
||||
"status": "True",
|
||||
"type": "Reconciling"
|
||||
},
|
||||
{
|
||||
"lastTransitionTime": "2024-04-29T13:42:46Z",
|
||||
"message": "Secret missing: secrets \"missing-secret\" not found",
|
||||
"observedGeneration": 1,
|
||||
"reason": "SecretMissing",
|
||||
"status": "True",
|
||||
"type": "Stalled"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
36
resource_customizations/openfaas.com/Function/testdata/healthy.yaml
vendored
Normal file
36
resource_customizations/openfaas.com/Function/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
apiVersion: openfaas.com/v1
|
||||
kind: Function
|
||||
metadata:
|
||||
annotations:
|
||||
kubectl.kubernetes.io/last-applied-configuration: |
|
||||
{"apiVersion":"openfaas.com/v1","kind":"Function","metadata":{"annotations":{},"name":"env","namespace":"openfaas-fn"},"spec":{"annotations":{},"environment":{"fprocess":"env","test":"yes"},"image":"ghcr.io/openfaas/alpine:latest","labels":{},"name":"env"}}
|
||||
creationTimestamp: "2024-04-29T13:38:50Z"
|
||||
generation: 1
|
||||
name: env
|
||||
namespace: openfaas-fn
|
||||
resourceVersion: "580323"
|
||||
uid: 865f74b9-cbc5-455a-abd7-4a1cdeae22d1
|
||||
spec:
|
||||
annotations: {}
|
||||
environment:
|
||||
fprocess: env
|
||||
test: "yes"
|
||||
image: ghcr.io/openfaas/alpine:latest
|
||||
labels: {}
|
||||
name: env
|
||||
status:
|
||||
availableReplicas: 1
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-04-29T13:38:50Z"
|
||||
message: Deployment and service reconciled
|
||||
observedGeneration: 1
|
||||
reason: Ready
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-04-29T13:38:53Z"
|
||||
message: At least one replica available
|
||||
observedGeneration: 1
|
||||
reason: ReplicaAvailable
|
||||
status: "True"
|
||||
type: Healthy
|
||||
replicas: 1
|
||||
30
resource_customizations/openfaas.com/Function/testdata/progressing.yaml
vendored
Normal file
30
resource_customizations/openfaas.com/Function/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
apiVersion: openfaas.com/v1
|
||||
kind: Function
|
||||
metadata:
|
||||
annotations:
|
||||
kubectl.kubernetes.io/last-applied-configuration: |
|
||||
{"apiVersion":"openfaas.com/v1","kind":"Function","metadata":{"annotations":{},"name":"env","namespace":"openfaas-fn"},"spec":{"annotations":{},"environment":{"fprocess":"env","test":"yes"},"image":"ghcr.io/openfaas/alpine:latest","labels":{},"name":"env"}}
|
||||
creationTimestamp: "2024-04-29T13:38:50Z"
|
||||
generation: 1
|
||||
name: env
|
||||
namespace: openfaas-fn
|
||||
resourceVersion: "580277"
|
||||
uid: 865f74b9-cbc5-455a-abd7-4a1cdeae22d1
|
||||
spec:
|
||||
annotations: {}
|
||||
environment:
|
||||
fprocess: env
|
||||
test: "yes"
|
||||
image: ghcr.io/openfaas/alpine:latest
|
||||
labels: {}
|
||||
name: env
|
||||
status:
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-04-29T13:38:50Z"
|
||||
message: Function queued for creation
|
||||
observedGeneration: 1
|
||||
reason: Reconciling
|
||||
status: "True"
|
||||
type: Reconciling
|
||||
---
|
||||
35
resource_customizations/openfaas.com/Function/testdata/suspended_zero_replicas.yaml
vendored
Normal file
35
resource_customizations/openfaas.com/Function/testdata/suspended_zero_replicas.yaml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
apiVersion: openfaas.com/v1
|
||||
kind: Function
|
||||
metadata:
|
||||
annotations:
|
||||
kubectl.kubernetes.io/last-applied-configuration: |
|
||||
{"apiVersion":"openfaas.com/v1","kind":"Function","metadata":{"annotations":{},"name":"env","namespace":"openfaas-fn"},"spec":{"annotations":{},"environment":{"fprocess":"env","test":"yes"},"image":"ghcr.io/openfaas/alpine:latest","labels":{},"name":"env"}}
|
||||
creationTimestamp: "2024-04-29T13:38:50Z"
|
||||
generation: 1
|
||||
name: env
|
||||
namespace: openfaas-fn
|
||||
resourceVersion: "580543"
|
||||
uid: 865f74b9-cbc5-455a-abd7-4a1cdeae22d1
|
||||
spec:
|
||||
annotations: {}
|
||||
environment:
|
||||
fprocess: env
|
||||
test: "yes"
|
||||
image: ghcr.io/openfaas/alpine:latest
|
||||
labels: {}
|
||||
name: env
|
||||
status:
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-04-29T13:38:50Z"
|
||||
message: Deployment and service reconciled
|
||||
observedGeneration: 1
|
||||
reason: Ready
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-04-29T13:41:27Z"
|
||||
message: At least one replica available
|
||||
observedGeneration: 1
|
||||
reason: ReplicaAvailable
|
||||
status: "False"
|
||||
type: Healthy
|
||||
Reference in New Issue
Block a user