Skip to content

Commit

Permalink
Avoid compiling cadvisor statically for the docker image by deriving …
Browse files Browse the repository at this point in the history
…the image from a stripped down busybox image.

Log failures encountered while dumping to influxdb
Handle critical failures in cadvisor gracefully without getting stuck.
  • Loading branch information
vishh committed Sep 19, 2014
1 parent 7c59947 commit 7ed645f
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
11 changes: 9 additions & 2 deletions cadvisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,23 @@ func main() {

defer glog.Flush()

errChan := make(chan error)
go func() {
glog.Fatal(containerManager.Start())
errChan <- containerManager.Start()
}()

glog.Infof("Starting cAdvisor version: %q", info.VERSION)
glog.Infof("About to serve on port %d", *argPort)

addr := fmt.Sprintf(":%v", *argPort)

glog.Fatal(http.ListenAndServe(addr, nil))
go func() {
errChan <- http.ListenAndServe(addr, nil)
}()
select {
case err := <-errChan:
glog.Fatal(err)
}
}

func setMaxProcs() {
Expand Down
9 changes: 3 additions & 6 deletions deploy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
FROM scratch
MAINTAINER dengnan@google.com vmarmol@google.com

# NOTE: Run prepare.sh before building this Docker image.
FROM progrium/busybox
MAINTAINER dengnan@google.com vmarmol@google.com vishnuk@google.com

# Grab cadvisor from the staging directory.
ADD cadvisor /usr/bin/cadvisor

EXPOSE 8080
ENTRYPOINT ["/usr/bin/cadvisor"]
CMD ["-log_dir", "/"]
ENTRYPOINT ["/usr/bin/cadvisor"]
8 changes: 8 additions & 0 deletions deploy/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e
set -x

godep go build -a github.com/google/cadvisor

sudo docker build -t google/cadvisor:test .
7 changes: 0 additions & 7 deletions deploy/prepare.sh

This file was deleted.

5 changes: 4 additions & 1 deletion storage/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"sync"

"github.com/golang/glog"
"github.com/google/cadvisor/info"
"github.com/google/cadvisor/storage"
)
Expand Down Expand Up @@ -104,7 +105,9 @@ func (self *InMemoryStorage) AddStats(ref info.ContainerReference, stats *info.C
// TODO(monnand): To deal with long delay write operations, we
// may want to start a pool of goroutines to do write
// operations.
self.backend.AddStats(ref, stats)
if err := self.backend.AddStats(ref, stats); err != nil {
glog.Error(err)
}
}
return cstore.AddStats(stats)
}
Expand Down

0 comments on commit 7ed645f

Please sign in to comment.