Commit f3d022d
authored
fix a duplicated ingress port issue (#69)
<!-- Thanks for sending a pull request! Here are some tips for you:
1. Ensure you have added the unit tests for your changes.
2. Ensure you have included output of manual testing done in the Testing
section.
3. Ensure number of lines of code for new or existing methods are within
the reasonable limit.
4. Ensure your change works on existing clusters after upgrade.
-->
**What type of PR is this?**
<!--
Add one of the following:
bug
cleanup
documentation
feature
-->
bug
**Which issue does this PR fix**:
This PR is fixing the duplicated ingress ports issue when scale dst
pods.
**What does this PR do / Why do we need it**:
The bug can cause duplicated ports breaching the limit and fails ports
beyond the limit.
**If an issue # is not available please add steps to reproduce and the
controller logs**:
1, create two deployments (simple nginx) with replicas = 1
2, create NPs for one deployment pods with ingress from the other
deployment pods
3, scale the dst pods to a larger number
4, print out the policyendpoint and check if the ingress has duplicated
ports with a same cidr in one entry
**Testing done on this change**:
<!--
output of manual testing/integration tests results and also attach logs
showing the fix being resolved
-->
Before this fix
```
ingress:
- cidr: 192.168.163.178
ports:
- port: 80
protocol: TCP
- port: 80
protocol: TCP
- port: 80
protocol: TCP
podIsolation:
- Ingress
- Egress
```
after this fix
```
ingress:
- cidr: 192.168.51.76
ports:
- port: 80
protocol: TCP
podIsolation:
- Ingress
- Egress
```
with more than one port
```
ingress:
- cidr: 192.168.7.80
ports:
- port: 80
protocol: TCP
- port: 8080
protocol: TCP
podIsolation:
- Ingress
- Egress
```
Updated Unit Tests
Before the fix
```
Error Trace: /local/home/zhuhz/go/src/amazon-network-policy-controller-k8s/pkg/resolvers/endpoints_test.go:872
Error: Not equal:
expected: 1
actual : 2
Test: TestEndpointsResolver_ResolveNetworkPeers
```
After the fix
```
=== RUN TestEndpointsResolver_ResolveNetworkPeers
--- PASS: TestEndpointsResolver_ResolveNetworkPeers (0.00s)
PASS
ok github.com/aws/amazon-network-policy-controller-k8s/pkg/resolvers (cached)
```
**Automation added to e2e**:
<!--
List the e2e tests you added as part of this PR.
If no, create an issue with enhancement/testing label
-->
**Will this PR introduce any new dependencies?**:
<!--
e.g. new K8s API
-->
**Will this break upgrades or downgrades. Has updating a running cluster
been tested?**:
**Does this PR introduce any user-facing change?**:
<!--
If yes, a release note update is required:
Enter your extended release note in the block below. If the PR requires
additional actions
from users switching to the new release, include the string "action
required".
-->
```release-note
```
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.2 files changed
+62
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
216 | 220 | | |
217 | 221 | | |
218 | 222 | | |
219 | | - | |
| 223 | + | |
220 | 224 | | |
221 | 225 | | |
222 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
223 | 231 | | |
224 | 232 | | |
225 | 233 | | |
| |||
455 | 463 | | |
456 | 464 | | |
457 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
668 | 668 | | |
669 | 669 | | |
670 | 670 | | |
671 | | - | |
| 671 | + | |
672 | 672 | | |
673 | 673 | | |
674 | 674 | | |
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
694 | 717 | | |
695 | 718 | | |
696 | 719 | | |
| |||
775 | 798 | | |
776 | 799 | | |
777 | 800 | | |
778 | | - | |
| 801 | + | |
779 | 802 | | |
780 | 803 | | |
781 | 804 | | |
| |||
811 | 834 | | |
812 | 835 | | |
813 | 836 | | |
814 | | - | |
| 837 | + | |
815 | 838 | | |
816 | 839 | | |
817 | 840 | | |
| |||
845 | 868 | | |
846 | 869 | | |
847 | 870 | | |
848 | | - | |
| 871 | + | |
| 872 | + | |
849 | 873 | | |
850 | 874 | | |
851 | 875 | | |
852 | | - | |
853 | | - | |
| 876 | + | |
| 877 | + | |
854 | 878 | | |
855 | 879 | | |
856 | 880 | | |
| |||
0 commit comments