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

Support security groups with cyclic references #213

Conversation

TiberiuGC
Copy link
Member

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 Allow skipping state validations for resources that support cyclic references 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.

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.

Great work on this Tibi, thank you!
I left a few comments/questions below

helm/values.yaml Outdated
Comment on lines 160 to 161
featureGates: {}
# featureGate1: true
# featureGate2: false
featureGates:
CARMv2: false
Copy link
Member

Choose a reason for hiding this comment

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

I think we need #214 before merging this

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed

ec2_validator.assert_security_group(resource_id_1, exists=False)
ec2_validator.assert_security_group(resource_id_2, exists=False)
ec2_validator.assert_security_group(resource_id_3, exists=False)
Copy link
Member

Choose a reason for hiding this comment

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

Can we also assert the the kubernetes resources are marked as ACKSynced=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.

you highlighted the section after the resources are being deleted, does the comment still apply?

when the resources are created the assertion exists

image

Copy link
Member

Choose a reason for hiding this comment

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

Ohhh correct, my eyes were looking for this call https://github.com/aws-controllers-k8s/test-infra/blob/main/src/acktest/k8s/condition.py#L69 - but your appraoch is correct as well

Comment on lines +1 to +5
sgCpy := r.ko.DeepCopy()
sgCpy.Spec.IngressRules = nil
sgCpy.Spec.EgressRules = nil
if err := rm.syncSGRules(ctx, &resource{ko: sgCpy}, r); err != nil {
return nil, err
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to detach the rules before SG deletion?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, otherwise we constantly run into a circular DependencyViolation error.

@TiberiuGC TiberiuGC force-pushed the improvement/security-groups-with-cyclic-refs branch from 3c79f32 to 2aac5ea Compare August 29, 2024 20:24
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.

Great stuff! 🎉
/lgtm

@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
@ack-prow ack-prow bot merged commit 6d61fbc into aws-controllers-k8s:main Aug 29, 2024
6 checks passed
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