Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1846922: "downloads" pod does not work on the node which is disabled IPv6 #438

Merged
merged 1 commit into from
Jun 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions manifests/07-downloads-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
- '-c'
- |
cat <<EOF >>/tmp/serve.py
import BaseHTTPServer, os, re, signal, SimpleHTTPServer, socket, sys, tarfile, tempfile, threading, time, zipfile
import BaseHTTPServer, errno, os, re, signal, SimpleHTTPServer, socket, sys, tarfile, tempfile, threading, time, zipfile

signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0))

Expand Down Expand Up @@ -116,8 +116,17 @@ spec:
# IPv6 should handle IPv4 passively so long as it is not bound to a
# specific address or set to IPv6_ONLY
# https://stackoverflow.com/questions/25817848/python-3-does-http-server-support-ipv6
addr = ('::', 8080)
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
try:
addr = ('::', 8080)
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
except socket.error as err:
# errno.EAFNOSUPPORT is "socket.error: [Errno 97] Address family not supported by protocol"
# When IPv6 is disabled, socket will bind using IPv4.
if err.errno == errno.EAFNOSUPPORT:
addr = ('', 8080)
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
bysnupy marked this conversation as resolved.
Show resolved Hide resolved
else:
raise
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(addr)
sock.listen(5)
Expand Down