argo-cd/resource_customizations/controlplane.cluster.x-k8s.io/AWSManagedControlPlane/health.lua
itaiatu f110570512
feat: Add custom health check for cluster-api AWSManagedControlPlane (#19304)
* add custom health check for awsmanagedcontrolplane

Signed-off-by: Iulian Taiatu <itaiatu@adobe.com>

* chore(deps): bump github.com/aws/aws-sdk-go from 1.55.3 to 1.55.4 (#19295)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.55.3 to 1.55.4.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Commits](https://github.com/aws/aws-sdk-go/compare/v1.55.3...v1.55.4)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Iulian Taiatu <itaiatu@adobe.com>

* add new line at the end of health_test.yaml file

Signed-off-by: Iulian Taiatu <itaiatu@adobe.com>

---------

Signed-off-by: Iulian Taiatu <itaiatu@adobe.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-02 10:54:00 -07:00

47 lines
1.7 KiB
Lua

local health_status = {
status = "Progressing",
message = "Provisioning..."
}
-- If .status is nil or doesn't have conditions, then the control plane is not ready
if obj.status == nil or obj.status.conditions == nil then
return health_status
end
-- Accumulator for the error messages (could be multiple conditions in error state)
err_msg = ""
-- Iterate over the conditions to determine the health status
for i, condition in ipairs(obj.status.conditions) do
-- Check if the Ready condition is True, then the control plane is ready
if condition.type == "Ready" and condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Control plane is ready"
return health_status
end
-- If we have a condition that is False and has an Error severity, then the control plane is in a degraded state
if condition.status == "False" and condition.severity == "Error" then
health_status.status = "Degraded"
err_msg = err_msg .. condition.message .. " "
end
end
-- If we have any error conditions, then the control plane is in a degraded state
if health_status.status == "Degraded" then
health_status.message = err_msg
return health_status
end
-- If .status.ready is False, then the control plane is not ready
if obj.status.ready == false then
health_status.status = "Progressing"
health_status.message = "Control plane is not ready (.status.ready is false)"
return health_status
end
-- If we reach this point, then the control plane is not ready and we don't have any error conditions
health_status.status = "Progressing"
health_status.message = "Control plane is not ready"
return health_status