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

Allow skipping state validations for resources that support cyclic references #544

Merged

Conversation

TiberiuGC
Copy link
Member

@TiberiuGC TiberiuGC commented Aug 19, 2024

Issue #, if available: aws-controllers-k8s/community#2119

Description of changes:

Introducing a new field config.Resources.Fields.References.SkipResourceStateValidations , that, if set to true, skips state validations performed during ResolveReferences step, that ensure the referenced resource exists in AWS and is synced. This is needed when multiple resources reference each other in a cyclic manner, as otherwise they will never sync due to circular ResourceReferenceNotSynced errors.

N.B. when setting this field to true, the developer is responsible to amend the sdkCreate and/or sdkUpdate functions of the referencing resource, in order to correctly wait on the desired state of the referenced resource, before SDK API calls that require the latter. In the future, we could consider generating this logic, but for now this is a niche use case.

see (example will be available when this PR is merged): https://github.com/aws-controllers-k8s/ec2-controller/blob/main/pkg/resource/security_group/sdk.go

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 a-hilaly and jlbutler August 19, 2024 13:55
@a-hilaly
Copy link
Member

/retest

@TiberiuGC TiberiuGC marked this pull request as draft August 20, 2024 11:33
@ack-prow ack-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2024
@TiberiuGC TiberiuGC force-pushed the feature/allow-cyclic-references branch from 62d1932 to e66e2f7 Compare August 29, 2024 05:31
@TiberiuGC TiberiuGC changed the title Allow cyclic references to sync successfully Allow skipping state validations for resources that support cyclic references Aug 29, 2024
@TiberiuGC TiberiuGC force-pushed the feature/allow-cyclic-references branch from e66e2f7 to 390d759 Compare August 29, 2024 05:39
@TiberiuGC TiberiuGC changed the title Allow skipping state validations for resources that support cyclic references Allow skipping state validations for resources that allow cyclic references Aug 29, 2024
@TiberiuGC TiberiuGC changed the title Allow skipping state validations for resources that allow cyclic references Allow skipping state validations for resources that support cyclic references Aug 29, 2024
@TiberiuGC TiberiuGC force-pushed the feature/allow-cyclic-references branch from 390d759 to 8213a7d Compare August 29, 2024 05:48
@a-hilaly
Copy link
Member

/retest

@a-hilaly
Copy link
Member

flaky eks tests
/retest

@TiberiuGC TiberiuGC marked this pull request as ready for review August 29, 2024 07:26
@ack-prow ack-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 29, 2024
Copy link

ack-prow bot commented Aug 29, 2024

@TiberiuGC: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
s3-olm-test 8213a7d link false /test s3-olm-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

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.

👍 👍
/lgtm

Comment on lines +357 to +370
// SkipResourceStateValidations if true, skips state validations performed during
// ResolveReferences step, that ensure the referenced resource exists in AWS and is synced.
// This is needed when multiple resources reference each other in a cyclic manner,
// as otherwise they will never sync due to circular ResourceReferenceNotSynced errors.
//
// see: https://github.com/aws-controllers-k8s/community/issues/2119
//
// N.B. when setting this field to true, the developer is responsible to amend the sdkCreate
// and/or sdkUpdate functions of the referencing resource, in order to correctly wait on the
// desired state of the referenced resource, before SDK API calls that require the latter.
// In the future, we could consider generating this logic, but for now this is a niche use case.
//
// see: https://github.com/aws-controllers-k8s/ec2-controller/blob/main/pkg/resource/security_group/sdk.go
SkipResourceStateValidations bool `json:"skip_resource_state_validations"`
Copy link
Member

Choose a reason for hiding this comment

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

Great explanation!

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 29, 2024
Copy link

ack-prow bot commented Aug 29, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, TiberiuGC

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 Aug 29, 2024
@TiberiuGC TiberiuGC merged commit 0e5ae97 into aws-controllers-k8s:main Aug 29, 2024
4 of 18 checks passed
ack-prow bot pushed a commit to aws-controllers-k8s/ec2-controller that referenced this pull request Aug 29, 2024
Issue #, if available: aws-controllers-k8s/community#2119

Description of changes:

Cyclic references support is done via. the following workflow:
1. skip runtime reference state validations by setting `SecurityGroup.Rules.UserIDGroupPairs.GroupID.skip_resource_state_validations: true`  (see aws-controllers-k8s/code-generator#544). This allows runtime to proceed with the `sdkCreate` call.
2. inside `sdkCreate` and `sdkUpdate` add custom logic that checks whether referenced security groups are being created on AWS end (i.e. `groupID != nil`). If the checks succeed, move forward with syncing SG rules. Otherwise, requeue and wait for all referenced SGs to be created. 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
nnbu pushed a commit to nnbu/ack-ec2-controller that referenced this pull request Sep 18, 2024
Issue #, if available: aws-controllers-k8s/community#2119

Description of changes:

Cyclic references support is done via. the following workflow:
1. skip runtime reference state validations by setting `SecurityGroup.Rules.UserIDGroupPairs.GroupID.skip_resource_state_validations: true`  (see aws-controllers-k8s/code-generator#544). This allows runtime to proceed with the `sdkCreate` call.
2. inside `sdkCreate` and `sdkUpdate` add custom logic that checks whether referenced security groups are being created on AWS end (i.e. `groupID != nil`). If the checks succeed, move forward with syncing SG rules. Otherwise, requeue and wait for all referenced SGs to be created. 

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
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.

2 participants