Skip to content

Conversation

@embano1
Copy link
Member

@embano1 embano1 commented Feb 8, 2023

feat: Add Archive resource

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

@ack-prow ack-prow bot requested review from RedbackThomson and a-hilaly February 8, 2023 11:01
Copy link
Contributor

@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.

Some teeny suggestions inline but this is great @embano1 thank you! :) Making fantastic progress on this controller.

@embano1
Copy link
Member Author

embano1 commented Feb 8, 2023

Some teeny suggestions inline but this is great @embano1 thank you! :) Making fantastic progress on this controller.

Reviews are a breeze with ya'all! One more (code is ready) and then we're good. Took @a-hilaly more time to write the Python tests than me writing the code, hahahaha...

@embano1
Copy link
Member Author

embano1 commented Feb 9, 2023

@a-hilaly ready for your E2E tests IMHO

@a-hilaly a-hilaly force-pushed the archive branch 4 times, most recently from 7fb9e50 to d8e2e8a Compare February 11, 2023 01:26
@embano1
Copy link
Member Author

embano1 commented Feb 14, 2023

/lgtm

@ack-prow
Copy link

ack-prow bot commented Feb 14, 2023

@embano1: you cannot LGTM your own PR.

In response to this:

/lgtm

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.

Copy link
Contributor

@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 stuff @embano1 and @a-hilaly! Let's get this merged!

Copy link

@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.

Some comments below - especially want to point out we can save a hook for setting synced=true based on status

Comment on lines +1 to +5
if !archiveAvailable(&resource{ko}) {
ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil)
} else {
ackcondition.SetSynced(&resource{ko}, corev1.ConditionTrue, nil, nil)
}

Choose a reason for hiding this comment

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

We already have this type of functionality built into the generator - to use statuses as the indicator for synced. Here is an example of how we do it for the apigatewayv2-controller: https://github.com/aws-controllers-k8s/apigatewayv2-controller/blob/main/generator.yaml#L98-L102

Copy link
Member Author

@embano1 embano1 Feb 15, 2023

Choose a reason for hiding this comment

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

Gotcha. So in all cases where I do not need to pass a message to SetSynced, e.g. ackcondition.SetSynced(&resource{ko}, corev1.ConditionFalse, nil, nil) I will remove this line and let code-gen figure out.

cc/ @a-hilaly should also work in such cases when I need to set other conditions then?

if archiveInTerminalState(latest) {
	msg := "Archive is in '" + *latest.ko.Status.State + "' status"
	ackcondition.SetTerminal(desired, corev1.ConditionTrue, &msg, nil)
	ackcondition.SetSynced(desired, corev1.ConditionTrue, nil, nil) // TODO: remove
	return desired, nil
}

Using this generator.yaml syntax:

    synced:
      when:
        - path: Status.State
          in:
            - ENABLED
            - DISABLED
            - CREATE_FAILED
            - UPDATE_FAILED

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, not sure this one will work then?

if archiveCreating(latest) {
	msg := "Archive is currently being created"
	ackcondition.SetSynced(desired, corev1.ConditionFalse, &msg, nil)
	return desired, requeueWaitUntilCanModify(latest)
}

Would code-gen SYNCED path respect my message here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I get the feeling to keep the logic as is for now as this change would require more testing (incl. E2Es) now to verify all the possible combinations again.

Copy link
Member

Choose a reason for hiding this comment

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

I've noticed that when you use is_synced with other hooks, other components of the reconciliation logic can break. I've seen it happen before with lambda.
So, to keep things simple and speed up development for this controller, I'm cool with merging the current code as is and dealing with the issue in a separate PR for all the CRDs. That way, if the problem pops up with this controller, we'll know how to tackle it without getting bogged down in everything else.

@@ -0,0 +1,19 @@
if archiveInTerminalState(latest) {
msg := "Archive is in '" + *latest.ko.Status.State + "' status"

Choose a reason for hiding this comment

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

nit: Move these messages into constants in hook.go and use fmt.Sprintf

Copy link
Member Author

Choose a reason for hiding this comment

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

Will change. Was following other controllers where this is a pattern and thought this is to avoid fmt allocations :D

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed the wording using fmt.Sprintf but kept it in the same location because there was no more readable way IMHO to express these messages by moving to separate file.

Signed-off-by: Amine Hilaly <hilalyamine@gmail.com>
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you, Michael!
/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 15, 2023
@ack-prow
Copy link

ack-prow bot commented Feb 15, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, embano1, 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-prow ack-prow bot added the approved label Feb 15, 2023
@ack-prow ack-prow bot merged commit 535e3b4 into aws-controllers-k8s:main Feb 15, 2023
@embano1 embano1 deleted the archive branch February 15, 2023 15:46
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.

4 participants