From 0035fdba8933854bde5a9b73dc5164f3db0fef8e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 30 Mar 2026 05:17:49 +0000 Subject: [PATCH] Add debug logging to config/docker_helpers.go Enhance docker_helpers.go with debug logging using the existing logDockerHelpers logger to improve troubleshooting of Docker operations: - runDockerInspect: log before executing the docker inspect command and after success with output length - checkPortMapping: log entry with containerID/port and result with mapped status - checkStdinInteractive: log result with containerID and interactive flag - checkLogDirMounted: log result with containerID, logDir, and mounted status These debug logs are controlled via DEBUG=config:docker_helpers and help diagnose Docker environment validation issues during gateway startup. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- internal/config/docker_helpers.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/internal/config/docker_helpers.go b/internal/config/docker_helpers.go index 56dbc46d..82396b32 100644 --- a/internal/config/docker_helpers.go +++ b/internal/config/docker_helpers.go @@ -73,17 +73,23 @@ func runDockerInspect(containerID, formatTemplate string) (string, error) { return "", err } + logDockerHelpers.Printf("Running docker inspect: containerID=%s, format=%s", containerID, formatTemplate) + cmd := exec.Command("docker", "inspect", "--format", formatTemplate, containerID) output, err := cmd.Output() if err != nil { return "", fmt.Errorf("docker inspect failed: %w", err) } - return strings.TrimSpace(string(output)), nil + result := strings.TrimSpace(string(output)) + logDockerHelpers.Printf("Docker inspect succeeded: output_len=%d", len(result)) + return result, nil } // checkPortMapping uses docker inspect to verify that the specified port is mapped func checkPortMapping(containerID, port string) (bool, error) { + logDockerHelpers.Printf("Checking port mapping: containerID=%s, port=%s", containerID, port) + output, err := runDockerInspect(containerID, "{{json .NetworkSettings.Ports}}") if err != nil { return false, err @@ -94,7 +100,9 @@ func checkPortMapping(containerID, port string) (bool, error) { // Check if the port is in the output with a host binding // The format is like: {"8000/tcp":[{"HostIp":"0.0.0.0","HostPort":"8000"}]} - return strings.Contains(output, portKey) && strings.Contains(output, "HostPort"), nil + mapped := strings.Contains(output, portKey) && strings.Contains(output, "HostPort") + logDockerHelpers.Printf("Port mapping check result: port=%s, mapped=%v", portKey, mapped) + return mapped, nil } // checkStdinInteractive uses docker inspect to verify the container was started with -i flag @@ -104,7 +112,9 @@ func checkStdinInteractive(containerID string) bool { return false } - return output == "true" + interactive := output == "true" + logDockerHelpers.Printf("Stdin interactive check: containerID=%s, interactive=%v", containerID, interactive) + return interactive } // checkLogDirMounted uses docker inspect to verify the log directory is mounted @@ -115,7 +125,9 @@ func checkLogDirMounted(containerID, logDir string) bool { } // Check if the log directory is in the mounts - return strings.Contains(output, logDir) + mounted := strings.Contains(output, logDir) + logDockerHelpers.Printf("Log dir mount check: containerID=%s, logDir=%s, mounted=%v", containerID, logDir, mounted) + return mounted } // ExpandEnvArgs expands Docker -e flags that reference environment variables.