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

Fixes #7780
master
Nitish Tiwari 6 years ago committed by kannappanr
parent 59f7266081
commit 7001fe407f
  1. 13
      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)
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

Loading…
Cancel
Save