Skip to content

Commit 2d2be9e

Browse files
brucegucodeTenglong Gu
andauthored
Add DBCluster serverlessV2ScalingConfiguration update support (#96)
* Update cluster custom update logic for serverlessV2ScalingConfiguration Co-authored-by: Tenglong Gu <[email protected]>
1 parent 2145c0e commit 2d2be9e

File tree

14 files changed

+70
-158
lines changed

14 files changed

+70
-158
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-06-23T23:45:42Z"
3-
build_hash: 4b54669d709a0eb2c1fab659e329060350a40e84
4-
go_version: go1.18.3
5-
version: v0.19.2
6-
api_directory_checksum: b0c5acd3d10a1214f5cc46d2fb8b887d9ecc2fe4
2+
build_date: "2022-07-06T21:17:58Z"
3+
build_hash: f9ab7cca7c2ea2ac77d0c4d2dfeb0b42ade56f38
4+
go_version: go1.18.2
5+
version: v0.19.2-4-gf9ab7cc
6+
api_directory_checksum: d6c6f02d6f5547b3092054e9c7c35f5840f8bef9
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.27
99
generator_config_info:
10-
file_checksum: 48d07f9a7b6ea79f8398bcd10254d912cd90cb6d
10+
file_checksum: 2d0c40614a7482376d47885f84cdb713d4307392
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/db_cluster.go

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/generator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ resources:
107107
resource: Key
108108
service_name: kms
109109
path: Status.ACKResourceMetadata.ARN
110+
renames:
111+
operations:
112+
CreateDBCluster:
113+
output_fields:
114+
ScalingConfigurationInfo: ScalingConfiguration
115+
ModifyDBCluster:
116+
output_fields:
117+
ScalingConfigurationInfo: ScalingConfiguration
110118
DBClusterParameterGroup:
111119
renames:
112120
operations:

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/rds.services.k8s.aws_dbclusters.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -869,29 +869,6 @@ spec:
869869
to other Aurora Replicas in the cluster, you can then reconnect
870870
to the reader endpoint."
871871
type: string
872-
scalingConfigurationInfo:
873-
description: "Shows the scaling configuration for an Aurora DB cluster
874-
in serverless DB engine mode. \n For more information, see Using
875-
Amazon Aurora Serverless v1 (https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html)
876-
in the Amazon Aurora User Guide."
877-
properties:
878-
autoPause:
879-
type: boolean
880-
maxCapacity:
881-
format: int64
882-
type: integer
883-
minCapacity:
884-
format: int64
885-
type: integer
886-
secondsBeforeTimeout:
887-
format: int64
888-
type: integer
889-
secondsUntilAutoPause:
890-
format: int64
891-
type: integer
892-
timeoutAction:
893-
type: string
894-
type: object
895872
status:
896873
description: Specifies the current state of this DB cluster.
897874
type: string

generator.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,14 @@ resources:
107107
resource: Key
108108
service_name: kms
109109
path: Status.ACKResourceMetadata.ARN
110+
renames:
111+
operations:
112+
CreateDBCluster:
113+
output_fields:
114+
ScalingConfigurationInfo: ScalingConfiguration
115+
ModifyDBCluster:
116+
output_fields:
117+
ScalingConfigurationInfo: ScalingConfiguration
110118
DBClusterParameterGroup:
111119
renames:
112120
operations:

helm/crds/rds.services.k8s.aws_dbclusters.yaml

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -869,29 +869,6 @@ spec:
869869
to other Aurora Replicas in the cluster, you can then reconnect
870870
to the reader endpoint."
871871
type: string
872-
scalingConfigurationInfo:
873-
description: "Shows the scaling configuration for an Aurora DB cluster
874-
in serverless DB engine mode. \n For more information, see Using
875-
Amazon Aurora Serverless v1 (https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html)
876-
in the Amazon Aurora User Guide."
877-
properties:
878-
autoPause:
879-
type: boolean
880-
maxCapacity:
881-
format: int64
882-
type: integer
883-
minCapacity:
884-
format: int64
885-
type: integer
886-
secondsBeforeTimeout:
887-
format: int64
888-
type: integer
889-
secondsUntilAutoPause:
890-
format: int64
891-
type: integer
892-
timeoutAction:
893-
type: string
894-
type: object
895872
status:
896873
description: Specifies the current state of this DB cluster.
897874
type: string

pkg/resource/db_cluster/custom_update.go

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ func (rm *resourceManager) customUpdate(
6262
ackcondition.SetSynced(desired, corev1.ConditionTrue, nil, nil)
6363
return desired, nil
6464
}
65-
6665
input, err := rm.newCustomUpdateRequestPayload(ctx, desired, delta)
6766
if err != nil {
6867
return nil, err
@@ -459,27 +458,6 @@ func (rm *resourceManager) customUpdate(
459458
} else {
460459
ko.Spec.ReplicationSourceIdentifier = nil
461460
}
462-
if resp.DBCluster.ScalingConfigurationInfo != nil {
463-
f51 := &svcapitypes.ScalingConfigurationInfo{}
464-
if resp.DBCluster.ScalingConfigurationInfo.AutoPause != nil {
465-
f51.AutoPause = resp.DBCluster.ScalingConfigurationInfo.AutoPause
466-
}
467-
if resp.DBCluster.ScalingConfigurationInfo.MaxCapacity != nil {
468-
f51.MaxCapacity = resp.DBCluster.ScalingConfigurationInfo.MaxCapacity
469-
}
470-
if resp.DBCluster.ScalingConfigurationInfo.MinCapacity != nil {
471-
f51.MinCapacity = resp.DBCluster.ScalingConfigurationInfo.MinCapacity
472-
}
473-
if resp.DBCluster.ScalingConfigurationInfo.SecondsUntilAutoPause != nil {
474-
f51.SecondsUntilAutoPause = resp.DBCluster.ScalingConfigurationInfo.SecondsUntilAutoPause
475-
}
476-
if resp.DBCluster.ScalingConfigurationInfo.TimeoutAction != nil {
477-
f51.TimeoutAction = resp.DBCluster.ScalingConfigurationInfo.TimeoutAction
478-
}
479-
ko.Status.ScalingConfigurationInfo = f51
480-
} else {
481-
ko.Status.ScalingConfigurationInfo = nil
482-
}
483461
if resp.DBCluster.Status != nil {
484462
ko.Status.Status = resp.DBCluster.Status
485463
} else {
@@ -630,6 +608,18 @@ func (rm *resourceManager) newCustomUpdateRequestPayload(
630608
}
631609
res.SetVpcSecurityGroupIds(f23)
632610
}
633-
611+
// For ServerlessV2ScalingConfiguration, MaxCapacity and MinCapacity, both need appear in modify call to get ServerlessV2ScalingConfiguration modified
612+
if r.ko.Spec.ServerlessV2ScalingConfiguration != nil && delta.DifferentAt("Spec.ServerlessV2ScalingConfiguration") {
613+
f23 := &svcsdk.ServerlessV2ScalingConfiguration{}
614+
if delta.DifferentAt("Spec.ServerlessV2ScalingConfiguration.MaxCapacity") || delta.DifferentAt("Spec.ServerlessV2ScalingConfiguration.MinCapacity") {
615+
if r.ko.Spec.ServerlessV2ScalingConfiguration.MaxCapacity != nil {
616+
f23.SetMaxCapacity(*r.ko.Spec.ServerlessV2ScalingConfiguration.MaxCapacity)
617+
}
618+
if r.ko.Spec.ServerlessV2ScalingConfiguration.MaxCapacity != nil {
619+
f23.SetMinCapacity(*r.ko.Spec.ServerlessV2ScalingConfiguration.MinCapacity)
620+
}
621+
}
622+
res.SetServerlessV2ScalingConfiguration(f23)
623+
}
634624
return res, nil
635625
}

pkg/resource/db_cluster/sdk.go

Lines changed: 8 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/resource/db_cluster_parameter_group/sdk.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)