-
Notifications
You must be signed in to change notification settings - Fork 373
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
Avoid allocating NPL port if Host Port is defined #2024
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2024 +/- ##
==========================================
+ Coverage 55.20% 62.33% +7.13%
==========================================
Files 268 268
Lines 20237 20241 +4
==========================================
+ Hits 11172 12618 +1446
+ Misses 7873 6315 -1558
- Partials 1192 1308 +116
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
some nits, otherwise LGTM
@@ -370,6 +370,24 @@ func TestPodAddMultiPort(t *testing.T) { | |||
assert.True(t, testData.portTable.RuleExists(defaultPodIP, newPort)) | |||
} | |||
|
|||
// TestPodAdHostPort creates a Pod with host ports and verifies that the Pod's NPL annotation |
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.
typo: s/TestPodAdHostPort/TestPodAddHostPort
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.
Thanks, done
if err != nil { | ||
return fmt.Errorf("failed to add rule for Pod %s: %v", key, err) | ||
if int(cport.HostPort) > 0 { | ||
klog.V(2).Infof("Host Port is defined for Pod, thus extra NPL port is not allocated: %s", key) |
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.
maybe this should be V(4)
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.
Done
if err != nil { | ||
return fmt.Errorf("failed to add rule for Pod %s: %v", key, err) | ||
if int(cport.HostPort) > 0 { | ||
klog.V(2).Infof("Host Port is defined for Pod, thus extra NPL port is not allocated: %s", key) |
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.
maybe a bit more context is needed in the log message (e.g. the container port), since a Pod can have multiple containers, with multiple ports, and hostPort is specific to a given port?
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.
Added container name
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.
/test-all |
Fixes: #1930 |
/test-all |
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.
Approving again after rebase
When Host Port is defined, use same port in NPL annotation, without reserving port from NPL port range. Avoid adding redundant IP table entry in NPL code. Fixes: #1930
/skip-all The diff is the same, but the author information for the commit had to be updated |
When Host Port is defined, use same port in NPL annotation, without
reserving port from NPL port range. Avoid adding redundant IP table
entry in NPL code.