Nth attempt to resolve port collisions once-and-for-all#9850
Open
kaleb-himes wants to merge 1 commit intowolfSSL:masterfrom
Open
Nth attempt to resolve port collisions once-and-for-all#9850kaleb-himes wants to merge 1 commit intowolfSSL:masterfrom
kaleb-himes wants to merge 1 commit intowolfSSL:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
I've been seeing port collisions in Jenkins again in spite of bwrap having worked for us for many years now. This is an attempt to further avoid the probability of port collisions in the make check scripts that use random port generation.
This solution introduces the concept of "remembering ports assigned" in addition to checking "already assigned ports on the system".
Testing:
Many many cycles running openssl/ocsp scripts in tight loops. Probability of collisions in the worst case script (openssl) is estimated to have been:
1 collision per 292 runs of the openssl script (we test more runs than that in each PR due to the many config options)
With this proposed change the probability is estimated to drop from 0.343% to 0% inside a single run of a script and ~0.006% intra-script (multiple copies of the script executing on the same machine). The new logic checks for already-handed-out ports on the machine but there is a small probability remaining that port is free when checked and no longer free by the time it gets used if another script grabs the same one.
I left the test scripts running all weekend without the fix and with the fix.
In the shell running the old code we saw 52 collisions over the course of 48 hours.
In the shell running with these changes in place we saw 0 collisions over the course of 48 hours.
I also created two "simulation" scripts to run many more tests in 10 minutes intervals then can be achieved with the actual live TLS connections in 48 hours and these are those results:
OLD SOLUTION w/ bwrap in place, using /dev/random for port values with no memory of assigned ports:
NEW SOLUTION w/ bwrap in place, using /dev/random for port values and having memory of assigned ports:
Checklist