From 5d9816be41a967fa1fa9bbbe0c638dd322c7c0b1 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Mon, 17 Sep 2018 21:33:51 -0700 Subject: Remove memory usage static init panic() during init() can be hard to debug. Updates #100 PiperOrigin-RevId: 213391932 Change-Id: Ic103f1981c5b48f1e12da3b42e696e84ffac02a9 --- runsc/boot/loader.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'runsc/boot/loader.go') diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index 665240ab6..faaf3e800 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -42,6 +42,7 @@ import ( "gvisor.googlesource.com/gvisor/pkg/sentry/sighandling" slinux "gvisor.googlesource.com/gvisor/pkg/sentry/syscalls/linux" "gvisor.googlesource.com/gvisor/pkg/sentry/time" + "gvisor.googlesource.com/gvisor/pkg/sentry/usage" "gvisor.googlesource.com/gvisor/pkg/sentry/watchdog" "gvisor.googlesource.com/gvisor/pkg/tcpip" "gvisor.googlesource.com/gvisor/pkg/tcpip/link/sniffer" @@ -143,6 +144,9 @@ func init() { // New initializes a new kernel loader configured by spec. // New also handles setting up a kernel for restoring a container. func New(spec *specs.Spec, conf *Config, controllerFD, deviceFD int, goferFDs []int, console bool) (*Loader, error) { + if err := usage.Init(); err != nil { + return nil, fmt.Errorf("Error setting up memory usage: %v", err) + } // Create kernel and platform. p, err := createPlatform(conf, deviceFD) if err != nil { -- cgit v1.2.3