Skip to content

feat(NetworkACL): Filter Default Rules from Delta #252

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 2 commits into from
Mar 27, 2025

Conversation

rushmash91
Copy link
Member

@rushmash91 rushmash91 commented Mar 25, 2025

fixes aws-controllers-k8s/community#2374

Description of changes:

  • Add a precompare hook for Delta to filter out default rules from desired and latest objects
  • Move create resource logic to createEntries

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 michaelhtm March 25, 2025 22:20
@ack-prow ack-prow bot added the approved label Mar 25, 2025
@rushmash91 rushmash91 force-pushed the default-nacl branch 3 times, most recently from ddd6d44 to acb2e30 Compare March 25, 2025 22:29
@rushmash91
Copy link
Member Author

/retest

1 similar comment
@rushmash91
Copy link
Member Author

/retest

Copy link
Member

@michaelhtm michaelhtm left a comment

Choose a reason for hiding this comment

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

👍

Copy link

ack-prow bot commented Mar 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelhtm, rushmash91

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:
  • OWNERS [michaelhtm,rushmash91]

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

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.

👍

) error {
if r.ko.Spec.Entries != nil {
if err := rm.syncEntries(ctx, r, nil); err != nil {
if desired.ko.Spec.Entries != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if desired.ko.Spec.Entries != nil {
if len(desired.ko.Spec.Entries) > 0 {

Comment on lines +608 to +602
func customPreCompare(
delta *ackcompare.Delta,
a *resource,
b *resource,
) {
a.ko.Spec.Entries = filterDefaultRules(a.ko.Spec.Entries)
b.ko.Spec.Entries = filterDefaultRules(b.ko.Spec.Entries)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why do we filter rules both in preCompare and in syncEntries?

Copy link
Member Author

@rushmash91 rushmash91 Mar 26, 2025

Choose a reason for hiding this comment

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

it was only needed during create, removing from sync and moving create to createEntries

Comment on lines 371 to 374
// During create latest is nil, just add the entries when sync is called via createEntries
if latest == nil {
toAdd = desired.ko.Spec.Entries
}
Copy link
Member

Choose a reason for hiding this comment

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

why at this level of the code? also toAdd is getting elements in L344. Maybe we need an if/else to make sure we're not executing unecessary logic?

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'll just move out the creation from sync, don't think its a create idea.

Comment on lines 94 to 98
if len(filteredEntries) > 0 {
for _, entry := range filteredEntries {
if err := rm.createEntry(ctx, desired, *entry); err != nil {
return err
}
}

}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if len(filteredEntries) > 0 {
for _, entry := range filteredEntries {
if err := rm.createEntry(ctx, desired, *entry); err != nil {
return err
}
}
}
for _, entry := range filteredEntries {
if err := rm.createEntry(ctx, desired, *entry); err != nil {
return err
}
}

@rushmash91
Copy link
Member Author

/retest

Copy link

ack-prow bot commented Mar 27, 2025

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

Test name Commit Details Required Rerun command
ec2-verify-attribution ef2640b link false /test ec2-verify-attribution
ec2-kind-e2e ef2640b link true /test ec2-kind-e2e

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.

@a-hilaly a-hilaly changed the title Filter Default Rules from Delta feat(NetworkACL): Filter Default Rules from Delta Mar 27, 2025
@rushmash91 rushmash91 merged commit 0e08341 into aws-controllers-k8s:main Mar 27, 2025
4 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NACL: Rules are not created properly
3 participants