mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat: Add health checks for ServiceBinding and ServiceInstance (#25007)
Signed-off-by: Dobromir Zahariev <dzahariev@yahoo.com>
This commit is contained in:
committed by
GitHub
parent
3f3e54f7c3
commit
51c9add05d
@@ -0,0 +1,34 @@
|
||||
hs = {}
|
||||
|
||||
-- Check for deletion timestamp
|
||||
if obj ~= nil and obj.metadata.deletionTimestamp then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Resource is being deleted"
|
||||
return hs
|
||||
end
|
||||
|
||||
-- Check for reconciliation conditions
|
||||
if obj ~= nil and obj.status ~= nil then
|
||||
if type(obj.status.conditions) == "table" then
|
||||
for i, condition in ipairs(obj.status.conditions) do
|
||||
if condition.observedGeneration and obj.metadata.generation and condition.observedGeneration ~= obj.metadata.generation then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for spec update to be observed"
|
||||
return hs
|
||||
end
|
||||
if condition ~= nil and
|
||||
((condition.type == "Succeeded" and condition.status == "False") or
|
||||
(condition.type == "Failed" and condition.status == "True")) then
|
||||
hs.status = "Degraded"
|
||||
hs.message = condition.message or ""
|
||||
return hs
|
||||
end
|
||||
end
|
||||
hs.status = "Healthy"
|
||||
hs.message = "Ready to use"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for status"
|
||||
return hs
|
||||
@@ -0,0 +1,21 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Waiting for status'
|
||||
inputPath: testdata/progressing.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Waiting for spec update to be observed'
|
||||
inputPath: testdata/observed-generation-outdated.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Resource is being deleted'
|
||||
inputPath: testdata/deleting.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'ServiceBinding create failed'
|
||||
inputPath: testdata/degraded.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: 'Ready to use'
|
||||
inputPath: testdata/healthy.yaml
|
||||
47
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/degraded.yaml
vendored
Normal file
47
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/degraded.yaml
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceBinding
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-binding
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
credentialsRotationPolicy:
|
||||
enabled: true
|
||||
rotatedBindingTTL: 20h
|
||||
rotationFrequency: 20h
|
||||
externalName: new-binding
|
||||
secretName: new-binding
|
||||
secretTemplate: |
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
reloader: enabled
|
||||
serviceInstanceName: instance-name
|
||||
serviceInstanceNamespace: sap
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding create failed
|
||||
observedGeneration: 1
|
||||
reason: CreateFailed
|
||||
status: 'False'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:40:38Z'
|
||||
message: ServiceBinding create failed
|
||||
observedGeneration: 1
|
||||
reason: CreateFailed
|
||||
status: 'True'
|
||||
type: Failed
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'False'
|
||||
49
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/deleting.yaml
vendored
Normal file
49
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/deleting.yaml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceBinding
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-binding
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
deletionTimestamp: "2025-10-10T10:00:00Z"
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
credentialsRotationPolicy:
|
||||
enabled: true
|
||||
rotatedBindingTTL: 20h
|
||||
rotationFrequency: 20h
|
||||
externalName: new-binding
|
||||
secretName: new-binding
|
||||
secretTemplate: |
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
reloader: enabled
|
||||
serviceInstanceName: instance-name
|
||||
serviceInstanceNamespace: sap
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Created
|
||||
status: 'True'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Provisioned
|
||||
status: 'True'
|
||||
type: Ready
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
subaccountID: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
48
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/healthy.yaml
vendored
Normal file
48
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceBinding
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-binding
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
credentialsRotationPolicy:
|
||||
enabled: true
|
||||
rotatedBindingTTL: 20h
|
||||
rotationFrequency: 20h
|
||||
externalName: new-binding
|
||||
secretName: new-binding
|
||||
secretTemplate: |
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
reloader: enabled
|
||||
serviceInstanceName: instance-name
|
||||
serviceInstanceNamespace: sap
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Created
|
||||
status: 'True'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Provisioned
|
||||
status: 'True'
|
||||
type: Ready
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
subaccountID: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
@@ -0,0 +1,48 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceBinding
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 2
|
||||
name: new-binding
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
credentialsRotationPolicy:
|
||||
enabled: true
|
||||
rotatedBindingTTL: 20h
|
||||
rotationFrequency: 20h
|
||||
externalName: new-binding
|
||||
secretName: new-binding
|
||||
secretTemplate: |
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
reloader: enabled
|
||||
serviceInstanceName: instance-name
|
||||
serviceInstanceNamespace: sap
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Created
|
||||
status: 'True'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceBinding provisioned successfully
|
||||
observedGeneration: 1
|
||||
reason: Provisioned
|
||||
status: 'True'
|
||||
type: Ready
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
subaccountID: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
30
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/progressing.yaml
vendored
Normal file
30
resource_customizations/services.cloud.sap.com/ServiceBinding/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceBinding
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-binding
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
credentialsRotationPolicy:
|
||||
enabled: true
|
||||
rotatedBindingTTL: 20h
|
||||
rotationFrequency: 20h
|
||||
externalName: new-binding
|
||||
secretName: new-binding
|
||||
secretTemplate: |
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
labels:
|
||||
reloader: enabled
|
||||
serviceInstanceName: instance-name
|
||||
serviceInstanceNamespace: sap
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
@@ -0,0 +1,34 @@
|
||||
hs = {}
|
||||
|
||||
-- Check for deletion timestamp
|
||||
if obj ~= nil and obj.metadata.deletionTimestamp then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Resource is being deleted"
|
||||
return hs
|
||||
end
|
||||
|
||||
-- Check for reconciliation conditions
|
||||
if obj ~= nil and obj.status ~= nil then
|
||||
if type(obj.status.conditions) == "table" then
|
||||
for i, condition in ipairs(obj.status.conditions) do
|
||||
if condition.observedGeneration and obj.metadata.generation and condition.observedGeneration ~= obj.metadata.generation then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for spec update to be observed"
|
||||
return hs
|
||||
end
|
||||
if condition ~= nil and
|
||||
((condition.type == "Succeeded" and condition.status == "False") or
|
||||
(condition.type == "Failed" and condition.status == "True")) then
|
||||
hs.status = "Degraded"
|
||||
hs.message = condition.message or ""
|
||||
return hs
|
||||
end
|
||||
end
|
||||
hs.status = "Healthy"
|
||||
hs.message = "Ready to use"
|
||||
return hs
|
||||
end
|
||||
end
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for status"
|
||||
return hs
|
||||
@@ -0,0 +1,21 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Waiting for status'
|
||||
inputPath: testdata/progressing.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Waiting for spec update to be observed'
|
||||
inputPath: testdata/observed-generation-outdated.yaml
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: 'Resource is being deleted'
|
||||
inputPath: testdata/deleting.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: 'ServiceInstance update failed'
|
||||
inputPath: testdata/degraded.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: 'Ready to use'
|
||||
inputPath: testdata/healthy.yaml
|
||||
37
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/degraded.yaml
vendored
Normal file
37
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/degraded.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceInstance
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-service
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
externalName: new-service-instance
|
||||
serviceOfferingName: my-service
|
||||
servicePlanName: my-plan
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance update failed
|
||||
observedGeneration: 1
|
||||
reason: UpdateFailed
|
||||
status: 'False'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance update failed
|
||||
observedGeneration: 1
|
||||
reason: UpdateFailed
|
||||
status: 'True'
|
||||
type: Failed
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
hashedSpec: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
38
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/deleting.yaml
vendored
Normal file
38
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/deleting.yaml
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceInstance
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-service
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
deletionTimestamp: "2025-10-10T10:00:00Z"
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
externalName: new-service-instance
|
||||
serviceOfferingName: my-service
|
||||
servicePlanName: my-plan
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance update failed
|
||||
observedGeneration: 1
|
||||
reason: UpdateFailed
|
||||
status: 'False'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance update failed
|
||||
observedGeneration: 1
|
||||
reason: UpdateFailed
|
||||
status: 'True'
|
||||
type: Failed
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
hashedSpec: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
37
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/healthy.yaml
vendored
Normal file
37
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceInstance
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-service
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
externalName: new-service-instance
|
||||
serviceOfferingName: my-service
|
||||
servicePlanName: my-plan
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance updated successfully
|
||||
observedGeneration: 1
|
||||
reason: Updated
|
||||
status: 'True'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance updated successfully
|
||||
observedGeneration: 1
|
||||
reason: Provisioned
|
||||
status: 'True'
|
||||
type: Ready
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
hashedSpec: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
@@ -0,0 +1,37 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceInstance
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 2
|
||||
name: new-service
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
externalName: new-service-instance
|
||||
serviceOfferingName: my-service
|
||||
servicePlanName: my-plan
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
status:
|
||||
bindingID: 1603017e-f77b-4de4-b5f4-5fd275797f2d
|
||||
conditions:
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance updated successfully
|
||||
observedGeneration: 1
|
||||
reason: Updated
|
||||
status: 'True'
|
||||
type: Succeeded
|
||||
- lastTransitionTime: '2025-08-14T00:38:55Z'
|
||||
message: ServiceInstance updated successfully
|
||||
observedGeneration: 1
|
||||
reason: Provisioned
|
||||
status: 'True'
|
||||
type: Ready
|
||||
instanceID: 0ef2bec2-c0e2-443c-a865-0ebcecc00aca
|
||||
ready: 'True'
|
||||
hashedSpec: e4316201-dcaa-436b-8069-fa366a56c6b3
|
||||
19
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/progressing.yaml
vendored
Normal file
19
resource_customizations/services.cloud.sap.com/ServiceInstance/testdata/progressing.yaml
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: services.cloud.sap.com/v1
|
||||
kind: ServiceInstance
|
||||
metadata:
|
||||
annotations:
|
||||
creationTimestamp: '2025-08-14T00:38:55Z'
|
||||
generation: 1
|
||||
name: new-service
|
||||
namespace: sap
|
||||
resourceVersion: '1'
|
||||
uid: 9c7cad9e-11e2-473f-8061-475a727b9069
|
||||
spec:
|
||||
externalName: new-service-instance
|
||||
serviceOfferingName: my-service
|
||||
servicePlanName: my-plan
|
||||
userInfo:
|
||||
groups:
|
||||
- group1
|
||||
uid: faa21265-03b1-42c2-9f50-90893470e7c3
|
||||
username: user-name
|
||||
Reference in New Issue
Block a user