Skip to content

Commit 3cc1a09

Browse files
committed
add replica update to crd
1 parent 9a9fa52 commit 3cc1a09

13 files changed

+712
-77
lines changed

Diff for: apis/v1alpha1/ack-generate-metadata.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2025-02-20T18:05:49Z"
3-
build_hash: a326346bd3a6973254d247c9ab2dc76790c36241
2+
build_date: "2025-03-12T23:25:20Z"
3+
build_hash: 5645e51ed3c413f616e1b929f1527a5139c44198
44
go_version: go1.24.0
5-
version: v0.43.2
6-
api_directory_checksum: 3bc0637159c94a74d2402d9a707f9c21339e9b45
5+
version: v0.43.2-3-g5645e51
6+
api_directory_checksum: 0d5b95bdbe63c6cfc495149b7a86440c4a5fb33a
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.32.6
99
generator_config_info:
10-
file_checksum: f6d68afa724d9e1d8fb6ce58da11ed0e5635f9d5
10+
file_checksum: 48323d41b9cb7ade08c8a87367846cccdd1f6409
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

Diff for: apis/v1alpha1/generator.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ operations:
2525
resources:
2626
Table:
2727
fields:
28+
Replicas:
29+
custom_field:
30+
list_of: CreateReplicationGroupMemberAction
31+
compare:
32+
is_ignored: true
33+
ReplicasDescriptions:
34+
custom_field:
35+
list_of: ReplicaDescription
36+
is_read_only: true
2837
GlobalSecondaryIndexesDescriptions:
2938
custom_field:
3039
list_of: GlobalSecondaryIndexDescription
@@ -64,7 +73,7 @@ resources:
6473
references:
6574
service_name: kms
6675
resource: Key
67-
path: Status.ACKResourceMetadata.ARN
76+
path: Status.ACKResourceMetadata.ARN
6877
exceptions:
6978
errors:
7079
404:

Diff for: apis/v1alpha1/table.go

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: apis/v1alpha1/zz_generated.deepcopy.go

+13-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: config/crd/bases/dynamodb.services.k8s.aws_tables.yaml

+40-2
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,45 @@ spec:
322322
format: int64
323323
type: integer
324324
type: object
325+
replicas:
326+
items:
327+
description: Represents a replica to be created.
328+
properties:
329+
globalSecondaryIndexes:
330+
items:
331+
description: Represents the properties of a replica global
332+
secondary index.
333+
properties:
334+
indexName:
335+
type: string
336+
provisionedThroughputOverride:
337+
description: |-
338+
Replica-specific provisioned throughput settings. If not specified, uses
339+
the source table's provisioned throughput settings.
340+
properties:
341+
readCapacityUnits:
342+
format: int64
343+
type: integer
344+
type: object
345+
type: object
346+
type: array
347+
kmsMasterKeyID:
348+
type: string
349+
provisionedThroughputOverride:
350+
description: |-
351+
Replica-specific provisioned throughput settings. If not specified, uses
352+
the source table's provisioned throughput settings.
353+
properties:
354+
readCapacityUnits:
355+
format: int64
356+
type: integer
357+
type: object
358+
regionName:
359+
type: string
360+
tableClassOverride:
361+
type: string
362+
type: object
363+
type: array
325364
sseSpecification:
326365
description: Represents the settings used to enable server-side encryption.
327366
properties:
@@ -605,8 +644,7 @@ spec:
605644
606645
* StreamLabel
607646
type: string
608-
replicas:
609-
description: Represents replicas of the table.
647+
replicasDescriptions:
610648
items:
611649
description: Contains the details of the replica.
612650
properties:

Diff for: generator.yaml

+10-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ operations:
2525
resources:
2626
Table:
2727
fields:
28+
Replicas:
29+
custom_field:
30+
list_of: CreateReplicationGroupMemberAction
31+
compare:
32+
is_ignored: true
33+
ReplicasDescriptions:
34+
custom_field:
35+
list_of: ReplicaDescription
36+
is_read_only: true
2837
GlobalSecondaryIndexesDescriptions:
2938
custom_field:
3039
list_of: GlobalSecondaryIndexDescription
@@ -64,7 +73,7 @@ resources:
6473
references:
6574
service_name: kms
6675
resource: Key
67-
path: Status.ACKResourceMetadata.ARN
76+
path: Status.ACKResourceMetadata.ARN
6877
exceptions:
6978
errors:
7079
404:

Diff for: helm/crds/dynamodb.services.k8s.aws_tables.yaml

