feat: Add health checks for route.openshift.io (#7112)

* feat: Add health checks for route.openshift.io

Signed-off-by: ishitasequeira <isequeir@redhat.com>

* Addressed PR comments

Signed-off-by: ishitasequeira <isequeir@redhat.com>
This commit is contained in:
Ishita Sequeira 2021-09-03 11:27:16 -04:00 committed by GitHub
parent c0f2bf55a7
commit b559bf88d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 179 additions and 0 deletions

View file

@ -0,0 +1,37 @@
health_status = {}
if obj.status ~= nil then
if obj.status.ingress ~= nil then
numIngressRules = 0
for _, ingressRules in pairs(obj.status.ingress) do
numIngressRules = numIngressRules + 1
numTrue = 0
numFalse = 0
if obj.status.ingress ~= nil then
for _, condition in pairs(ingressRules.conditions) do
if condition.type == "Admitted" and condition.status == "True" then
numTrue = numTrue + 1
elseif condition.type == "Admitted" and condition.status == "False" then
numFalse = numFalse + 1
end
end
end
health_status.status = 'Test'
end
if numTrue == numIngressRules then
health_status.status = "Healthy"
health_status.message = "Route is healthy"
return health_status
elseif numFalse > 0 then
health_status.status = "Degraded"
health_status.message = "Route is degraded"
return health_status
else
health_status.status = "Progressing"
health_status.message = "Route is still getting admitted"
return health_status
end
end
end
health_status.status = "Progressing"
health_status.message = "Route is still getting admitted"
return health_status

View file

@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Progressing
message: 'Route is still getting admitted'
inputPath: testdata/progressing.yaml
- healthStatus:
status: Degraded
message: 'Route is degraded'
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
message: 'Route is healthy'
inputPath: testdata/healthy.yaml

View file

@ -0,0 +1,43 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
annotations:
openshift.io/host.generated: 'true'
resourceVersion: '187177'
name: openshift-gitops-server
namespace: openshift-gitops
ownerReferences:
- apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
name: openshift-gitops
uid: 09443427-36c8-4680-9a4b-602ae8a45b89
controller: true
blockOwnerDeletion: true
labels:
app.kubernetes.io/managed-by: openshift-gitops
app.kubernetes.io/name: openshift-gitops-server
app.kubernetes.io/part-of: argocd
spec:
host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
to:
kind: Service
name: openshift-gitops-server
weight: 100
port:
targetPort: https
tls:
termination: passthrough
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
status:
ingress:
- host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
routerName: default
conditions:
- type: Admitted
status: 'False'
lastTransitionTime: '2021-08-30T12:13:34Z'
wildcardPolicy: None
routerCanonicalHostname: router-default.apps.dev-svc-4.8-083007.devcluster.openshift.com

View file

@ -0,0 +1,43 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
annotations:
openshift.io/host.generated: 'true'
resourceVersion: '187177'
name: openshift-gitops-server
namespace: openshift-gitops
ownerReferences:
- apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
name: openshift-gitops
uid: 09443427-36c8-4680-9a4b-602ae8a45b89
controller: true
blockOwnerDeletion: true
labels:
app.kubernetes.io/managed-by: openshift-gitops
app.kubernetes.io/name: openshift-gitops-server
app.kubernetes.io/part-of: argocd
spec:
host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
to:
kind: Service
name: openshift-gitops-server
weight: 100
port:
targetPort: https
tls:
termination: passthrough
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
status:
ingress:
- host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
routerName: default
conditions:
- type: Admitted
status: 'True'
lastTransitionTime: '2021-08-30T12:13:34Z'
wildcardPolicy: None
routerCanonicalHostname: router-default.apps.dev-svc-4.8-083007.devcluster.openshift.com

View file

@ -0,0 +1,43 @@
kind: Route
apiVersion: route.openshift.io/v1
metadata:
annotations:
openshift.io/host.generated: 'true'
resourceVersion: '187177'
name: openshift-gitops-server
namespace: openshift-gitops
ownerReferences:
- apiVersion: argoproj.io/v1alpha1
kind: ArgoCD
name: openshift-gitops
uid: 09443427-36c8-4680-9a4b-602ae8a45b89
controller: true
blockOwnerDeletion: true
labels:
app.kubernetes.io/managed-by: openshift-gitops
app.kubernetes.io/name: openshift-gitops-server
app.kubernetes.io/part-of: argocd
spec:
host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
to:
kind: Service
name: openshift-gitops-server
weight: 100
port:
targetPort: https
tls:
termination: passthrough
insecureEdgeTerminationPolicy: Redirect
wildcardPolicy: None
status:
ingress:
- host: >-
openshift-gitops-server-openshift-gitops.apps.dev-svc-4.8-083007.devcluster.openshift.com
routerName: default
conditions:
- type: Admitted
status: 'Unknown'
lastTransitionTime: '2021-08-30T12:13:34Z'
wildcardPolicy: None
routerCanonicalHostname: router-default.apps.dev-svc-4.8-083007.devcluster.openshift.com