feat(server): 3scale health checks (#24327) (#24326)

Signed-off-by: Adriano Machado <60320+ammachado@users.noreply.github.com>
This commit is contained in:
Adriano Machado
2025-09-06 14:24:18 -04:00
committed by GitHub
parent 66f7b4caa1
commit d954789d47
76 changed files with 970 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
local hs = {}
if obj ~= nil and obj.status ~= nil then
local deployments = obj.status.deployments
if deployments ~= nil then
local has_ready = deployments.ready ~= nil
local has_starting = deployments.starting ~= nil
local has_stopped = deployments.stopped ~= nil
if has_ready and (not has_starting) and (not has_stopped) then
hs.status = "Healthy"
hs.message = "3scale APIManager is available"
return hs
elseif (has_ready and (has_starting or has_stopped)) or (not has_ready) then
hs.status = "Progressing"
hs.message = "Waiting for 3scale APIManager status..."
end
end
-- Fallback to condition-based evaluation
if obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Available" then
if condition.status == "True" then
hs.status = "Healthy"
hs.message = "3scale APIManager is available"
return hs
elseif condition.reason ~= nil and condition.reason ~= "" then
local msg = "3scale APIManager is degraded: " .. condition.reason
hs.status = "Degraded"
hs.message = msg
return hs
end
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale APIManager status..."
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Degraded
message: "3scale APIManager is degraded: MissingWatchedSecrets"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Healthy
message: "3scale APIManager is available"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale APIManager status..."
inputPath: testdata/progressing-1.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale APIManager status..."
inputPath: testdata/progressing-2.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale APIManager status..."
inputPath: testdata/progressing-3.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
status:
conditions:
- type: Available
status: "False"
reason: "MissingWatchedSecrets"

View File

@@ -0,0 +1,8 @@
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
status:
conditions:
- status: "True"
type: Available
deployments:
ready: []

View File

@@ -0,0 +1,14 @@
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
status:
conditions:
- status: "False"
type: Available
deployments:
ready:
- a
starting:
- b
- c
stopped:
- e

View File

@@ -0,0 +1,11 @@
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
status:
conditions:
- status: "False"
type: Available
deployments:
starting:
- a
stopped:
- b

View File

@@ -0,0 +1,12 @@
apiVersion: apps.3scale.net/v1alpha1
kind: APIManager
status:
conditions:
- status: "False"
type: Available
deployments:
ready:
- a
starting:
- b
- c

View File

@@ -0,0 +1,27 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = "3scale ActiveDoc is ready"
return hs
elseif condition.type == "Invalid" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale ActiveDoc configuration is invalid"
return hs
elseif condition.type == "Orphan" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale ActiveDoc references non-existing resources"
return hs
elseif condition.type == "Failed" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale ActiveDoc synchronization failed"
return hs
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale ActiveDoc status..."
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "3scale ActiveDoc is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failure message"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "Validation failure"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Degraded
message: "Referenced product does not exist"
inputPath: testdata/degraded-orphan.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale ActiveDoc status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Failed
status: "True"
message: Failure message

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Invalid
status: "True"
message: Validation failure

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Invalid
status: "True"
message: Referenced product does not exist

View File

@@ -0,0 +1,6 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions: [ ]

View File

@@ -0,0 +1,32 @@
local hs = {}
if obj.status ~= nil then
if obj.status.state ~= nil and obj.status.state == "suspended" then
hs.status = "Suspended"
hs.message = "3scale Application is suspended"
return hs
end
local application_id = obj.status.adminId
local has_application_id = (application_id ~= nil and type(application_id) == "number" and application_id > 0)
if obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" then
if condition.status == "True" then
hs.status = "Healthy"
hs.message = "3scale Application is ready"
return hs
elseif not has_application_id then
hs.status = "Degraded"
hs.message = condition.message or "3scale Application is not ready"
return hs
end
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale Application status..."
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "3scale Application is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failed to synchronize application with 3scale API"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Suspended
message: "3scale Application is suspended"
inputPath: testdata/suspended.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale Application status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,8 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Application
status:
applicationID: null
conditions:
- type: Ready
status: "False"
message: Failed to synchronize application with 3scale API

View File

@@ -0,0 +1,8 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Application
status:
applicationID: 123456
conditions:
- type: Ready
status: "True"
message: Application has been successfully synchronized

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Application
status:
conditions: [ ]

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Application
status:
state: suspended

View File

@@ -0,0 +1,23 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Ready" then
hs.status = "Healthy"
hs.message = "3scale ApplicationAuth is ready"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale ApplicationAuth failed"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale ApplicationAuth status..."
return hs

View File

@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Healthy
message: "3scale ApplicationAuth is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failed to generate authentication secret"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale ApplicationAuth status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ApplicationAuth
status:
conditions:
- type: Failed
status: "True"
message: Failed to generate authentication secret

View File

@@ -0,0 +1,6 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ApplicationAuth
status:
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ApplicationAuth
status:
conditions: [ ]

View File

@@ -0,0 +1,27 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Synced" then
hs.status = "Healthy"
hs.message = "3scale Backend is synced"
return hs
elseif condition.type == "Invalid" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Backend configuration is invalid"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Backend synchronization failed"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale Backend status..."
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "3scale Backend is synced"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "3scale Backend synchronization failed"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "3scale Backend configuration is invalid"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale Backend status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,10 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
status:
conditions:
- status: "True"
type: Failed
- status: "False"
type: Invalid
- status: "False"
type: Synced

View File

@@ -0,0 +1,11 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
status:
backendId: 59978
conditions:
- status: "False"
type: Failed
- status: "True"
type: Invalid
- status: "False"
type: Synced

View File

@@ -0,0 +1,11 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
status:
conditions:
- status: "False"
type: Failed
- status: "False"
type: Invalid
- status: "False"
type: Synced
reason: SynchronizationFailed

View File

@@ -0,0 +1,11 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
status:
backendId: 59978
conditions:
- status: "False"
type: Failed
- status: "False"
type: Invalid
- status: "True"
type: Synced

View File

@@ -0,0 +1,11 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Backend
status:
backendId: 59978
conditions:
- status: "False"
type: Failed
- status: "False"
type: Invalid
- status: "False"
type: Synced

View File

@@ -0,0 +1,23 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "True" then
hs.status = "Healthy"
hs.message = "3scale CustomPolicyDefinition is ready"
return hs
elseif condition.type == "Invalid" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale CustomPolicyDefinition configuration is invalid"
return hs
elseif condition.type == "Failed" and condition.status == "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale CustomPolicyDefinition synchronization failed"
return hs
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale CustomPolicyDefinition status..."
return hs

View File

@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Healthy
message: "3scale CustomPolicyDefinition is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Policy schema is invalid"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale CustomPolicyDefinition status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: CustomPolicyDefinition
status:
conditions:
- type: Invalid
status: "True"
message: Policy schema is invalid

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: CustomPolicyDefinition
status:
policyID: 123456
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: CustomPolicyDefinition
status:
conditions: [ ]

View File

@@ -0,0 +1,31 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Ready" then
hs.status = "Healthy"
hs.message = "3scale DeveloperAccount is ready"
return hs
elseif condition.type == "Invalid" then
hs.status = "Degraded"
hs.message = condition.message or "3scale DeveloperAccount configuration is invalid"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale DeveloperAccount synchronization failed"
return hs
elseif condition.type == "Waiting" then
hs.status = "Suspended"
hs.message = condition.message or "3scale DeveloperAccount is waiting for approval"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale DeveloperAccount status..."
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "3scale DeveloperAccount is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Suspended
message: "Developer account is waiting for admin approval"
inputPath: testdata/waiting.yaml
- healthStatus:
status: Degraded
message: "Failure message"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "Validation failure"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale DeveloperAccount status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperAccount
status:
conditions:
- type: Failed
status: "True"
message: Failure message

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperAccount
status:
conditions:
- type: Invalid
status: "True"
message: Validation failure

View File

@@ -0,0 +1,6 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperAccount
status:
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperAccount
status:
conditions: [ ]

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperAccount
status:
conditions:
- type: Waiting
status: "True"
message: Developer account is waiting for admin approval

View File

@@ -0,0 +1,39 @@
local hs = {}
if obj.status ~= nil then
if obj.status.developerUserState ~= nil and obj.status.developerUserState == "suspended" then
hs.status = "Suspended"
hs.message = "3scale Developer user is waiting for admin approval"
return hs
end
if obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Ready" then
hs.status = "Healthy"
hs.message = "3scale DeveloperUser is ready"
return hs
elseif condition.type == "Invalid" then
hs.status = "Degraded"
hs.message = condition.message or "3scale DeveloperUser configuration is invalid"
return hs
elseif condition.type == "Orphan" then
hs.status = "Degraded"
hs.message = condition.message or "3scale DeveloperUser references non-existing resources"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale DeveloperUser synchronization failed"
return hs
end
::continue::
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale DeveloperUser status..."
return hs

View File

@@ -0,0 +1,25 @@
tests:
- healthStatus:
status: Healthy
message: "3scale DeveloperUser is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Suspended
message: "3scale Developer user is waiting for admin approval"
inputPath: testdata/suspended.yaml
- healthStatus:
status: Degraded
message: "Failure message"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "Validation failure"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Degraded
message: "Referenced developer account does not exist"
inputPath: testdata/degraded-orphan.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale DeveloperUser status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Failed
status: "True"
message: Failure message

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ActiveDoc
status:
conditions:
- type: Invalid
status: "True"
message: Validation failure

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperUser
status:
conditions:
- type: Invalid
status: "True"
message: Referenced developer account does not exist

View File

@@ -0,0 +1,6 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperUser
status:
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperUser
status:
conditions: [ ]

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: DeveloperUser
status:
developerUserState: suspended

View File

@@ -0,0 +1,27 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Ready" then
hs.status = "Healthy"
hs.message = "3scale OpenAPI is ready"
return hs
elseif condition.type == "Invalid" then
hs.status = "Degraded"
hs.message = condition.message or "3scale OpenAPI configuration is invalid"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale OpenAPI reconciliation failed"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale OpenAPI status..."
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "3scale OpenAPI is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failure message"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "OpenAPI specification is invalid or malformed"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale OpenAPI status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: OpenAPI
status:
conditions:
- type: Failed
status: "True"
message: Failure message

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: OpenAPI
status:
conditions:
- type: Invalid
status: "True"
message: OpenAPI specification is invalid or malformed

View File

@@ -0,0 +1,6 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: OpenAPI
status:
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: OpenAPI
status:
conditions: [ ]

View File

@@ -0,0 +1,31 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Synced" then
hs.status = "Healthy"
hs.message = "3scale Product is synced"
return hs
elseif condition.type == "Invalid" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Product configuration is invalid"
return hs
elseif condition.type == "Orphan" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Product references non-existing resources"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Product synchronization failed"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale Product status..."
return hs

View File

@@ -0,0 +1,21 @@
tests:
- healthStatus:
status: Healthy
message: "3scale Product is synced"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failure message"
inputPath: testdata/degraded-failed.yaml
- healthStatus:
status: Degraded
message: "Product configuration is invalid - missing required hits metric"
inputPath: testdata/degraded-invalid.yaml
- healthStatus:
status: Degraded
message: "Product spec contains reference(s) to non existing resources"
inputPath: testdata/degraded-orphan.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale Product status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
status:
conditions:
- type: Failed
status: "True"
message: Failure message

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
status:
conditions:
- type: Invalid
status: "True"
message: Product configuration is invalid - missing required hits metric

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
status:
conditions:
- type: Orphan
status: "True"
message: Product spec contains reference(s) to non existing resources

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
status:
productId: 123456
conditions:
- type: Synced
status: "True"

View File

@@ -0,0 +1,20 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: Product
metadata:
name: progressing-product
namespace: example-ns
spec:
name: Progressing Product
systemName: progressing_product
description: Progressing product for testing
metrics:
hits:
friendlyName: Hits
unit: hit
description: Number of API hits
status:
productId: null
state: null
providerAccountHost: example.3scale.net
observedGeneration: 1
conditions: [ ]

View File

@@ -0,0 +1,27 @@
local hs = {}
if obj.status ~= nil and obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.status ~= "True" then goto continue end
if condition.type == "Ready" then
hs.status = "Healthy"
hs.message = "3scale ProxyConfigPromote is ready"
return hs
elseif condition.type == "In-progress" then
hs.status = "Progressing"
hs.message = condition.message or "3scale ProxyConfigPromote is in progress"
return hs
elseif condition.type == "Failed" then
hs.status = "Degraded"
hs.message = condition.message or "3cale ProxyConfigPromote failed"
return hs
end
::continue::
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale ProxyConfigPromote status..."
return hs

View File

@@ -0,0 +1,17 @@
tests:
- healthStatus:
status: Healthy
message: "3scale ProxyConfigPromote is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failed to promote proxy configuration - product not found"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Proxy configuration promotion is in progress"
inputPath: testdata/in-progress.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale ProxyConfigPromote status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
status:
conditions:
- type: Failed
status: "True"
message: Failed to promote proxy configuration - product not found

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
status:
productId: "123456"
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,7 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
status:
conditions:
- type: In-progress
status: "True"
message: Proxy configuration promotion is in progress

View File

@@ -0,0 +1,4 @@
apiVersion: capabilities.3scale.net/v1beta1
kind: ProxyConfigPromote
status:
conditions: [ ]

View File

@@ -0,0 +1,38 @@
local hs = {}
if obj ~= nil and obj.status ~= nil then
local tenant_id = obj.status.tenantId
local admin_id = obj.status.adminId
local has_tenant_id = (tenant_id ~= nil and type(tenant_id) == "number" and tenant_id > 0)
local has_admin_id = (admin_id ~= nil and type(admin_id) == "number" and admin_id > 0)
local is_ready = false
if obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status == "True" then
is_ready = true
break
end
end
end
if is_ready and has_tenant_id and has_admin_id then
hs.status = "Healthy"
hs.message = "3scale Tenant is ready"
return hs
end
if obj.status.conditions ~= nil then
for _, condition in ipairs(obj.status.conditions) do
if condition.type == "Ready" and condition.status ~= "True" then
hs.status = "Degraded"
hs.message = condition.message or "3scale Tenant is degraded"
return hs
end
end
end
end
hs.status = "Progressing"
hs.message = "Waiting for 3scale Tenant status..."
return hs

View File

@@ -0,0 +1,13 @@
tests:
- healthStatus:
status: Healthy
message: "3scale Tenant is ready"
inputPath: testdata/healthy.yaml
- healthStatus:
status: Degraded
message: "Failed to create tenant - invalid credentials"
inputPath: testdata/degraded.yaml
- healthStatus:
status: Progressing
message: "Waiting for 3scale Tenant status..."
inputPath: testdata/progressing.yaml

View File

@@ -0,0 +1,9 @@
apiVersion: capabilities.3scale.net/v1alpha1
kind: Tenant
status:
tenantId: 0
adminId: 0
conditions:
- type: Ready
status: "False"
message: Failed to create tenant - invalid credentials

View File

@@ -0,0 +1,11 @@
apiVersion: capabilities.3scale.net/v1alpha1
kind: Tenant
metadata:
name: example-tenant
namespace: example-ns
status:
tenantId: 123456
adminId: 789
conditions:
- type: Ready
status: "True"

View File

@@ -0,0 +1,9 @@
apiVersion: capabilities.3scale.net/v1alpha1
kind: Tenant
metadata:
name: progressing-tenant
namespace: example-ns
status:
tenantId: 0
adminId: 0
conditions: [ ]