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

Add Table resource custom hooks, terminalCodes and e2e tests #3

Merged
merged 1 commit into from
Jun 14, 2021

Conversation

a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Jun 2, 2021

Part of aws-controllers-k8s/community#803

Description of changes

  • Add custom hooks, terminalCodes, printcomns to Table resource in generator.yaml
  • Add e2e tests for Table create and delete operations

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 June 2, 2021 22:29
// collection that is of type ConditionTypeResourceSynced. If no such condition
// is found, returns nil.
//
// TODO(jaypipes): Move to ACK code-gen templates.
Copy link
Contributor

Choose a reason for hiding this comment

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

?? Are these files not auto generated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not yet, I guess we still need to experiment with other controllers to figure out a general design

/cc @jaypipes

Copy link
Collaborator

Choose a reason for hiding this comment

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

@RedbackThomson yeah, eventually I'd like to generate functions like these and/or move into ACK runtime. I added these for the mq-controller:

https://github.com/aws-controllers-k8s/mq-controller/blob/main/pkg/resource/broker/conditions.go
https://github.com/aws-controllers-k8s/mq-controller/blob/main/pkg/resource/broker/hooks.go

and then adapted them for the RDS controller:

https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_instance/conditions.go
https://github.com/aws-controllers-k8s/rds-controller/blob/main/pkg/resource/db_instance/hooks.go

I use the service controllers as a bit of a laboratory for experimentation in this way while I figure out what works as a standard.

Copy link
Member

Choose a reason for hiding this comment

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

3 controllers using same code, good time to move ?
aws-controllers-k8s/community#806

Copy link
Collaborator

Choose a reason for hiding this comment

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

3 controllers using same code, good time to move ?
aws-controllers-k8s/community#806

after I get those logging changes pushed up, yeah...

pkg/resource/table/hooks.go Outdated Show resolved Hide resolved
var (
requeueWaitWhileDeleting = ackrequeue.NeededAfter(
ErrTableDeleting,
5*time.Second,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an arbitrary amount? I'd like to see requeue times standardised over all controllers, perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not arbitrary, just remarked that tables are created super fast. The default value is 30seconds https://github.com/aws-controllers-k8s/runtime/blob/main/pkg/requeue/requeue.go#L20-L22

pkg/resource/table/hooks.go Outdated Show resolved Hide resolved
Comment on lines 1 to 3
if tableDeleting(r) {
return requeueWaitWhileDeleting
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Table could be in deleting state before calling delete? I imagine if someone messed with it in the console (outside ACK)?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yup - not sure if this is something we should consider at this stage.

@RedbackThomson
Copy link
Contributor

/ok-to-test
/test dynamodb-unit-test
/test dynamodb-kind-e2e

@ack-bot ack-bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jun 2, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Jun 3, 2021

@a-hilaly: The specified target(s) for /test were not found.
The following commands are available to trigger jobs:

  • /test dynamodb-unit-test

In response to this:

/test dynamodb-pre-submit

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 Jun 3, 2021

/test dynamodb-kind-e2e

@ack-bot
Copy link
Collaborator

ack-bot commented Jun 3, 2021

@a-hilaly: The specified target(s) for /test were not found.
The following commands are available to trigger jobs:

  • /test dynamodb-unit-test

In response to this:

/test dynamodb-kind-e2e

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 Jun 3, 2021

@RedbackThomson i'm not able to run kind-e2e tests, i can see that we already have generated prow jobs for dynamodb. PTAL

@a-hilaly
Copy link
Member Author

a-hilaly commented Jun 3, 2021

/test dynamodb-unit-test

@a-hilaly
Copy link
Member Author

a-hilaly commented Jun 3, 2021

/test dynamodb-kind-e2e

@ack-bot
Copy link
Collaborator

ack-bot commented Jun 3, 2021

@a-hilaly: The specified target(s) for /test were not found.
The following commands are available to trigger jobs:

  • /test dynamodb-unit-test

In response to this:

/test dynamodb-kind-e2e

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.

pkg/resource/table/conditions.go Outdated Show resolved Hide resolved
pkg/resource/table/custom_update_api.go Outdated Show resolved Hide resolved
Comment on lines +1 to +6
if isTableCreating(&resource{ko}) {
return &resource{ko}, requeueWaitWhileCreating
}
if isTableUpdating(&resource{ko}) {
return &resource{ko}, requeueWaitWhileUpdating
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we need the above code hooks in the sdkReadOne post-set-output code paths?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes tables needs few seconds to get created. re-queuing here is needed to sync the .status.TableStatus field.

Copy link
Member Author

Choose a reason for hiding this comment

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

Here what i get when i create a table and wait for few seconds

k get tables
NAME   TABLENAME   TABLESTATUS
tb1    tb1         CREATING
aws dynamodb describe-table --table-name tb1 | jq
{
    ...
    "TableStatus": "ACTIVE",
    ...
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is fixing a very similar issue to what @phanimullapudi was seeing in mq controller aws-controllers-k8s/community#831

Copy link
Collaborator

Choose a reason for hiding this comment

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

for reviewers: @a-hilaly and I walked through the code and Amine patiently waited for me to understand he was totally correct. :)

apis/v1alpha1/table.go Outdated Show resolved Hide resolved
test/e2e/resources/table.yaml Outdated Show resolved Hide resolved
@RedbackThomson
Copy link
Contributor

/test dynamodb-kind-e2e

@a-hilaly
Copy link
Member Author

a-hilaly commented Jun 4, 2021

/test dynamodb-kind-e2e

1 similar comment
@RedbackThomson
Copy link
Contributor

/test dynamodb-kind-e2e

@a-hilaly a-hilaly changed the title Add Table resource custom hooks, terminalCodes, printcolumns and e2e tests Add Table resource custom hooks, terminalCodes and e2e tests Jun 8, 2021
@a-hilaly
Copy link
Member Author

a-hilaly commented Jun 8, 2021

/test dynamodb-kind-e2e

@a-hilaly a-hilaly requested a review from RedbackThomson June 8, 2021 15:26
- Add custom hooks and terminalCodes
- Regenerate `Table` resource
- Add e2e tests for create and delete operations
@a-hilaly
Copy link
Member Author

a-hilaly commented Jun 9, 2021

/test dynamodb-kind-e2e

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.

👍

Comment on lines +1 to +6
if isTableCreating(&resource{ko}) {
return &resource{ko}, requeueWaitWhileCreating
}
if isTableUpdating(&resource{ko}) {
return &resource{ko}, requeueWaitWhileUpdating
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

for reviewers: @a-hilaly and I walked through the code and Amine patiently waited for me to understand he was totally correct. :)

@jaypipes
Copy link
Collaborator

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 14, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Jun 14, 2021

[APPROVALNOTIFIER] This PR is APPROVED

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

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-bot ack-bot merged commit e786654 into aws-controllers-k8s:main Jun 14, 2021
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants