Skip to content

Commit

Permalink
Add diagnostic for IPv6 support (see #357)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrehn committed Jun 21, 2024
1 parent f495b45 commit 070dd3c
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/ue4docker/diagnostics/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .diagnostic_all import allDiagnostics
from .diagnostic_8gig import diagnostic8Gig
from .diagnostic_20gig import diagnostic20Gig
from .diagnostic_ipv6 import diagnosticIPv6
from .diagnostic_network import diagnosticNetwork
28 changes: 15 additions & 13 deletions src/ue4docker/diagnostics/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _printAndRun(self, logger, prefix, command, check=False):
logger.info(prefix + "Run: {}".format(command), False)
subprocess.run(command, check=check)

def _checkPlatformMistmatch(self, logger, containerPlatform):
def _checkPlatformMistmatch(self, logger, containerPlatform, linuxFlagSupported):
"""
Verifies that the user isn't trying to test Windows containers under Windows 10 when in Linux container mode (or vice versa)
"""
Expand All @@ -51,12 +51,13 @@ def _checkPlatformMistmatch(self, logger, containerPlatform):
),
False,
)
logger.error(
"[{}] Use the --linux flag if you want to test Linux containers instead.".format(
prefix
),
False,
)
if linuxFlagSupported:
logger.error(
"[{}] Use the --linux flag if you want to test Linux containers instead.".format(
prefix
),
False,
)
raise RuntimeError
elif containerPlatform == "linux" and dockerPlatform == "windows":
logger.error(
Expand All @@ -65,12 +66,13 @@ def _checkPlatformMistmatch(self, logger, containerPlatform):
),
False,
)
logger.error(
"[{}] Remove the --linux flag if you want to test Windows containers instead.".format(
prefix
),
False,
)
if linuxFlagSupported:
logger.error(
"[{}] Remove the --linux flag if you want to test Windows containers instead.".format(
prefix
),
False,
)
raise RuntimeError

def _generateWindowsBuildArgs(
Expand Down
2 changes: 1 addition & 1 deletion src/ue4docker/diagnostics/diagnostic_8gig.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run(self, logger, args=[]):

# Verify that the user isn't trying to test Windows containers under Windows 10 when in Linux container mode (or vice versa)
try:
self._checkPlatformMistmatch(logger, containerPlatform)
self._checkPlatformMistmatch(logger, containerPlatform, True)
except RuntimeError:
return False

Expand Down
2 changes: 2 additions & 0 deletions src/ue4docker/diagnostics/diagnostic_all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .base import DiagnosticBase
from .diagnostic_8gig import diagnostic8Gig
from .diagnostic_20gig import diagnostic20Gig
from .diagnostic_ipv6 import diagnosticIPv6
from .diagnostic_network import diagnosticNetwork


Expand All @@ -27,6 +28,7 @@ def run(self, logger, args=[]):
diagnostics = [
diagnostic8Gig(),
diagnostic20Gig(),
diagnosticIPv6(),
diagnosticNetwork(),
]
for index, diagnostic in enumerate(diagnostics):
Expand Down
76 changes: 76 additions & 0 deletions src/ue4docker/diagnostics/diagnostic_ipv6.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
from .base import DiagnosticBase


class diagnosticIPv6(DiagnosticBase):
# The tag we use for built images
IMAGE_TAG = "adamrehn/ue4-docker/diagnostics:ipv6"

def __init__(self):
pass

def getName(self):
"""
Returns the human-readable name of the diagnostic
"""
return "Check that Linux containers can access the IPv6 loopback address"

def getDescription(self):
"""
Returns a description of what the diagnostic does
"""
return "\n".join(
[
"This diagnostic determines whether Linux containers are able to access the IPv6,",
"loopback address ::1, which is required by Unreal Engine 5.4 and newer for",
"local ZenServer communication.",
"",
"This should work automatically under Docker 26.0.0 and newer, but older versions",
"require manual configuration by the user.",
]
)

def getPrefix(self):
"""
Returns the short name of the diagnostic for use in log output
"""
return "ipv6"

def run(self, logger, args=[]):
"""
Runs the diagnostic
"""

# This diagnostic only applies to Linux containers
containerPlatform = "linux"

# Verify that the user isn't trying to test Linux containers under Windows 10 when in Windows container mode
try:
self._checkPlatformMistmatch(logger, containerPlatform, False)
except RuntimeError:
return False

# Attempt to build the Dockerfile
logger.action(
"[network] Attempting to build an image that accesses the IPv6 loopback address...",
False,
)
built = self._buildDockerfile(
logger, containerPlatform, diagnosticIPv6.IMAGE_TAG, []
)

# Inform the user of the outcome of the diagnostic
if built == True:
logger.action(
"[network] Diagnostic succeeded! Linux containers can access the IPv6 loopback address without any issues.\n"
)
else:
logger.error(
"[network] Diagnostic failed! Linux containers cannot access the IPv6 loopback address. Update to Docker 26.0.0+ or manually enable IPv6:",
True,
)
logger.error(
"[network] https://docs.docker.com/config/daemon/ipv6/#use-ipv6-for-the-default-bridge-network\n",
False,
)

return built
2 changes: 1 addition & 1 deletion src/ue4docker/diagnostics/diagnostic_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def run(self, logger, args=[]):

# Verify that the user isn't trying to test Windows containers under Windows 10 when in Linux container mode (or vice versa)
try:
self._checkPlatformMistmatch(logger, containerPlatform)
self._checkPlatformMistmatch(logger, containerPlatform, True)
except RuntimeError:
return False

Expand Down
1 change: 1 addition & 0 deletions src/ue4docker/diagnostics_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def diagnostics():
"all": allDiagnostics(),
"8gig": diagnostic8Gig(),
"20gig": diagnostic20Gig(),
"ipv6": diagnosticIPv6(),
"network": diagnosticNetwork(),
}

Expand Down
7 changes: 7 additions & 0 deletions src/ue4docker/dockerfiles/diagnostics/ipv6/linux/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine:latest

# Add a sentinel label so we can easily identify intermediate images
LABEL com.adamrehn.ue4-docker.sentinel="1"

# Test that we can ping the IPv6 loopback address
RUN ping6 -c 5 '::1'

0 comments on commit 070dd3c

Please sign in to comment.