Check local address in healthcheck script to ensure correct MinIO port (#7787)

Fixes #7780
This commit is contained in:
Nitish Tiwari 2019-06-17 12:42:36 +05:30 committed by kannappanr
parent 59f7266081
commit 7001fe407f

View File

@ -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