-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(health): support for some rds.crossplane.io resources (#19076)
Signed-off-by: Jellyfrog <[email protected]>
- Loading branch information
Showing
11 changed files
with
471 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
resource_customizations/rds.aws.crossplane.io/DBCluster/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
18 changes: 18 additions & 0 deletions
18
resource_customizations/rds.aws.crossplane.io/DBCluster/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 48 additions & 0 deletions
48
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/creating.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 37 additions & 0 deletions
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/degraded.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 61 additions & 0 deletions
61
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 37 additions & 0 deletions
37
resource_customizations/rds.aws.crossplane.io/DBCluster/testdata/suspended.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
41 changes: 41 additions & 0 deletions
41
resource_customizations/rds.aws.crossplane.io/DBInstance/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
14 changes: 14 additions & 0 deletions
14
resource_customizations/rds.aws.crossplane.io/DBInstance/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 changes: 45 additions & 0 deletions
45
resource_customizations/rds.aws.crossplane.io/DBInstance/testdata/creating.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.