fix: always use ipv4 address from docker kind network#1290
Conversation
Signed-off-by: Eitan Yarmush <eitan.yarmush@solo.io>
There was a problem hiding this comment.
Pull request overview
This PR fixes the extraction of IPv4 addresses from the Docker Kind network in the CI workflow. The issue occurs when Docker Kind networks have both IPv4 and IPv6 gateway configurations, and the previous command would concatenate all gateway values without proper filtering or separation, potentially returning an invalid IP address.
Changes:
- Modified the
docker network inspectcommand to properly filter and extract only IPv4 gateway addresses by adding newline separation, grep filtering for IPv4 pattern, and selecting the first match
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| run: | | ||
| # Get the Kind network gateway IP that pods can reach | ||
| HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{.Gateway}}{{end}}') | ||
| HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1) |
There was a problem hiding this comment.
The command to extract HOST_IP could fail silently if no IPv4 gateway is found. If the grep or head commands return empty results, HOST_IP will be empty, which could cause the e2e tests to fail with unclear error messages. Consider adding validation after this line to ensure HOST_IP is not empty and fail with a clear error message if it is. For example: if [ -z "$HOST_IP" ]; then echo "Failed to detect IPv4 gateway from Kind network" && exit 1; fi
| HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1) | |
| HOST_IP=$(docker network inspect kind -f '{{range .IPAM.Config}}{{if .Gateway}}{{.Gateway}}{{"\n"}}{{end}}{{end}}' | grep -E '^[0-9]+\.' | head -1) | |
| if [ -z "$HOST_IP" ]; then | |
| echo "Failed to detect IPv4 gateway from Kind network" >&2 | |
| exit 1 | |
| fi |
No description provided.