Add ReusePort config to confighttp#14058
Add ReusePort config to confighttp#14058sinkingpoint wants to merge 26 commits intoopen-telemetry:mainfrom
Conversation
636ae93 to
344b948
Compare
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (66.66%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #14058 +/- ##
==========================================
- Coverage 91.31% 91.29% -0.03%
==========================================
Files 699 700 +1
Lines 44939 44956 +17
==========================================
+ Hits 41036 41041 +5
- Misses 2759 2766 +7
- Partials 1144 1149 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
344b948 to
bac556b
Compare
|
Contrib test failure fixed here: open-telemetry/opentelemetry-collector-contrib#43681 |
Without a valid `runCtx`, anything that attempts to use the context segfaults. In open-telemetry/opentelemetry-collector#14058 I am using the context, so this test borks. This adds the runCtx to fix it. Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Without a valid `runCtx`, anything that attempts to use the context segfaults. In open-telemetry/opentelemetry-collector#14058 I am using the context, so this test borks. This adds the runCtx to fix it. Signed-off-by: sinkingpoint <colin@quirl.co.nz>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Without a valid `runCtx`, anything that attempts to use the context segfaults. In open-telemetry/opentelemetry-collector#14058 I am using the context, so this test borks. This adds the runCtx to fix it. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue open-telemetry/opentelemetry-collector#14058 <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: sinkingpoint <colin@quirl.co.nz>
|
Should we have this for configgrpc too? And non-HTTP/gRPC? I'm wondering if we should make a breaking change to confighttp.ServerConfig to use confignet.AddrConfig, similar to configgrpc: Then we could add ReusePort to confignet.AddrConfig and have it in one place. (Not necessarily all in this PR, just thinking out loud about how to generalise this change.) |
I was going to do those in a separate PR, but rely on "A little copying is better than a little dependency" and just copy the same config changes across. Breaking changes scare me |
|
@sinkingpoint 👍 that seems fine, we can always make a breaking change independently if desired. |
bac556b to
8f6079d
Compare
|
Actually, looking at it a bit more: configgrpc provides |
|
|
||
| func TestServerReusePort(t *testing.T) { | ||
| if runtime.GOOS == "windows" { | ||
| t.Skip("skipping test: SO_REUSEPORT is not supported on windows") |
There was a problem hiding this comment.
Could you add a test checking that we do get an error when trying to use SoReuse on windows?
8f6079d to
3d1484b
Compare
This adds in a new field, `ReusePort` that, if set, sets the SO_REUSEPORT socket option on the listener port. If we're on non unix, this errors out instead as AFAIK SO_REUSEPORT isn't available. Cursory testing says that SO_REUSEADDR _might_ work, but I don't have a windows machine to test on. Signed-off-by: sinkingpoint <colin@quirl.co.nz>
3d1484b to
e063074
Compare
|
Could you avoid force-pushing? That breaks the GitHub review interface. |
|
Apologies 😬 I think I've fixed it up now anyway |
Where did you see that being done? I found the stef receiver is not using confighttp, for example: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/e3f1205a034ff05c1c31e1e1b84a8bf735563d91/receiver/stefreceiver/stef.go#L57-L77 |
|
Oh hrm.. I checked several, like https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/skywalkingreceiver/skywalking_receiver.go#L144 , but you're right - missed the ones that use confignet. Want me to update that here? Or put in a seperate PR? |
|
Ah I see. That receiver probably should be updated, but I digress A separate PR sounds good to me, maybe change the description so the issue doesn't get closed when this PR is merged |
As per PR comments, this moves things around so that listen_config_other becomes listen_config_unix, and listen_config_windows becomes listen_config_other, with appropriate build gating. Signed-off-by: sinkingpoint <colin@quirl.co.nz>
…tor into sinkingpoint/so-reuse-port
|
@bogdandrutu @dmitryax Does this look OK now? |
evan-bradley
left a comment
There was a problem hiding this comment.
Thanks for your patience with the long review cycle @sinkingpoint.
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
…tor into sinkingpoint/so-reuse-port
Signed-off-by: sinkingpoint <colin@quirl.co.nz>
Signed-off-by: sinkingpoint <colin@quirl.co.nz>
This changes the if runtime.GOOS == "windows" { to properly match the
updated build tags
Signed-off-by: sinkingpoint <colin@quirl.co.nz>
|
@evan-bradley Can I get another look from you when you get a sec? |
evan-bradley
left a comment
There was a problem hiding this comment.
Thanks @sinkingpoint. I'd like to get approvals from a few other approvers/maintainers since this is a stable module and we can't revert this change once it's released.
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
|
@sinkingpoint I hope you don't mind, I took the liberty of addressing @evan-bradley's comments and pushing to your branch |
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
Description
This adds in a new field,
ReusePortthat, if set, sets the SO_REUSEPORT socket option on the listener port. If we're on non unix, this errors out instead as AFAIK SO_REUSEPORT isn't available. Cursory googling says that SO_REUSEADDR might work, but I don't have a windows machine to test on.Link to tracking issue
#14046
Testing
We add a new test,
TestServerReusePortwhich checks the behaviour of both setting and unsetting the ReusePort config with the expectation of an error if it isn't set and it not erroring when binding twice to the same port