From 7001fe407f6cc89497fb171db303d4c42e0f8f77 Mon Sep 17 00:00:00 2001 From: Nitish Tiwari Date: Mon, 17 Jun 2019 12:42:36 +0530 Subject: [PATCH] Check local address in healthcheck script to ensure correct MinIO port (#7787) Fixes #7780 --- dockerscripts/healthcheck.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dockerscripts/healthcheck.go b/dockerscripts/healthcheck.go index 02d471062..ec0674df9 100755 --- a/dockerscripts/healthcheck.go +++ b/dockerscripts/healthcheck.go @@ -39,6 +39,7 @@ const ( healthPath = "/minio/health/live" timeout = time.Duration(30 * time.Second) tcp = "tcp" + anyIP = ":::" ) // returns container boot time by finding @@ -69,17 +70,15 @@ func findEndpoint() (string, error) { scanner := bufio.NewScanner(stdout) scanner.Split(bufio.ScanLines) // MinIO works on TCP and it is supposed to be - // the only process listening on a port inside - // container. So we take the first row of netstat - // output (that has tcp) and assume that is the - // MinIO server port. + // the only process listening on a port on any IP address + // (on :::) inside container. // Since MinIO is running as non-root user, we can - // no longer depend on the PID/Program name column + // not depend on the PID/Program name column // of netstat output for scanner.Scan() { - if strings.Contains(scanner.Text(), tcp) { - line := scanner.Text() - newLine := strings.Replace(line, ":::", "127.0.0.1:", 1) + line := scanner.Text() + if strings.Contains(line, tcp) && strings.Contains(line, anyIP) { + newLine := strings.Replace(line, anyIP, "127.0.0.1:", 1) fields := strings.Fields(newLine) // index 3 in the row has the Local address // find the last index of ":" - address will