-
Notifications
You must be signed in to change notification settings - Fork 430
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 support for custom egress rules #1299
Add support for custom egress rules #1299
Conversation
eb98beb
to
2a3e814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For what it's worth LGTM
2a3e814
to
49e9bd4
Compare
/hold for squash |
if restoredSecurityRule.Direction == infrav1alpha4.SecurityRuleDirectionInbound { | ||
// For inbound rules, we add back the restored direction if the rule still exists. | ||
for l, dstSecurityRule := range dstSubnet.SecurityGroup.SecurityRules { | ||
if dstSecurityRule.Name == restoredSecurityRule.Name { | ||
dst.Spec.NetworkSpec.Subnets[j].SecurityGroup.SecurityRules[l].Direction = restored.Spec.NetworkSpec.Subnets[i].SecurityGroup.SecurityRules[k].Direction | ||
break | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this logic redundant since inbound rules will get auto converted (now that you've set direction as well in line 263)? IIUC, I think we can simplify this to just handle outbound rules:
if restoredSecurityRule.Direction == infrav1alpha4.SecurityRuleDirectionOutbound {
restoredOutboundRules = append(restoredOutboundRules, restoredSecurityRule)
}
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! I had actually thought of that earlier and thought it would break the Fuzzy test because the directions set in the fuzzer are random strings. But, what I ended up doing is:
if restoredSecurityRule.Direction != infrav1alpha4.SecurityRuleDirectionInbound {
restoredOutboundRules = append(restoredOutboundRules, restoredSecurityRule)
}
Which makes the Fuzzer happy, and, IMO, is more logically correct because the condition for "dropping" a rule in v1alpha4 --> v1alpha3 conversion is "if direction != Inbound" (we only include rules where direction == Ibound). So it makes sense to restore all rules that aren't inbound since they would all have been dropped theoretically speaking. And in the unlikely event that we need to add a new direction in v1alpha4 (for example, "both") we don't need to change the existing conversion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 checking for != inbound
instead of ==outbound
, more future proof!
6a74f88
to
715d5fd
Compare
@CecileRobertMichon: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. |
/hold cancel |
/lgtm |
/assign @devigned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/appove
Looks great! Always love seeing docs updates with a PR 😎.
/approve :D |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon 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 |
What type of PR is this?
What this PR does / why we need it:
ingressRule
tosecurityRules
(note there was a missing s in the field name which represented a list of ingress rules) to be more consistent with Azure naming, and to include rules in both directionsdirection
field toSecurityRule
which can be eitherInbound
orOutbound
. Defaults toInbound
to preserve existing behavior.Feature request came out of this slack thread
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes partly #618
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: