config: Add warning if EndpointAddress and NetAddress ports are equal#6006
Merged
gmalouf merged 4 commits intoalgorand:masterfrom Jun 12, 2024
Merged
config: Add warning if EndpointAddress and NetAddress ports are equal#6006gmalouf merged 4 commits intoalgorand:masterfrom
gmalouf merged 4 commits intoalgorand:masterfrom
Conversation
Contributor
|
Please also rebase on top of master. |
83fa1b9 to
790fae0
Compare
9d2f5c8 to
020e801
Compare
Contributor
Author
|
@algorandskiy Refactored the code based on your feedback. Tests are failing, but I don't have insights into why as CircleCI seems to be gated and with no public access. Would you be able to check? |
algorandskiy
approved these changes
Jun 12, 2024
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6006 +/- ##
=======================================
Coverage 55.88% 55.88%
=======================================
Files 482 482
Lines 68447 68463 +16
=======================================
+ Hits 38252 38261 +9
- Misses 27594 27607 +13
+ Partials 2601 2595 -6 ☔ View full report in Codecov by Sentry. |
gmalouf
approved these changes
Jun 12, 2024
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.
Summary
Log warning if EndpointAddress and NetAddress has identical ports.
This can happen in a scenario where NetAddress is set to listen to port 0.0.0.0:8080, and where no EndpointAddress is defined. In that case NetAddress is set to listen to 127.0.0.1:0 (port 0 being random OS assigned port in a specific range), however the
makeListenerfunc indaemon/algod/server.gohas logic that sets the port to be port 8080 in case port 0 is provided (https://github.com/algorand/go-algorand/blob/master/daemon/algod/server.go#L256).This will result in the following:
If you are like me this can cause a lot of confusion as paths and service responses now will default to standard 404 messages and payloads.
The proposed change will add a log warning if the two ports matches up.
Reasoning for a warning is that changing existing logic where port 0 implicitly means port 8080 may be a breaking change for anyone depending on the existing behavior, and where in some cases it could be assumed that people find this desirable (even if not following convention of using port 0).
Note that this PR does not change behavior regarding which address to bind to, meaning that a configuration such as the one below will continue to be a fatal error.
Test Plan
"NetAddress": "0.0.0.0:8080",to config.json. Warning should be logged."EndpointAddress": "0.0.0.0:8080", "NetAddress": "0.0.0.0:8081",. No warning should be logged."EndpointAddress": "127.0.0.1:8080", "NetAddress": "[::1]:8080",. Warning should be logged.