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

fix ingress dest ports issue #58

Merged
merged 4 commits into from
Dec 7, 2023
Merged

fix ingress dest ports issue #58

merged 4 commits into from
Dec 7, 2023

Conversation

haouc
Copy link
Contributor

@haouc haouc commented Dec 1, 2023

What type of PR is this?
Fixing an issue for ingress port in policyendpoints

bug
Which issue does this PR fix:
#52

What does this PR do / Why do we need it:
The controller shouldn't use src port in PE's ingress endpoint.

If an issue # is not available please add steps to reproduce and the controller logs:

Testing done on this change:

Automation added to e2e:

Will this PR introduce any new dependencies?:

Will this break upgrades or downgrades. Has updating a running cluster been tested?:

Does this PR introduce any user-facing change?:


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

@haouc haouc requested a review from a team as a code owner December 1, 2023 21:05
@achevuru
Copy link
Contributor

achevuru commented Dec 4, 2023

lgtm. Maybe, let's add an UT case for this scenario here - https://github.com/aws/amazon-network-policy-controller-k8s/blob/main/pkg/resolvers/endpoints_test.go#L185

@haouc
Copy link
Contributor Author

haouc commented Dec 6, 2023

lgtm. Maybe, let's add an UT case for this scenario here - https://github.com/aws/amazon-network-policy-controller-k8s/blob/main/pkg/resolvers/endpoints_test.go#L185

Added unit tests and make some minor changes to the endpoints.go file as well.

achevuru
achevuru previously approved these changes Dec 6, 2023
r.logger.V(1).Info("Namespaces for network peers resolution", "list", namespaces, "policy", k8s.NamespacedName(policy))

var portsToApply []policyinfo.Port
// populate the policy applied targets' ports
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Please add few comments as to why this is done only for ingress...

for _, ns := range namespaces {
networkPeers = append(networkPeers, r.getMatchingPodAddresses(ctx, peer.PodSelector, ns, ports)...)
networkPeers = append(networkPeers, r.getMatchingPodAddresses(ctx, peer.PodSelector, ns, portsToApply, ports, policyType)...)
Copy link
Contributor

@jayanthvn jayanthvn Dec 6, 2023

Choose a reason for hiding this comment

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

If portsToApply is nil say for instance we hit the "Unable to List Pods" then why do even we need to go in the loop? Because eventually portList := r.getPortList(pod, ports) would be 0 and we just continue to the next pod isn't it? And we will loop thru all pods and just continue since ports are nil...Am I missing anything?

@haouc
Copy link
Contributor Author

haouc commented Dec 7, 2023

go vulns check failed on go version update. we will do a follow-up to update go version in action and also build script.

@haouc haouc merged commit d131836 into aws:main Dec 7, 2023
3 of 4 checks passed
@haouc haouc deleted the port-issue branch December 7, 2023 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants