Skip to content

Add Table update code path #30

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

Merged
merged 1 commit into from
Apr 6, 2023

Conversation

a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Feb 11, 2022

Issues:

Description of changes:

  • Add Table custom update code
  • Add Table custom preCompare delta code (to properly compare
    GlobalSecondaryIndexes ,AttributeDefinitions and KeySchemas)
  • Add unit tests for custom compare code for GlobalSecondaryIndexes
  • Make KeySchema an immutable field.
  • Gradually update GlobalSecondaryIndexes when multiple ones are
    update/removed or added.
  • Add custom code to properly populate BillingMode and
    SSESpecification and TableClass
  • Add e2e tests for each new support field update + one test to ensure
    that multi-field updates at once can be properly handled

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-bot ack-bot requested review from jaypipes and vijtrip2 February 11, 2022 17:04
@ack-bot
Copy link
Collaborator

ack-bot commented Feb 11, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@a-hilaly a-hilaly force-pushed the table/updates branch 2 times, most recently from cc124fb to a156e26 Compare February 11, 2022 17:08
Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty ready. Just found some typos in your diffs, and I have a question regarding re-queueing because of the nature of asynchronous updates.

@a-hilaly a-hilaly force-pushed the table/updates branch 2 times, most recently from 1e3c998 to 58f4ec0 Compare February 23, 2022 13:47
@a-hilaly
Copy link
Member Author

/retest all

@ack-bot
Copy link
Collaborator

ack-bot commented Feb 23, 2022

@a-hilaly: The /retest command does not accept any targets.
The following commands are available to trigger jobs:

  • /test dynamodb-kind-e2e
  • /test dynamodb-release-test
  • /test dynamodb-recommended-policy-test
  • /test dynamodb-unit-test

Use /test all to run all jobs.

In response to this:

/retest all

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@a-hilaly
Copy link
Member Author

/test dynamodb-kind-e2e

generator.yaml Outdated
is_ignored: true
KeySchema:
compare:
is_immutable: true
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it necessary to have is_immutable when is_ignored is true? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is_immutable doesn't ignore the field comparison in the generated delta function. The reason I added an is_ignored: true is that the Dynamodb control plane sorts the KeySchema array, and sometimes causes the controller to reconcile for ever since reflect.DeepEqual takes in consideration the order to elements. I added a custom equalKeySchemaArrays function which properly compares the Custom Resource Spec.KeySchema with the sorted one returned by the dynamodb control plane.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-hilaly note that is_immutable is a configuration on the FieldConfig, not the CompareConfig.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@a-hilaly is_immutable is a configuration on the FieldConfig, not the CompareConfig, so this is being ignored entirely...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're I brain lagged here. Addressed

@a-hilaly a-hilaly force-pushed the table/updates branch 2 times, most recently from a95deaf to 5ff5e02 Compare March 3, 2022 14:13
@ack-bot ack-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 1, 2022
@aws-controllers-k8s aws-controllers-k8s deleted a comment from ack-bot Jun 1, 2022
@jaypipes jaypipes removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 1, 2022
@jaypipes
Copy link
Collaborator

jaypipes commented Jun 1, 2022

@a-hilaly you want to rebase this and get it going again?

@jaypipes
Copy link
Collaborator

jaypipes commented Jul 6, 2022

@a-hilaly where are we with this?

@ack-bot
Copy link
Collaborator

ack-bot commented Oct 4, 2022

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle stale

@ack-bot ack-bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 4, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Nov 3, 2022

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/lifecycle rotten

@ack-bot ack-bot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 3, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Dec 3, 2022

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/close

@ack-bot ack-bot closed this Dec 3, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Dec 3, 2022

@ack-bot: Closed this PR.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Provide feedback via https://github.com/aws-controllers-k8s/community.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@a-hilaly
Copy link
Member Author

a-hilaly commented Dec 3, 2022

/reopen
/lifecycle frozen

@ack-bot ack-bot reopened this Dec 3, 2022
@a-hilaly a-hilaly removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Apr 4, 2023
@a-hilaly
Copy link
Member Author

a-hilaly commented Apr 4, 2023

@jaypipes @Julian-Chu rebased and pushed latest changes PTAL

@a-hilaly a-hilaly force-pushed the table/updates branch 8 times, most recently from ffcbe1b to a048d49 Compare April 5, 2023 16:34
@a-hilaly
Copy link
Member Author

a-hilaly commented Apr 5, 2023

/retest

@a-hilaly a-hilaly force-pushed the table/updates branch 2 times, most recently from de4670c to 700ca2a Compare April 5, 2023 18:14
Comment on lines +70 to +79
// equalGlobalSecondaryIndexesArrays returns true if two GlobalSecondaryIndex
// arrays are equal regardless of the order of their elements.
func equalGlobalSecondaryIndexesArrays(
a []*v1alpha1.GlobalSecondaryIndex,
b []*v1alpha1.GlobalSecondaryIndex,
) bool {
added, updated, removed := computeGlobalSecondaryIndexDelta(a, b)
return len(added) == 0 && len(updated) == 0 && len(removed) == 0
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this function being used anywhere?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used in customerPreCompare:

	if len(a.ko.Spec.GlobalSecondaryIndexes) != len(b.ko.Spec.GlobalSecondaryIndexes) {
		delta.Add("Spec.GlobalSecondaryIndexes", a.ko.Spec.GlobalSecondaryIndexes, b.ko.Spec.GlobalSecondaryIndexes)
	} else if a.ko.Spec.GlobalSecondaryIndexes != nil && b.ko.Spec.GlobalSecondaryIndexes != nil {
		if !equalGlobalSecondaryIndexesArrays(a.ko.Spec.GlobalSecondaryIndexes, b.ko.Spec.GlobalSecondaryIndexes) {
			delta.Add("Spec.GlobalSecondaryIndexes", a.ko.Spec.GlobalSecondaryIndexes, b.ko.Spec.GlobalSecondaryIndexes)
		}
	}

"github.com/aws-controllers-k8s/dynamodb-controller/apis/v1alpha1"
)

func computeLocalSecondaryIndexDelta(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are local secondary indexes ever updated?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local secondary indexes can only be set during the CREATE op. They are immutable. computeLocalSecondaryIndexDelta is used to set a terminal condition if users try to modify them

assert self.table_exists(table_name)

# Get CR latest revision
cr = k8s.wait_resource_consumed_by_controller(ref)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above tests are great. I don't see where local secondary indexes are ever tested though? or updated...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reason here. LSIs are only mentioned during the creation, and the API will reject any non-valid LSIs, checking that the table is active is equivalent to checking the LSIs

@a-hilaly a-hilaly requested review from jljaco, RedbackThomson and jaypipes and removed request for vijtrip2 April 5, 2023 21:39
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this @a-hilaly. I'm super excited to finally see this getting merged. 👍

Signed-off-by: Amine Hilaly <[email protected]>
@a-hilaly
Copy link
Member Author

a-hilaly commented Apr 6, 2023

/retest

@jljaco
Copy link

jljaco commented Apr 6, 2023

/lgtm

@ack-prow ack-prow bot assigned jljaco Apr 6, 2023
@ack-prow
Copy link

ack-prow bot commented Apr 6, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, jljaco

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Apr 6, 2023
@ack-prow ack-prow bot merged commit b0b0d59 into aws-controllers-k8s:main Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants