Use glog instead of 'log' library.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
parent
6c2694a53b
commit
3e390e0f33
@ -20,12 +20,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
)
|
)
|
||||||
@ -41,8 +41,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var supportedApiVersions map[string]struct{} = map[string]struct{}{
|
var supportedApiVersions map[string]struct{} = map[string]struct{}{
|
||||||
version1_0: struct{}{},
|
version1_0: {},
|
||||||
version1_1: struct{}{},
|
version1_1: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHandlers(m manager.Manager) error {
|
func RegisterHandlers(m manager.Manager) error {
|
||||||
@ -92,7 +92,7 @@ func handleRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) er
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case requestType == machineApi:
|
case requestType == machineApi:
|
||||||
log.Printf("Api - Machine")
|
glog.V(2).Infof("Api - Machine")
|
||||||
|
|
||||||
// Get the MachineInfo
|
// Get the MachineInfo
|
||||||
machineInfo, err := m.GetMachineInfo()
|
machineInfo, err := m.GetMachineInfo()
|
||||||
@ -109,7 +109,7 @@ func handleRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) er
|
|||||||
// The container name is the path after the requestType.
|
// The container name is the path after the requestType.
|
||||||
containerName := path.Join("/", strings.Join(requestArgs, "/"))
|
containerName := path.Join("/", strings.Join(requestArgs, "/"))
|
||||||
|
|
||||||
log.Printf("Api - Container(%s)", containerName)
|
glog.V(2).Infof("Api - Container(%s)", containerName)
|
||||||
|
|
||||||
// Get the query request.
|
// Get the query request.
|
||||||
query, err := getContainerInfoRequest(r.Body)
|
query, err := getContainerInfoRequest(r.Body)
|
||||||
@ -137,7 +137,7 @@ func handleRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) er
|
|||||||
// The container name is the path after the requestType.
|
// The container name is the path after the requestType.
|
||||||
containerName := path.Join("/", strings.Join(requestArgs, "/"))
|
containerName := path.Join("/", strings.Join(requestArgs, "/"))
|
||||||
|
|
||||||
log.Printf("Api - Subcontainers(%s)", containerName)
|
glog.V(2).Infof("Api - Subcontainers(%s)", containerName)
|
||||||
|
|
||||||
// Get the query request.
|
// Get the query request.
|
||||||
query, err := getContainerInfoRequest(r.Body)
|
query, err := getContainerInfoRequest(r.Body)
|
||||||
@ -161,7 +161,7 @@ func handleRequest(m manager.Manager, w http.ResponseWriter, r *http.Request) er
|
|||||||
return fmt.Errorf("unknown API request type %q", requestType)
|
return fmt.Errorf("unknown API request type %q", requestType)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Request took %s", time.Since(start))
|
glog.V(2).Infof("Request took %s", time.Since(start))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
cadvisor.go
22
cadvisor.go
@ -17,9 +17,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/api"
|
"github.com/google/cadvisor/api"
|
||||||
"github.com/google/cadvisor/container/docker"
|
"github.com/google/cadvisor/container/docker"
|
||||||
"github.com/google/cadvisor/container/raw"
|
"github.com/google/cadvisor/container/raw"
|
||||||
@ -38,22 +38,22 @@ func main() {
|
|||||||
|
|
||||||
storageDriver, err := NewStorageDriver(*argDbDriver)
|
storageDriver, err := NewStorageDriver(*argDbDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to connect to database: %s", err)
|
glog.Fatalf("Failed to connect to database: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
containerManager, err := manager.New(storageDriver)
|
containerManager, err := manager.New(storageDriver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to create a Container Manager: %s", err)
|
glog.Fatalf("Failed to create a Container Manager: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register Docker.
|
// Register Docker.
|
||||||
if err := docker.Register(containerManager); err != nil {
|
if err := docker.Register(containerManager); err != nil {
|
||||||
log.Printf("Docker registration failed: %v.", err)
|
glog.Errorf("Docker registration failed: %v.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register the raw driver.
|
// Register the raw driver.
|
||||||
if err := raw.Register(containerManager); err != nil {
|
if err := raw.Register(containerManager); err != nil {
|
||||||
log.Fatalf("raw registration failed: %v.", err)
|
glog.Fatalf("raw registration failed: %v.", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler for static content.
|
// Handler for static content.
|
||||||
@ -66,7 +66,7 @@ func main() {
|
|||||||
|
|
||||||
// Register API handler.
|
// Register API handler.
|
||||||
if err := api.RegisterHandlers(containerManager); err != nil {
|
if err := api.RegisterHandlers(containerManager); err != nil {
|
||||||
log.Fatalf("failed to register API handlers: %s", err)
|
glog.Fatalf("failed to register API handlers: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect / to containers page.
|
// Redirect / to containers page.
|
||||||
@ -80,14 +80,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
defer glog.Flush()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
log.Fatal(containerManager.Start())
|
glog.Fatal(containerManager.Start())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Printf("Starting cAdvisor version: %q", info.VERSION)
|
glog.Infof("Starting cAdvisor version: %q", info.VERSION)
|
||||||
log.Print("About to serve on port ", *argPort)
|
glog.Infof("About to serve on port ", *argPort)
|
||||||
|
|
||||||
addr := fmt.Sprintf(":%v", *argPort)
|
addr := fmt.Sprintf(":%v", *argPort)
|
||||||
|
|
||||||
log.Fatal(http.ListenAndServe(addr, nil))
|
glog.Fatal(http.ListenAndServe(addr, nil))
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ package docker
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"path"
|
"path"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -25,6 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups/systemd"
|
"github.com/docker/libcontainer/cgroups/systemd"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
)
|
)
|
||||||
@ -134,9 +134,9 @@ func Register(factory info.MachineInfoFactory) error {
|
|||||||
client: client,
|
client: client,
|
||||||
}
|
}
|
||||||
if f.useSystemd {
|
if f.useSystemd {
|
||||||
log.Printf("System is using systemd")
|
glog.Infof("System is using systemd")
|
||||||
}
|
}
|
||||||
log.Printf("Registering Docker factory")
|
glog.Infof("Registering Docker factory")
|
||||||
container.RegisterContainerHandlerFactory(f)
|
container.RegisterContainerHandlerFactory(f)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -28,6 +27,7 @@ import (
|
|||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
"github.com/docker/libcontainer/cgroups/fs"
|
"github.com/docker/libcontainer/cgroups/fs"
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
containerLibcontainer "github.com/google/cadvisor/container/libcontainer"
|
containerLibcontainer "github.com/google/cadvisor/container/libcontainer"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
@ -197,7 +197,7 @@ func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err
|
|||||||
config, err := self.readLibcontainerConfig()
|
config, err := self.readLibcontainerConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == fileNotFound {
|
if err == fileNotFound {
|
||||||
log.Printf("Libcontainer config not found for container %q", self.name)
|
glog.Errorf("Libcontainer config not found for container %q", self.name)
|
||||||
return &info.ContainerStats{}, nil
|
return &info.ContainerStats{}, nil
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@ -205,7 +205,7 @@ func (self *dockerContainerHandler) GetStats() (stats *info.ContainerStats, err
|
|||||||
state, err := self.readLibcontainerState()
|
state, err := self.readLibcontainerState()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == fileNotFound {
|
if err == fileNotFound {
|
||||||
log.Printf("Libcontainer state not found for container %q", self.name)
|
glog.Errorf("Libcontainer state not found for container %q", self.name)
|
||||||
return &info.ContainerStats{}, nil
|
return &info.ContainerStats{}, nil
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -16,8 +16,9 @@ package container
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerHandlerFactory interface {
|
type ContainerHandlerFactory interface {
|
||||||
@ -55,7 +56,7 @@ func NewContainerHandler(name string) (ContainerHandler, error) {
|
|||||||
// Create the ContainerHandler with the first factory that supports it.
|
// Create the ContainerHandler with the first factory that supports it.
|
||||||
for _, factory := range factories {
|
for _, factory := range factories {
|
||||||
if factory.CanHandle(name) {
|
if factory.CanHandle(name) {
|
||||||
log.Printf("Using factory %q for container %q", factory.String(), name)
|
glog.V(1).Infof("Using factory %q for container %q", factory.String(), name)
|
||||||
return factory.NewContainerHandler(name)
|
return factory.NewContainerHandler(name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,9 @@ package raw
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
)
|
)
|
||||||
@ -75,7 +75,7 @@ func Register(machineInfoFactory info.MachineInfoFactory) error {
|
|||||||
return fmt.Errorf("failed to find supported cgroup mounts for the raw factory")
|
return fmt.Errorf("failed to find supported cgroup mounts for the raw factory")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Registering Raw factory")
|
glog.Infof("Registering Raw factory")
|
||||||
factory := &rawFactory{
|
factory := &rawFactory{
|
||||||
machineInfoFactory: machineInfoFactory,
|
machineInfoFactory: machineInfoFactory,
|
||||||
cgroupSubsystems: &cgroupSubsystems{
|
cgroupSubsystems: &cgroupSubsystems{
|
||||||
|
@ -17,13 +17,13 @@ package raw
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
"github.com/docker/libcontainer/cgroups/fs"
|
"github.com/docker/libcontainer/cgroups/fs"
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/container/libcontainer"
|
"github.com/google/cadvisor/container/libcontainer"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
@ -67,7 +67,7 @@ func readString(dirpath string, file string) string {
|
|||||||
// Read
|
// Read
|
||||||
out, err := ioutil.ReadFile(cgroupFile)
|
out, err := ioutil.ReadFile(cgroupFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("raw driver: Failed to read %q: %s", cgroupFile, err)
|
glog.Errorf("raw driver: Failed to read %q: %s", cgroupFile, err)
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return string(out)
|
return string(out)
|
||||||
@ -81,7 +81,7 @@ func readInt64(dirpath string, file string) uint64 {
|
|||||||
|
|
||||||
val, err := strconv.ParseUint(strings.TrimSpace(out), 10, 64)
|
val, err := strconv.ParseUint(strings.TrimSpace(out), 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("raw driver: Failed to parse in %q from file %q: %s", out, path.Join(dirpath, file), err)
|
glog.Errorf("raw driver: Failed to parse int %q from file %q: %s", out, path.Join(dirpath, file), err)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ package manager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
"github.com/google/cadvisor/storage"
|
"github.com/google/cadvisor/storage"
|
||||||
@ -51,7 +51,7 @@ type containerData struct {
|
|||||||
func (c *containerData) Start() error {
|
func (c *containerData) Start() error {
|
||||||
// Force the first update.
|
// Force the first update.
|
||||||
c.housekeepingTick()
|
c.housekeepingTick()
|
||||||
log.Printf("Start housekeeping for container %q\n", c.info.Name)
|
glog.Infof("Start housekeeping for container %q\n", c.info.Name)
|
||||||
|
|
||||||
go c.housekeeping()
|
go c.housekeeping()
|
||||||
return nil
|
return nil
|
||||||
@ -119,7 +119,7 @@ func (c *containerData) housekeeping() {
|
|||||||
// Log if housekeeping took longer than 120ms.
|
// Log if housekeeping took longer than 120ms.
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
if duration >= 120*time.Millisecond {
|
if duration >= 120*time.Millisecond {
|
||||||
log.Printf("Housekeeping(%s) took %s", c.info.Name, duration)
|
glog.V(2).Infof("Housekeeping(%s) took %s", c.info.Name, duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ func (c *containerData) housekeeping() {
|
|||||||
func (c *containerData) housekeepingTick() {
|
func (c *containerData) housekeepingTick() {
|
||||||
err := c.updateStats()
|
err := c.updateStats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to update stats for container \"%s\": %s", c.info.Name, err)
|
glog.Infof("Failed to update stats for container \"%s\": %s", c.info.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,12 +16,12 @@ package manager
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/container"
|
"github.com/google/cadvisor/container"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
"github.com/google/cadvisor/storage"
|
"github.com/google/cadvisor/storage"
|
||||||
@ -56,14 +56,14 @@ func New(driver storage.StorageDriver) (Manager, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newManager.machineInfo = *machineInfo
|
newManager.machineInfo = *machineInfo
|
||||||
log.Printf("Machine: %+v", newManager.machineInfo)
|
glog.Infof("Machine: %+v", newManager.machineInfo)
|
||||||
|
|
||||||
versionInfo, err := getVersionInfo()
|
versionInfo, err := getVersionInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newManager.versionInfo = *versionInfo
|
newManager.versionInfo = *versionInfo
|
||||||
log.Printf("Version: %+v", newManager.versionInfo)
|
glog.Infof("Version: %+v", newManager.versionInfo)
|
||||||
newManager.storageDriver = driver
|
newManager.storageDriver = driver
|
||||||
|
|
||||||
return newManager, nil
|
return newManager, nil
|
||||||
@ -84,12 +84,12 @@ func (m *manager) Start() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Printf("Starting recovery of all containers")
|
glog.Infof("Starting recovery of all containers")
|
||||||
err = m.detectContainers()
|
err = m.detectContainers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.Printf("Recovery completed")
|
glog.Infof("Recovery completed")
|
||||||
|
|
||||||
// Look for new containers in the main housekeeping thread.
|
// Look for new containers in the main housekeeping thread.
|
||||||
for t := range time.Tick(time.Second) {
|
for t := range time.Tick(time.Second) {
|
||||||
@ -98,13 +98,13 @@ func (m *manager) Start() error {
|
|||||||
// Check for new containers.
|
// Check for new containers.
|
||||||
err = m.detectContainers()
|
err = m.detectContainers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to detect containers: %s", err)
|
glog.Errorf("Failed to detect containers: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log if housekeeping took more than 100ms.
|
// Log if housekeeping took more than 100ms.
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
if duration >= 100*time.Millisecond {
|
if duration >= 100*time.Millisecond {
|
||||||
log.Printf("Global Housekeeping(%d) took %s", t.Unix(), duration)
|
glog.V(1).Infof("Global Housekeeping(%d) took %s", t.Unix(), duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -242,7 +242,7 @@ func (m *manager) createContainer(containerName string) (*containerData, error)
|
|||||||
m.containers[alias] = cont
|
m.containers[alias] = cont
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.Printf("Added container: %q (aliases: %s)", containerName, cont.info.Aliases)
|
glog.Infof("Added container: %q (aliases: %s)", containerName, cont.info.Aliases)
|
||||||
|
|
||||||
// Start the container's housekeeping.
|
// Start the container's housekeeping.
|
||||||
cont.Start()
|
cont.Start()
|
||||||
@ -269,7 +269,7 @@ func (m *manager) destroyContainer(containerName string) error {
|
|||||||
for _, alias := range cont.info.Aliases {
|
for _, alias := range cont.info.Aliases {
|
||||||
delete(m.containers, alias)
|
delete(m.containers, alias)
|
||||||
}
|
}
|
||||||
log.Printf("Destroyed container: %s (aliases: %s)", containerName, cont.info.Aliases)
|
glog.Infof("Destroyed container: %s (aliases: %s)", containerName, cont.info.Aliases)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ func (m *manager) detectContainers() error {
|
|||||||
for _, cont := range added {
|
for _, cont := range added {
|
||||||
_, err = m.createContainer(cont.Name)
|
_, err = m.createContainer(cont.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to create existing container: %s: %s", cont.Name, err)
|
glog.Errorf("failed to create existing container: %s: %s", cont.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ func (m *manager) detectContainers() error {
|
|||||||
for _, cont := range removed {
|
for _, cont := range removed {
|
||||||
err = m.destroyContainer(cont.Name)
|
err = m.destroyContainer(cont.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("failed to destroy existing container: %s: %s", cont.Name, err)
|
glog.Errorf("failed to destroy existing container: %s: %s", cont.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ package pages
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"html/template"
|
"html/template"
|
||||||
"log"
|
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -27,6 +26,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
"github.com/google/cadvisor/manager"
|
"github.com/google/cadvisor/manager"
|
||||||
)
|
)
|
||||||
@ -66,7 +66,7 @@ func init() {
|
|||||||
pageTemplate = template.New("containersTemplate").Funcs(funcMap)
|
pageTemplate = template.New("containersTemplate").Funcs(funcMap)
|
||||||
_, err := pageTemplate.Parse(containersHtmlTemplate)
|
_, err := pageTemplate.Parse(containersHtmlTemplate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Failed to parse template: %s", err)
|
glog.Fatalf("Failed to parse template: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,9 +263,9 @@ func ServerContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL)
|
|||||||
}
|
}
|
||||||
err = pageTemplate.Execute(w, data)
|
err = pageTemplate.Execute(w, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed to apply template: %s", err)
|
glog.Errorf("Failed to apply template: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Request took %s", time.Since(start))
|
glog.V(1).Infof("Request took %s", time.Since(start))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ func (self simpleSchedulerLoadReader) Load(container string) ([]int, error) {
|
|||||||
|
|
||||||
func (self simpleSchedulerLoadReader) AllContainers() ([]string, error) {
|
func (self simpleSchedulerLoadReader) AllContainers() ([]string, error) {
|
||||||
ret := make([]string, 0, len(self))
|
ret := make([]string, 0, len(self))
|
||||||
for c, _ := range self {
|
for c := range self {
|
||||||
ret = append(ret, c)
|
ret = append(ret, c)
|
||||||
}
|
}
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user