Skip to content

Commit

Permalink
feat(docdb): observe engineVersion + fix/add unit-test cases
Browse files Browse the repository at this point in the history
Signed-off-by: Charel Baum (external expert on behalf of DB InfraGO AG) <[email protected]>
  • Loading branch information
Charel Baum (external expert on behalf of DB InfraGO AG) committed Jul 4, 2024
1 parent 1a2c379 commit e30016c
Show file tree
Hide file tree
Showing 7 changed files with 397 additions and 6 deletions.
5 changes: 5 additions & 0 deletions apis/docdb/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ resources:
from:
operation: ModifyDBCluster
path: AllowMajorVersionUpgrade
EngineVersion:
is_read_only: true
from:
operation: DescribeDBClusters
path: DBClusters.EngineVersion

ignore:
field_paths:
Expand Down
2 changes: 2 additions & 0 deletions apis/docdb/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (
DocDBInstanceStateDeleting = "deleting"
// The instance is being modified.
DocDBInstanceStateModifying = "modifying"
// The instance is being upgraded.
DocDBInstanceStateUpgrading = "upgrading"
// The instance has failed and Amazon RDS can't recover it. Perform a point-in-time restore to the latest restorable time of the instance to recover the data.
DocDBInstanceStateFailed = "failed"
)
Expand Down
2 changes: 2 additions & 0 deletions apis/docdb/v1alpha1/zz_db_cluster.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions apis/docdb/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package/crds/docdb.aws.crossplane.io_dbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,9 @@ spec:
description: Specifies the connection endpoint for the primary
instance of the cluster.
type: string
engineVersion:
description: Indicates the database engine version.
type: string
hostedZoneID:
description: Specifies the ID that Amazon Route 53 assigns when
you create a hosted zone.
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/docdb/dbcluster/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func (e *hooks) postObserve(ctx context.Context, cr *svcapitypes.DBCluster, resp
return managed.ExternalObservation{}, err
}

cluster := resp.DBClusters[0]
cr.Status.AtProvider.EngineVersion = cluster.EngineVersion

obs.ConnectionDetails = getConnectionDetails(cr)

if !meta.WasDeleted(cr) {
Expand Down Expand Up @@ -180,6 +183,10 @@ func lateInitialize(cr *svcapitypes.DBClusterParameters, resp *svcsdk.DescribeDB
func (e *hooks) isUpToDate(ctx context.Context, cr *svcapitypes.DBCluster, resp *svcsdk.DescribeDBClustersOutput) (bool, string, error) {
cluster := resp.DBClusters[0]

if pointer.StringValue(cluster.Status) == svcapitypes.DocDBInstanceStateModifying || pointer.StringValue(cluster.Status) == svcapitypes.DocDBInstanceStateUpgrading {
return true, "", nil
}

_, pwChanged, err := e.getPasswordFromRef(ctx, cr.Spec.ForProvider.MasterUserPasswordSecretRef, cr.Spec.WriteConnectionSecretToReference)
if err != nil || pwChanged {
return false, "", err
Expand Down
Loading

0 comments on commit e30016c

Please sign in to comment.