Skip to content

fix(entrypoint): respect operator-provided P2P_ADVERTISE_IP#1111

Open
faisalnugroho wants to merge 1 commit into
base:mainfrom
faisalnugroho:fix/respect-p2p-advertise-ip
Open

fix(entrypoint): respect operator-provided P2P_ADVERTISE_IP#1111
faisalnugroho wants to merge 1 commit into
base:mainfrom
faisalnugroho:fix/respect-p2p-advertise-ip

Conversation

@faisalnugroho
Copy link
Copy Markdown

What

Makes the consensus-entrypoint script respect BASE_NODE_P2P_ADVERTISE_IP if the operator has already set it, instead of always running IP discovery and potentially overriding or failing.

The problem

The script unconditionally calls get_public_ip() (which tries ifconfig.me, api.ipify.org, ipecho.net, v4.ident.me) and exports the result as BASE_NODE_P2P_ADVERTISE_IP, even if the operator already configured this in their env file.

This causes two issues:

  1. Silent override: If an operator sets BASE_NODE_P2P_ADVERTISE_IP to a specific value (e.g., a load balancer IP or a specific interface), the script ignores it and replaces it with whatever the discovery endpoints return.

  2. Hard failure on restricted networks: If all four IP services are unreachable (firewalled host, restricted egress, transient network issues), the script exits with code 8 and the consensus container won't start — even when the operator already provided the correct IP.

The fix

if [[ -n "${BASE_NODE_P2P_ADVERTISE_IP:-}" ]]; then
  echo "Using operator-provided BASE_NODE_P2P_ADVERTISE_IP: $BASE_NODE_P2P_ADVERTISE_IP"
elif PUBLIC_IP=$(get_public_ip); then
  echo "fetched public IP is: $PUBLIC_IP"
  export BASE_NODE_P2P_ADVERTISE_IP=$PUBLIC_IP
else
  echo "Could not retrieve public IP."
  exit 8
fi

Discovery only runs as a fallback when no value is provided. Existing operators who don't set this variable see no behavior change — the script still discovers their IP automatically.

Fixes #1107

The consensus-entrypoint script always calls get_public_ip() and
exports the result as BASE_NODE_P2P_ADVERTISE_IP, overriding any
value the operator already set in their env file.

This is a problem for operators running behind NAT or in restricted
networks where the external IP services are unreachable — the script
exits with code 8 and the node won't start, even though the operator
already knows their public IP and configured it.

Now checks if BASE_NODE_P2P_ADVERTISE_IP is already set before
attempting discovery. If the operator provided a value, it's used
as-is. Discovery only runs as a fallback.

Refs base#1107
@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@faisalnugroho
Copy link
Copy Markdown
Author

Hi! I'd love to get this PR reviewed when you have a moment. This PR addresses respect operator-provided P2P_ADVERTISE_IP. Happy to make any adjustments based on your feedback. Let me know if there's anything I can do to help move this forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

consensus-entrypoint always overrides BASE_NODE_P2P_ADVERTISE_IP and exits if public IP discovery fails

2 participants