-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: creating gsi under on-demand mode (#85)
Issue #, if available: Description of changes: - fix empty NonKeyAttributes validation issue - fix GSI creation issue when using `pay-per-request` mode ```shell 2023-04-19T17:31:29.932+0200 ERROR Reconciler error {"controller": "table", "controllerGroup": "dynamodb.services.k8s.aws", "controllerKind": "Table", "Table": {"name":"ack-demo-table-provisioned-global-secondary-indexes","namespace":"ack-system"}, "namespace": "ack-system", "name": "ack-demo-table-provisioned-global-secondary-indexes", "reconcileID": "c7354a77-56c4-4c56-b715-f16b59d1926e", "error": "ValidationException: One or more parameter values were invalid: Neither ReadCapacityUnits nor WriteCapacityUnits can be specified when BillingMode is PAY_PER_REQUEST\n\tstatus code: 400, request id: R901I15N84RUVS24D4HVRP6L3JVV4KQNSO5AEMVJF66Q9ASUAAJG"} 2023-04-19T18:54:54.887+0200 ERROR Reconciler error {"controller": "table", "controllerGroup": "dynamodb.services.k8s.aws", "controllerKind": "Table", "Table": {"name":"ack-demo-table-provisioned-global-secondary-indexes","namespace":"ack-system"}, "namespace": "ack-system", "name": "ack-demo-table-provisioned-global-secondary-indexes", "reconcileID": "223f9f39-f2cc-460c-ad78-56fce55b4bf3", "error": "ValidationException: One or more parameter values were invalid: ProvisionedThroughput should not be specified for index: id-index when BillingMode is PAY_PER_REQUEST\n\tstatus code: 400, request id: JO5OGQR8IN74JJ2C62O43ESU43VV4KQNSO5AEMVJF66Q9ASUAAJG"} sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler ``` ```yaml conditions: - message: | InvalidParameter: 3 validation error(s) found. - minimum field size of 1, UpdateTableInput.GlobalSecondaryIndexUpdates[0].Create.Projection.NonKeyAttributes. - minimum field value of 1, UpdateTableInput.GlobalSecondaryIndexUpdates[0].Create.ProvisionedThroughput.ReadCapacityUnits. - minimum field value of 1, UpdateTableInput.GlobalSecondaryIndexUpdates[0].Create.ProvisionedThroughput.WriteCapacityUnits. status: "True" type: ACK.Terminal ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
- Loading branch information
1 parent
ccb4c56
commit b52e89f
Showing
7 changed files
with
205 additions
and
22 deletions.
There are no files selected for viewing
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
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,76 @@ | ||
package table | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
svcsdk "github.com/aws/aws-sdk-go/service/dynamodb" | ||
|
||
"github.com/aws-controllers-k8s/dynamodb-controller/apis/v1alpha1" | ||
) | ||
|
||
func Test_newSDKProvisionedThroughput(t *testing.T) { | ||
type args struct { | ||
pt *v1alpha1.ProvisionedThroughput | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want *svcsdk.ProvisionedThroughput | ||
}{ | ||
{ | ||
name: "provisioned throughput is nil", | ||
args: args{ | ||
pt: nil, | ||
}, | ||
want: nil, | ||
}, | ||
{ | ||
name: "provisioned throughput is not nil, read capacity units is nil", | ||
args: args{ | ||
pt: &v1alpha1.ProvisionedThroughput{ | ||
ReadCapacityUnits: nil, | ||
WriteCapacityUnits: aws.Int64(10), | ||
}, | ||
}, | ||
want: &svcsdk.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(1), | ||
WriteCapacityUnits: aws.Int64(10), | ||
}, | ||
}, | ||
{ | ||
name: "provisioned throughput is not nil, write capacity units is nil", | ||
args: args{ | ||
pt: &v1alpha1.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(10), | ||
WriteCapacityUnits: nil, | ||
}, | ||
}, | ||
want: &svcsdk.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(10), | ||
WriteCapacityUnits: aws.Int64(1), | ||
}, | ||
}, | ||
{ | ||
name: "provisioned throughput is not nil, write and read capacity units are not nil", | ||
args: args{ | ||
pt: &v1alpha1.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(5), | ||
WriteCapacityUnits: aws.Int64(5), | ||
}, | ||
}, | ||
want: &svcsdk.ProvisionedThroughput{ | ||
ReadCapacityUnits: aws.Int64(5), | ||
WriteCapacityUnits: aws.Int64(5), | ||
}, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := newSDKProvisionedThroughput(tt.args.pt); !reflect.DeepEqual(got, tt.want) { | ||
t.Errorf("newSDKProvisionedThroughput() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,19 @@ | ||
# Table used to test GSI creation under on-demand billing mode | ||
apiVersion: dynamodb.services.k8s.aws/v1alpha1 | ||
kind: Table | ||
metadata: | ||
name: $TABLE_NAME | ||
spec: | ||
tableName: $TABLE_NAME | ||
billingMode: PAY_PER_REQUEST | ||
tableClass: STANDARD | ||
attributeDefinitions: | ||
- attributeName: Bill | ||
attributeType: S | ||
- attributeName: Total | ||
attributeType: S | ||
keySchema: | ||
- attributeName: Bill | ||
keyType: HASH | ||
- attributeName: Total | ||
keyType: RANGE |
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
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