Skip to content

Commit ea583d0

Browse files
committed
Merge pull request #241 from vishh/dns_lookup
Avoid compiling cadvisor statically for the docker image
2 parents 7c59947 + 7ed645f commit ea583d0

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

cadvisor.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,23 @@ func main() {
9393

9494
defer glog.Flush()
9595

96+
errChan := make(chan error)
9697
go func() {
97-
glog.Fatal(containerManager.Start())
98+
errChan <- containerManager.Start()
9899
}()
99100

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

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

105-
glog.Fatal(http.ListenAndServe(addr, nil))
106+
go func() {
107+
errChan <- http.ListenAndServe(addr, nil)
108+
}()
109+
select {
110+
case err := <-errChan:
111+
glog.Fatal(err)
112+
}
106113
}
107114

108115
func setMaxProcs() {

deploy/Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
FROM scratch
2-
3-
4-
# NOTE: Run prepare.sh before building this Docker image.
1+
FROM progrium/busybox
2+
53

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

97
EXPOSE 8080
10-
ENTRYPOINT ["/usr/bin/cadvisor"]
11-
CMD ["-log_dir", "/"]
8+
ENTRYPOINT ["/usr/bin/cadvisor"]

deploy/build.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
godep go build -a github.com/google/cadvisor
7+
8+
sudo docker build -t google/cadvisor:test .

deploy/prepare.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

storage/memory/memory.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"fmt"
2020
"sync"
2121

22+
"github.com/golang/glog"
2223
"github.com/google/cadvisor/info"
2324
"github.com/google/cadvisor/storage"
2425
)
@@ -104,7 +105,9 @@ func (self *InMemoryStorage) AddStats(ref info.ContainerReference, stats *info.C
104105
// TODO(monnand): To deal with long delay write operations, we
105106
// may want to start a pool of goroutines to do write
106107
// operations.
107-
self.backend.AddStats(ref, stats)
108+
if err := self.backend.AddStats(ref, stats); err != nil {
109+
glog.Error(err)
110+
}
108111
}
109112
return cstore.AddStats(stats)
110113
}

0 commit comments

Comments
 (0)