Bump cgroups to c0710c92e8b3a44681d1321dcfd1360fc5
This fixes performance issues with walking `/dev` to get device paths. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| github.com/coreos/go-systemd 48702e0da86bd25e76cfef347e2adeb434a0d0a6 | ||||
| github.com/containerd/go-runc 4f6e87ae043f859a38255247b49c9abc262d002f | ||||
| github.com/containerd/console 84eeaae905fa414d03e07bcd6c8d3f19e7cf180e | ||||
| github.com/containerd/cgroups 29da22c6171a4316169f9205ab6c49f59b5b852f | ||||
| github.com/containerd/cgroups c0710c92e8b3a44681d1321dcfd1360fc5c6c089 | ||||
| github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 | ||||
| github.com/docker/go-metrics 4ea375f7759c82740c893fc030bc37088d2ec098 | ||||
| github.com/docker/go-events 9461782956ad83b30282bf90e31fa6a70c255ba9 | ||||
|   | ||||
							
								
								
									
										71
									
								
								vendor/github.com/containerd/cgroups/blkio.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										71
									
								
								vendor/github.com/containerd/cgroups/blkio.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -3,12 +3,12 @@ package cgroups | ||||
| import ( | ||||
| 	"bufio" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path/filepath" | ||||
| 	"strconv" | ||||
| 	"strings" | ||||
| 	"syscall" | ||||
|  | ||||
| 	specs "github.com/opencontainers/runtime-spec/specs-go" | ||||
| ) | ||||
| @@ -105,8 +105,13 @@ func (b *blkioController) Stat(path string, stats *Metrics) error { | ||||
| 			}, | ||||
| 		) | ||||
| 	} | ||||
| 	f, err := os.Open("/proc/diskstats") | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	defer f.Close() | ||||
|  | ||||
| 	devices, err := getDevices("/dev") | ||||
| 	devices, err := getDevices(f) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| @@ -268,50 +273,32 @@ type deviceKey struct { | ||||
| // getDevices makes a best effort attempt to read all the devices into a map | ||||
| // keyed by major and minor number. Since devices may be mapped multiple times, | ||||
| // we err on taking the first occurrence. | ||||
| func getDevices(path string) (map[deviceKey]string, error) { | ||||
| 	// TODO(stevvooe): We are ignoring lots of errors. It might be kind of | ||||
| 	// challenging to debug this if we aren't mapping devices correctly. | ||||
| 	// Consider logging these errors. | ||||
| 	devices := map[deviceKey]string{} | ||||
| 	if err := filepath.Walk(path, func(p string, fi os.FileInfo, err error) error { | ||||
| func getDevices(r io.Reader) (map[deviceKey]string, error) { | ||||
|  | ||||
| 	var ( | ||||
| 		s       = bufio.NewScanner(r) | ||||
| 		devices = make(map[deviceKey]string) | ||||
| 	) | ||||
| 	for s.Scan() { | ||||
| 		fields := strings.Fields(s.Text()) | ||||
| 		major, err := strconv.Atoi(fields[0]) | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 			return nil, err | ||||
| 		} | ||||
| 		switch { | ||||
| 		case fi.IsDir(): | ||||
| 			switch fi.Name() { | ||||
| 			case "pts", "shm", "fd", "mqueue", ".lxc", ".lxd-mounts": | ||||
| 				return filepath.SkipDir | ||||
| 			default: | ||||
| 				return nil | ||||
| 			} | ||||
| 		case fi.Name() == "console": | ||||
| 			return nil | ||||
| 		default: | ||||
| 			if fi.Mode()&os.ModeDevice == 0 { | ||||
| 				// skip non-devices | ||||
| 				return nil | ||||
| 			} | ||||
|  | ||||
| 			st, ok := fi.Sys().(*syscall.Stat_t) | ||||
| 			if !ok { | ||||
| 				return fmt.Errorf("%s: unable to convert to system stat", p) | ||||
| 			} | ||||
|  | ||||
| 			key := deviceKey{major(st.Rdev), minor(st.Rdev)} | ||||
| 			if _, ok := devices[key]; ok { | ||||
| 				return nil // skip it if we have already populated the path. | ||||
| 			} | ||||
|  | ||||
| 			devices[key] = p | ||||
| 		minor, err := strconv.Atoi(fields[1]) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|  | ||||
| 		return nil | ||||
| 	}); err != nil { | ||||
| 		return nil, err | ||||
| 		key := deviceKey{ | ||||
| 			major: uint64(major), | ||||
| 			minor: uint64(minor), | ||||
| 		} | ||||
| 		if _, ok := devices[key]; ok { | ||||
| 			continue | ||||
| 		} | ||||
| 		devices[key] = filepath.Join("/dev", fields[2]) | ||||
| 	} | ||||
|  | ||||
| 	return devices, nil | ||||
| 	return devices, s.Err() | ||||
| } | ||||
|  | ||||
| func major(devNumber uint64) uint64 { | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/containerd/cgroups/errors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/containerd/cgroups/errors.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -12,7 +12,7 @@ var ( | ||||
| 	ErrFreezerNotSupported      = errors.New("cgroups: freezer cgroup not supported on this system") | ||||
| 	ErrMemoryNotSupported       = errors.New("cgroups: memory cgroup not supported on this system") | ||||
| 	ErrCgroupDeleted            = errors.New("cgroups: cgroup deleted") | ||||
| 	ErrNoCgroupMountDestination = errors.New("cgroups: cannot found cgroup mount destination") | ||||
| 	ErrNoCgroupMountDestination = errors.New("cgroups: cannot find cgroup mount destination") | ||||
| ) | ||||
|  | ||||
| // ErrorHandler is a function that handles and acts on errors | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Michael Crosby
					Michael Crosby