feat: Add health checks for Crossplane providers (#4778)

Signed-off-by: Simon Rüegg <simon@rueggs.ch>
This commit is contained in:
Simon Rüegg
2020-11-10 22:57:21 +01:00
committed by GitHub
parent 5040d6f080
commit 0681c2754a
6 changed files with 125 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
hs = {}
if obj.status ~= nil then
if obj.status.conditions ~= nil then
installed = false
healthy = false
for i, condition in ipairs(obj.status.conditions) do
if condition.type == "Installed" then
installed = condition.status == "True"
installed_message = condition.reason
elseif condition.type == "Healthy" then
healthy = condition.status == "True"
healthy_message = condition.reason
end
end
if installed and healthy then
hs.status = "Healthy"
else
hs.status = "Degraded"
end
hs.message = installed_message .. " " .. healthy_message
return hs
end
end
hs.status = "Progressing"
hs.message = "Waiting for provider to be installed"
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Progressing
message: Waiting for provider to be installed
inputPath: testdata/progressing_noStatus.yaml
- healthStatus:
status: Degraded
message: ActivePackageRevision UnhealthyPackageRevision
inputPath: testdata/degraded_installed.yaml
- healthStatus:
status: Degraded
message: UnpackingPackage HealthyPackageRevision
inputPath: testdata/degraded_healthy.yaml
- healthStatus:
status: Healthy
message: ActivePackageRevision HealthyPackageRevision
inputPath: testdata/healthy.yaml

View File

@@ -0,0 +1,23 @@
apiVersion: pkg.crossplane.io/v1alpha1
kind: Provider
metadata:
creationTimestamp: "2020-10-28T15:25:56Z"
generation: 2
name: provider-helm
resourceVersion: "1664592"
selfLink: /apis/pkg.crossplane.io/v1alpha1/providers/provider-helm
uid: 6ce16954-64f1-48c5-8a80-e29af37fc736
spec:
package: crossplane/provider-helm:v0.3.5error
revisionActivationPolicy: Automatic
status:
conditions:
- lastTransitionTime: "2020-11-06T12:37:16Z"
reason: UnpackingPackage
status: "False"
type: Installed
- lastTransitionTime: "2020-11-06T10:19:07Z"
reason: HealthyPackageRevision
status: "True"
type: Healthy
currentRevision: provider-helm-7f275162c62e

View File

@@ -0,0 +1,23 @@
apiVersion: pkg.crossplane.io/v1alpha1
kind: Provider
metadata:
creationTimestamp: "2020-10-28T15:25:56Z"
generation: 4
name: provider-helm
resourceVersion: "1666009"
selfLink: /apis/pkg.crossplane.io/v1alpha1/providers/provider-helm
uid: 6ce16954-64f1-48c5-8a80-e29af37fc736
spec:
package: crossplane/provider-helm:v0.3.6
revisionActivationPolicy: Automatic
status:
conditions:
- lastTransitionTime: "2020-11-06T12:44:22Z"
reason: ActivePackageRevision
status: "True"
type: Installed
- lastTransitionTime: "2020-11-06T12:44:21Z"
reason: UnhealthyPackageRevision
status: "False"
type: Healthy
currentRevision: provider-helm-61a254740524

View File

@@ -0,0 +1,23 @@
apiVersion: pkg.crossplane.io/v1alpha1
kind: Provider
metadata:
creationTimestamp: "2020-10-28T15:25:56Z"
generation: 4
name: provider-helm
resourceVersion: "1666154"
selfLink: /apis/pkg.crossplane.io/v1alpha1/providers/provider-helm
uid: 6ce16954-64f1-48c5-8a80-e29af37fc736
spec:
package: crossplane/provider-helm:v0.3.6
revisionActivationPolicy: Automatic
status:
conditions:
- lastTransitionTime: "2020-11-06T12:44:28Z"
reason: ActivePackageRevision
status: "True"
type: Installed
- lastTransitionTime: "2020-11-06T12:44:26Z"
reason: HealthyPackageRevision
status: "True"
type: Healthy
currentRevision: provider-helm-61a254740524

View File

@@ -0,0 +1,12 @@
apiVersion: pkg.crossplane.io/v1alpha1
kind: Provider
metadata:
creationTimestamp: "2020-10-28T15:25:56Z"
generation: 4
name: provider-helm
resourceVersion: "1666154"
selfLink: /apis/pkg.crossplane.io/v1alpha1/providers/provider-helm
uid: 6ce16954-64f1-48c5-8a80-e29af37fc736
spec:
package: crossplane/provider-helm:v0.3.6
revisionActivationPolicy: Automatic