mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
feat(health): support for some rds.crossplane.io resources (#19076)
Signed-off-by: Jellyfrog <Jellyfrog@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
local hs = {}
|
||||
if obj.status ~= nil then
|
||||
if obj.status.conditions ~= nil then
|
||||
local ready = false
|
||||
local synced = false
|
||||
local suspended = false
|
||||
for i, condition in ipairs(obj.status.conditions) do
|
||||
|
||||
if condition.type == "Ready" then
|
||||
ready = condition.status == "True"
|
||||
ready_message = condition.reason
|
||||
elseif condition.type == "Synced" then
|
||||
synced = condition.status == "True"
|
||||
if condition.reason == "ReconcileError" then
|
||||
synced_message = condition.message
|
||||
elseif condition.reason == "ReconcilePaused" then
|
||||
suspended = true
|
||||
suspended_message = condition.reason
|
||||
end
|
||||
end
|
||||
end
|
||||
if ready and synced then
|
||||
hs.status = "Healthy"
|
||||
hs.message = ready_message
|
||||
elseif synced == false and suspended == true then
|
||||
hs.status = "Suspended"
|
||||
hs.message = suspended_message
|
||||
elseif ready == false and synced == true and suspended == false then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for DBCluster to be available"
|
||||
else
|
||||
hs.status = "Degraded"
|
||||
hs.message = synced_message
|
||||
end
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for DBCluster to be created"
|
||||
return hs
|
||||
@@ -0,0 +1,18 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: Waiting for DBCluster to be available
|
||||
inputPath: testdata/creating.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: Available
|
||||
inputPath: testdata/healthy.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "create failed: cannot create DBCluster in AWS: InvalidParameterValue:
|
||||
Invalid DB engine\n\tstatus code: 400, request id: "
|
||||
inputPath: testdata/degraded.yaml
|
||||
- healthStatus:
|
||||
status: Suspended
|
||||
message: ReconcilePaused
|
||||
inputPath: testdata/suspended.yaml
|
||||
48
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/creating.yaml
vendored
Normal file
48
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/creating.yaml
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBCluster
|
||||
metadata:
|
||||
name: test-rds1
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
allowMajorVersionUpgrade: true
|
||||
applyImmediately: true
|
||||
autogeneratePassword: true
|
||||
databaseName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
engine: aurora-postgresql
|
||||
engineVersion: '16.2'
|
||||
masterUsername: root
|
||||
skipFinalSnapshot: true
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
publishConnectionDetailsTo:
|
||||
configRef:
|
||||
name: store-config
|
||||
name: test-rds1-rds
|
||||
status:
|
||||
atProvider:
|
||||
activityStreamStatus: stopped
|
||||
clusterCreateTime: '2024-07-15T14:23:42Z'
|
||||
crossAccountClone: false
|
||||
dbClusterARN: 'arn:aws:rds:abc123:cluster:test-rds1'
|
||||
dbClusterIdentifier: test-rds1
|
||||
dbClusterParameterGroup: default.aurora-postgresql16
|
||||
dbClusterResourceID: cluster-abc123
|
||||
dbSubnetGroup: test-rds
|
||||
endpoint: test-rds1.cluster-abc.rds.amazonaws.com
|
||||
status: creating
|
||||
vpcSecurityGroups:
|
||||
- status: active
|
||||
vpcSecurityGroupID: sg-abc123
|
||||
conditions:
|
||||
- lastTransitionTime: '2024-07-15T14:23:42Z'
|
||||
reason: Creating
|
||||
status: 'False'
|
||||
type: Ready
|
||||
- lastTransitionTime: '2024-07-15T14:23:42Z'
|
||||
reason: ReconcileSuccess
|
||||
status: 'True'
|
||||
type: Synced
|
||||
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/degraded.yaml
vendored
Normal file
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/degraded.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBCluster
|
||||
metadata:
|
||||
name: test-rds1
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
allowMajorVersionUpgrade: true
|
||||
applyImmediately: true
|
||||
autogeneratePassword: true
|
||||
databaseName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
engine: foobar
|
||||
engineVersion: '16.2'
|
||||
masterUsername: root
|
||||
skipFinalSnapshot: true
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
publishConnectionDetailsTo:
|
||||
configRef:
|
||||
name: store-config
|
||||
name: test-rds1-rds
|
||||
status:
|
||||
atProvider: {}
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-07-17T18:03:12Z"
|
||||
reason: Creating
|
||||
status: "False"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-07-17T18:03:12Z"
|
||||
message: "create failed: cannot create DBCluster in AWS: InvalidParameterValue:
|
||||
Invalid DB engine\n\tstatus code: 400, request id: "
|
||||
reason: ReconcileError
|
||||
status: "False"
|
||||
type: Synced
|
||||
61
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/healthy.yaml
vendored
Normal file
61
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBCluster
|
||||
metadata:
|
||||
name: test-rds1
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
allowMajorVersionUpgrade: true
|
||||
applyImmediately: true
|
||||
autogeneratePassword: true
|
||||
databaseName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
engine: aurora-postgresql
|
||||
engineVersion: '16.2'
|
||||
masterUsername: root
|
||||
skipFinalSnapshot: true
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
publishConnectionDetailsTo:
|
||||
configRef:
|
||||
name: store-config
|
||||
name: test-rds1-rds
|
||||
status:
|
||||
atProvider:
|
||||
activityStreamStatus: stopped
|
||||
clusterCreateTime: "2024-07-15T14:23:42Z"
|
||||
crossAccountClone: false
|
||||
dbClusterARN: arn:aws:rds:abc123:cluster:test-rds1
|
||||
dbClusterIdentifier: test-rds1
|
||||
dbClusterMembers:
|
||||
- dbClusterParameterGroupStatus: in-sync
|
||||
dbInstanceIdentifier: test-rds1-0
|
||||
isClusterWriter: true
|
||||
promotionTier: 1
|
||||
dbClusterParameterGroup: default.aurora-postgresql16
|
||||
dbClusterResourceID: cluster-abc123
|
||||
dbSubnetGroup: sandbox5-valhalla-rds
|
||||
earliestRestorableTime: "2024-07-15T14:24:40Z"
|
||||
endpoint: test-rds1.cluster-abc123.rds.amazonaws.com
|
||||
engineVersion: "16.2"
|
||||
hostedZoneID: abc123
|
||||
httpEndpointEnabled: false
|
||||
iamDatabaseAuthenticationEnabled: false
|
||||
latestRestorableTime: "2024-07-15T14:46:08Z"
|
||||
multiAZ: false
|
||||
readerEndpoint: test-rds1.abc123.rds.amazonaws.com
|
||||
status: available
|
||||
vpcSecurityGroups:
|
||||
- status: active
|
||||
vpcSecurityGroupID: sg-abc123
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-07-15T14:48:40Z"
|
||||
reason: Available
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-07-15T14:23:42Z"
|
||||
reason: ReconcileSuccess
|
||||
status: "True"
|
||||
type: Synced
|
||||
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/suspended.yaml
vendored
Normal file
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/suspended.yaml
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBCluster
|
||||
metadata:
|
||||
name: test-rds1
|
||||
annotations:
|
||||
crossplane.io/paused: "true"
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
allowMajorVersionUpgrade: true
|
||||
applyImmediately: true
|
||||
autogeneratePassword: true
|
||||
databaseName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
engine: aurora-postgresql
|
||||
engineVersion: '16.2'
|
||||
masterUsername: root
|
||||
skipFinalSnapshot: true
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
publishConnectionDetailsTo:
|
||||
configRef:
|
||||
name: store-config
|
||||
name: test-rds1-rds
|
||||
status:
|
||||
atProvider: {}
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-07-17T18:03:12Z"
|
||||
reason: Creating
|
||||
status: "False"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-07-17T18:04:55Z"
|
||||
reason: ReconcilePaused
|
||||
status: "False"
|
||||
type: Synced
|
||||
@@ -0,0 +1,41 @@
|
||||
local hs = {}
|
||||
if obj.status ~= nil then
|
||||
if obj.status.conditions ~= nil then
|
||||
local ready = false
|
||||
local synced = false
|
||||
local suspended = false
|
||||
for i, condition in ipairs(obj.status.conditions) do
|
||||
|
||||
if condition.type == "Ready" then
|
||||
ready = condition.status == "True"
|
||||
ready_message = condition.reason
|
||||
elseif condition.type == "Synced" then
|
||||
synced = condition.status == "True"
|
||||
if condition.reason == "ReconcileError" then
|
||||
synced_message = condition.message
|
||||
elseif condition.reason == "ReconcilePaused" then
|
||||
suspended = true
|
||||
suspended_message = condition.reason
|
||||
end
|
||||
end
|
||||
end
|
||||
if ready and synced then
|
||||
hs.status = "Healthy"
|
||||
hs.message = ready_message
|
||||
elseif synced == false and suspended == true then
|
||||
hs.status = "Suspended"
|
||||
hs.message = suspended_message
|
||||
elseif ready == false and synced == true and suspended == false then
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for DBInstance to be available"
|
||||
else
|
||||
hs.status = "Degraded"
|
||||
hs.message = synced_message
|
||||
end
|
||||
return hs
|
||||
end
|
||||
end
|
||||
|
||||
hs.status = "Progressing"
|
||||
hs.message = "Waiting for DBInstance to be created"
|
||||
return hs
|
||||
@@ -0,0 +1,14 @@
|
||||
tests:
|
||||
- healthStatus:
|
||||
status: Progressing
|
||||
message: Waiting for DBInstance to be available
|
||||
inputPath: testdata/creating.yaml
|
||||
- healthStatus:
|
||||
status: Healthy
|
||||
message: Available
|
||||
inputPath: testdata/healthy.yaml
|
||||
- healthStatus:
|
||||
status: Degraded
|
||||
message: "update failed: cannot update DBInstance in AWS: InvalidParameterValue:
|
||||
Invalid DB Instance class: db.t4g.foobar\n\tstatus code: 400, request id: "
|
||||
inputPath: testdata/degraded.yaml
|
||||
45
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/creating.yaml
vendored
Normal file
45
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/creating.yaml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBInstance
|
||||
metadata:
|
||||
name: test-rds1-0
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
autoMinorVersionUpgrade: true
|
||||
caCertificateIdentifier: rds-ca-rsa2048-g1
|
||||
dbClusterIdentifier: test-rds1
|
||||
dbInstanceClass: db.t4g.medium
|
||||
dbName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
enablePerformanceInsights: false
|
||||
engine: aurora-postgresql
|
||||
licenseModel: postgresql-license
|
||||
masterUsername: root
|
||||
multiAZ: false
|
||||
preferredMaintenanceWindow: 'tue:00:36-tue:01:06'
|
||||
promotionTier: 1
|
||||
publiclyAccessible: false
|
||||
region: eu-north-1
|
||||
storageThroughput: 0
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
status:
|
||||
atProvider:
|
||||
certificateDetails:
|
||||
cAIdentifier: rds-ca-rsa2048-g1
|
||||
customerOwnedIPEnabled: false
|
||||
dbInstanceARN: 'arn:aws:rds:abc:db:test-rds1-0'
|
||||
dbInstanceIdentifier: test-rds1-0
|
||||
dbInstancePort: 0
|
||||
dbInstanceStatus: creating
|
||||
conditions:
|
||||
- lastTransitionTime: '2024-07-15T14:25:07Z'
|
||||
reason: Creating
|
||||
status: 'False'
|
||||
type: Ready
|
||||
- lastTransitionTime: '2024-07-15T14:25:07Z'
|
||||
reason: ReconcileSuccess
|
||||
status: 'True'
|
||||
type: Synced
|
||||
64
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/degraded.yaml
vendored
Normal file
64
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/degraded.yaml
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBInstance
|
||||
metadata:
|
||||
name: test-rds1-0
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
autoMinorVersionUpgrade: true
|
||||
caCertificateIdentifier: rds-ca-rsa2048-g1
|
||||
dbClusterIdentifier: test-rds1
|
||||
dbInstanceClass: db.t4g.foobar
|
||||
dbName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
enablePerformanceInsights: false
|
||||
engine: aurora-postgresql
|
||||
licenseModel: postgresql-license
|
||||
masterUsername: root
|
||||
multiAZ: false
|
||||
preferredMaintenanceWindow: 'tue:00:36-tue:01:06'
|
||||
promotionTier: 1
|
||||
publiclyAccessible: false
|
||||
region: eu-north-1
|
||||
storageThroughput: 0
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
status:
|
||||
atProvider:
|
||||
certificateDetails:
|
||||
cAIdentifier: rds-ca-rsa2048-g1
|
||||
validTill: "2025-07-15T16:06:53Z"
|
||||
customerOwnedIPEnabled: false
|
||||
dbInstanceARN: arn:aws:rds:123:db:test-rds1-app-0
|
||||
dbInstanceIdentifier: test-rds1-app-0
|
||||
dbInstancePort: 0
|
||||
dbInstanceStatus: available
|
||||
dbiResourceID: db-123
|
||||
endpoint:
|
||||
address: test-rds1-app-0.123.abc.rds.amazonaws.com
|
||||
hostedZoneID: ABC213
|
||||
port: 5432
|
||||
engineVersion: "16.2"
|
||||
iamDatabaseAuthenticationEnabled: false
|
||||
instanceCreateTime: "2024-07-15T16:08:27Z"
|
||||
optionGroupMemberships:
|
||||
- optionGroupName: default:aurora-postgresql-16
|
||||
status: in-sync
|
||||
pendingModifiedValues: {}
|
||||
performanceInsightsEnabled: false
|
||||
vpcSecurityGroups:
|
||||
- status: active
|
||||
vpcSecurityGroupID: sg-abc123
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-07-15T17:04:24Z"
|
||||
reason: Available
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-07-17T17:57:38Z"
|
||||
message: "update failed: cannot update DBInstance in AWS: InvalidParameterValue:
|
||||
Invalid DB Instance class: db.t4g.foobar\n\tstatus code: 400, request id: "
|
||||
reason: ReconcileError
|
||||
status: "False"
|
||||
type: Synced
|
||||
65
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/healthy.yaml
vendored
Normal file
65
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/healthy.yaml
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
apiVersion: rds.aws.crossplane.io/v1alpha1
|
||||
kind: DBInstance
|
||||
metadata:
|
||||
name: test-rds1-0
|
||||
spec:
|
||||
deletionPolicy: Delete
|
||||
forProvider:
|
||||
autoMinorVersionUpgrade: true
|
||||
caCertificateIdentifier: rds-ca-rsa2048-g1
|
||||
dbClusterIdentifier: test-rds1
|
||||
dbInstanceClass: db.t4g.medium
|
||||
dbName: app
|
||||
dbSubnetGroupName: test-rds
|
||||
enablePerformanceInsights: false
|
||||
engine: aurora-postgresql
|
||||
licenseModel: postgresql-license
|
||||
masterUsername: root
|
||||
multiAZ: false
|
||||
preferredMaintenanceWindow: 'tue:00:36-tue:01:06'
|
||||
promotionTier: 1
|
||||
publiclyAccessible: false
|
||||
region: eu-north-1
|
||||
storageThroughput: 0
|
||||
managementPolicies:
|
||||
- '*'
|
||||
providerConfigRef:
|
||||
name: provider-aws
|
||||
status:
|
||||
atProvider:
|
||||
certificateDetails:
|
||||
cAIdentifier: rds-ca-rsa2048-g1
|
||||
validTill: "2025-07-15T14:27:27Z"
|
||||
customerOwnedIPEnabled: false
|
||||
dbInstanceARN: arn:aws:rds:abc123:db:test-rds1-0
|
||||
dbInstanceIdentifier: test-rds1-0
|
||||
dbInstancePort: 0
|
||||
dbInstanceStatus: available
|
||||
dbParameterGroups:
|
||||
- dbParameterGroupName: default.aurora-postgresql16
|
||||
parameterApplyStatus: in-sync
|
||||
dbiResourceID: db-abc123
|
||||
endpoint:
|
||||
address: test-rds1-0.abc123.rds.amazonaws.com
|
||||
hostedZoneID: abc123
|
||||
port: 5432
|
||||
engineVersion: "16.2"
|
||||
iamDatabaseAuthenticationEnabled: false
|
||||
instanceCreateTime: "2024-07-15T14:29:00Z"
|
||||
optionGroupMemberships:
|
||||
- optionGroupName: default:aurora-postgresql-16
|
||||
status: in-sync
|
||||
pendingModifiedValues: {}
|
||||
performanceInsightsEnabled: false
|
||||
vpcSecurityGroups:
|
||||
- status: active
|
||||
vpcSecurityGroupID: sg-abc123
|
||||
conditions:
|
||||
- lastTransitionTime: "2024-07-15T14:48:40Z"
|
||||
reason: Available
|
||||
status: "True"
|
||||
type: Ready
|
||||
- lastTransitionTime: "2024-07-15T14:25:07Z"
|
||||
reason: ReconcileSuccess
|
||||
status: "True"
|
||||
type: Synced
|
||||
Reference in New Issue
Block a user