Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rdsinstance.database): do not overwrite engineVersion if only major was set + add engineVersion to observe #2149

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apis/database/v1beta1/rdsinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ type RDSInstanceStatus struct {
// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status"
// +kubebuilder:printcolumn:name="STATE",type="string",JSONPath=".status.atProvider.dbInstanceStatus"
// +kubebuilder:printcolumn:name="ENGINE",type="string",JSONPath=".spec.forProvider.engine"
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".spec.forProvider.engineVersion"
// +kubebuilder:printcolumn:name="VERSION",type="string",JSONPath=".status.atProvider.engineVersion"
// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:subresource:status
// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws}
Expand Down
2 changes: 1 addition & 1 deletion package/crds/database.aws.crossplane.io_rdsinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ spec:
- jsonPath: .spec.forProvider.engine
name: ENGINE
type: string
- jsonPath: .spec.forProvider.engineVersion
- jsonPath: .status.atProvider.engineVersion
name: VERSION
type: string
- jsonPath: .metadata.creationTimestamp
Expand Down
8 changes: 1 addition & 7 deletions pkg/clients/database/rds.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
Expand Down Expand Up @@ -463,6 +462,7 @@ func GenerateObservation(db rdstypes.DBInstance) v1beta1.RDSInstanceObservation
DBInstancePort: int(ptr.Deref(db.DbInstancePort, 0)),
DBResourceID: aws.ToString(db.DbiResourceId),
EnabledCloudwatchLogsExports: db.EnabledCloudwatchLogsExports,
EngineVersion: db.EngineVersion,
EnhancedMonitoringResourceArn: aws.ToString(db.EnhancedMonitoringResourceArn),
PerformanceInsightsEnabled: aws.ToBool(db.PerformanceInsightsEnabled),
ReadReplicaDBClusterIdentifiers: db.ReadReplicaDBClusterIdentifiers,
Expand Down Expand Up @@ -671,12 +671,6 @@ func LateInitialize(in *v1beta1.RDSInstanceParameters, db *rdstypes.DBInstance)
}
}
in.EngineVersion = pointer.LateInitialize(in.EngineVersion, db.EngineVersion)
// When version 5.6 is chosen, AWS creates 5.6.41 and that's totally valid.
// But we detect as if we need to update it all the time. Here, we assign
// the actual full version to our spec to avoid unnecessary update signals.
if strings.HasPrefix(aws.ToString(db.EngineVersion), aws.ToString(in.EngineVersion)) {
in.EngineVersion = db.EngineVersion
}
if in.DBParameterGroupName == nil {
for i := range db.DBParameterGroups {
if db.DBParameterGroups[i].DBParameterGroupName != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/clients/database/rds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ var (
tier = 4
tier32 = int32(tier)
trueFlag = true
truncEngine = "5.6"
username = "username"
value = "testValue"
vpc = "vpc"
Expand Down Expand Up @@ -836,6 +835,7 @@ func TestGenerateObservation(t *testing.T) {
DbiResourceId: &resourceID,
BackupRetentionPeriod: &retention32,
EnabledCloudwatchLogsExports: enabledCloudwatchExports,
EngineVersion: &engine,
EnhancedMonitoringResourceArn: &arn,
PerformanceInsightsEnabled: &trueFlag,
ReadReplicaDBClusterIdentifiers: replicaClusters,
Expand Down Expand Up @@ -893,6 +893,7 @@ func TestGenerateObservation(t *testing.T) {
InstanceCreateTime: &metav1.Time{Time: createTime},
Endpoint: v1beta1.Endpoint{Port: port, HostedZoneID: zone, Address: address},
EnabledCloudwatchLogsExports: enabledCloudwatchExports,
EngineVersion: &engine,
EnhancedMonitoringResourceArn: arn,
LatestRestorableTime: &metav1.Time{Time: lastRestoreTime},
OptionGroupMemberships: []v1beta1.OptionGroupMembership{{OptionGroupName: name, Status: status}},
Expand Down Expand Up @@ -1230,7 +1231,7 @@ func TestLateInitialize(t *testing.T) {
EngineVersion: &engine,
},
params: v1beta1.RDSInstanceParameters{
EngineVersion: &truncEngine,
EngineVersion: &engine,
},
want: v1beta1.RDSInstanceParameters{
EngineVersion: &engine,
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/database/rdsinstance/rdsinstance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func withStatusAWSBackupRecoveryPointARN(s string) rdsModifier {
return func(r *v1beta1.RDSInstance) { r.Status.AtProvider.AWSBackupRecoveryPointARN = s }
}

func withStatusEngineVersion(s *string) rdsModifier {
return func(r *v1beta1.RDSInstance) { r.Status.AtProvider.EngineVersion = s }
}

func instance(m ...rdsModifier) *v1beta1.RDSInstance {
cr := &v1beta1.RDSInstance{}
for _, f := range m {
Expand Down Expand Up @@ -421,6 +425,7 @@ func TestObserve(t *testing.T) {
want: want{
cr: instance(
withEngineVersion(&engineVersion),
withStatusEngineVersion(&engineVersion),
withDBInstanceStatus(string(v1beta1.RDSInstanceStateCreating)),
withConditions(xpv1.Creating()),
),
Expand Down
Loading