+40-2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,45 @@ spec:
326326
format: int64
327327
type: integer
328328
type: object
329+
replicas:
330+
items:
331+
description: Represents a replica to be created.
332+
properties:
333+
globalSecondaryIndexes:
334+
items:
335+
description: Represents the properties of a replica global
336+
secondary index.
337+
properties:
338+
indexName:
339+
type: string
340+
provisionedThroughputOverride:
341+
description: |-
342+
Replica-specific provisioned throughput settings. If not specified, uses
343+
the source table's provisioned throughput settings.
344+
properties:
345+
readCapacityUnits:
346+
format: int64
347+
type: integer
348+
type: object
349+
type: object
350+
type: array
351+
kmsMasterKeyID:
352+
type: string
353+
provisionedThroughputOverride:
354+
description: |-
355+
Replica-specific provisioned throughput settings. If not specified, uses
356+
the source table's provisioned throughput settings.
357+
properties:
358+
readCapacityUnits:
359+
format: int64
360+
type: integer
361+
type: object
362+
regionName:
363+
type: string
364+
tableClassOverride:
365+
type: string
366+
type: object
367+
type: array
329368
sseSpecification:
330369
description: Represents the settings used to enable server-side encryption.
331370
properties:
@@ -609,8 +648,7 @@ spec:
609648
610649
* StreamLabel
611650
type: string
612-
replicas:
613-
description: Represents replicas of the table.
651+
replicasDescriptions:
614652
items:
615653
description: Contains the details of the replica.
616654
properties:

Diff for: pkg/resource/table/hooks.go

+29-4
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,25 @@ import (
3434

3535
var (
3636
ErrTableDeleting = fmt.Errorf(
37-
"Table in '%v' state, cannot be modified or deleted",
37+
"table in '%v' state, cannot be modified or deleted",
3838
svcsdktypes.TableStatusDeleting,
3939
)
4040
ErrTableCreating = fmt.Errorf(
41-
"Table in '%v' state, cannot be modified or deleted",
41+
"table in '%v' state, cannot be modified or deleted",
4242
svcsdktypes.TableStatusCreating,
4343
)
4444
ErrTableUpdating = fmt.Errorf(
45-
"Table in '%v' state, cannot be modified or deleted",
45+
"table in '%v' state, cannot be modified or deleted",
4646
svcsdktypes.TableStatusUpdating,
4747
)
4848
ErrTableGSIsUpdating = fmt.Errorf(
49-
"Table GSIs in '%v' state, cannot be modified or deleted",
49+
"table GSIs in '%v' state, cannot be modified or deleted",
5050
svcsdktypes.IndexStatusCreating,
5151
)
52+
ErrReplicaNotActive = fmt.Errorf(
53+
"table replica in NOT '%v' state, cannot be modified or deleted",
54+
svcsdktypes.ReplicaStatusActive,
55+
)
5256
)
5357

5458
// TerminalStatuses are the status strings that are terminal states for a
@@ -80,6 +84,10 @@ var (
8084
ErrTableGSIsUpdating,
8185
10*time.Second,
8286
)
87+
requeueWaitForReplicasActive = ackrequeue.NeededAfter(
88+
ErrReplicaNotActive,
89+
10*time.Second,
90+
)
8391
)
8492

8593
// tableHasTerminalStatus returns whether the supplied Dynamodb table is in a
@@ -224,6 +232,10 @@ func (rm *resourceManager) customUpdateTable(
224232
}
225233
return nil, err
226234
}
235+
case delta.DifferentAt("Spec.Replicas"):
236+
if err := rm.syncReplicaUpdates(ctx, latest, desired); err != nil {
237+
return nil, err
238+
}
227239
}
228240
}
229241

@@ -262,6 +274,10 @@ func (rm *resourceManager) newUpdateTablePayload(
262274
input := &svcsdk.UpdateTableInput{
263275
TableName: aws.String(*r.ko.Spec.TableName),
264276
}
277+
// If delta is nil, we're just creating a basic payload for other operations to modify
278+
if delta == nil {
279+
return input, nil
280+
}
265281

266282
if delta.DifferentAt("Spec.BillingMode") {
267283
if r.ko.Spec.BillingMode != nil {
@@ -558,6 +574,15 @@ func customPreCompare(
558574
}
559575
}
560576

577+
// Handle ReplicaUpdates comparison
578+
if len(a.ko.Spec.Replicas) != len(b.ko.Spec.Replicas) {
579+
delta.Add("Spec.Replicas", a.ko.Spec.Replicas, b.ko.Spec.Replicas)
580+
} else if a.ko.Spec.Replicas != nil && b.ko.Spec.Replicas != nil {
581+
if !equalReplicaArrays(a.ko.Spec.Replicas, b.ko.Spec.Replicas) {
582+
delta.Add("Spec.Replicas", a.ko.Spec.Replicas, b.ko.Spec.Replicas)
583+
}
584+
}
585+
561586
if a.ko.Spec.DeletionProtectionEnabled == nil {
562587
a.ko.Spec.DeletionProtectionEnabled = aws.Bool(false)
563588
}

0 commit comments

Comments
 (0)