1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #348 from aboch/is

Endpoint interface stats read fails when invoked from docker
This commit is contained in:
Madhu Venugopal 2015-06-30 11:04:39 -07:00
commit 2ac749c006

View file

@ -2,8 +2,8 @@ package sandbox
import ( import (
"fmt" "fmt"
"io/ioutil"
"net" "net"
"os/exec"
"regexp" "regexp"
"sync" "sync"
@ -168,9 +168,12 @@ func (i *nwIface) Statistics() (*InterfaceStatistics, error) {
s := &InterfaceStatistics{} s := &InterfaceStatistics{}
err := nsInvoke(path, func(nsFD int) error { return nil }, func(callerFD int) error { err := nsInvoke(path, func(nsFD int) error { return nil }, func(callerFD int) error {
data, err := ioutil.ReadFile(netStatsFile) // For some reason ioutil.ReadFile(netStatsFile) reads the file in
// the default netns when this code is invoked from docker.
// Executing "cat <netStatsFile>" works as expected.
data, err := exec.Command("cat", netStatsFile).Output()
if err != nil { if err != nil {
return fmt.Errorf("failed to open %s: %v", netStatsFile, err) return fmt.Errorf("failure opening %s: %v", netStatsFile, err)
} }
return scanInterfaceStats(string(data), i.DstName(), s) return scanInterfaceStats(string(data), i.DstName(), s)
}) })