Skip to content

Commit cfcaba5

Browse files
committed
Use go-docker client, negotiate API version
1 parent 6781e08 commit cfcaba5

File tree

232 files changed

+15497
-3813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+15497
-3813
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ TARGET = kubernetes-oomkill-exporter
22
GOTARGET = github.com/sapcc/$(TARGET)
33
BUILDMNT = /go/src/$(GOTARGET)
44
REGISTRY ?= sapcc
5-
VERSION ?= 0.1.0
5+
VERSION ?= 0.2.0
66
IMAGE = $(REGISTRY)/$(BIN)
77
BUILD_IMAGE ?= golang:1.11-alpine3.8
88
DOCKER ?= docker

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ module github.com/sapcc/kubernetes-oomkill-exporter
22

33
require (
44
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c // indirect
5+
docker.io/go-docker v1.0.0
56
github.com/Microsoft/go-winio v0.4.11 // indirect
67
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 // indirect
78
github.com/davecgh/go-spew v1.1.1 // indirect
8-
github.com/docker/distribution v2.6.2+incompatible // indirect
9-
github.com/docker/docker v1.13.1
9+
github.com/docker/distribution v2.7.0+incompatible // indirect
1010
github.com/docker/go-connections v0.4.0 // indirect
1111
github.com/docker/go-units v0.3.3 // indirect
1212
github.com/euank/go-kmsg-parser v2.0.0+incompatible
@@ -19,14 +19,15 @@ require (
1919
github.com/modern-go/reflect2 v1.0.1 // indirect
2020
github.com/onsi/ginkgo v1.7.0 // indirect
2121
github.com/onsi/gomega v1.4.3 // indirect
22+
github.com/opencontainers/go-digest v1.0.0-rc1 // indirect
23+
github.com/opencontainers/image-spec v1.0.1 // indirect
2224
github.com/pkg/errors v0.8.0 // indirect
2325
github.com/pmezard/go-difflib v1.0.0 // indirect
2426
github.com/prometheus/client_golang v0.9.1
2527
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect
2628
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 // indirect
2729
github.com/prometheus/procfs v0.0.0-20181126161756-619930b0b471 // indirect
2830
github.com/spf13/pflag v1.0.3 // indirect
29-
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 // indirect
3031
github.com/stretchr/testify v1.2.2
3132
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc // indirect
3233
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a

go.sum

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c h1:5eeuG0BHx1+DHeT3AP+ISKZ2ht1UjGhm581ljqYpVeQ=
22
code.cloudfoundry.org/clock v0.0.0-20180518195852-02e53af36e6c/go.mod h1:QD9Lzhd/ux6eNQVUDVRJX/RKTigpewimNYBi7ivZKY8=
3+
docker.io/go-docker v1.0.0 h1:VdXS/aNYQxyA9wdLD5z8Q8Ro688/hG8HzKxYVEVbE6s=
4+
docker.io/go-docker v1.0.0/go.mod h1:7tiAn5a0LFmjbPDbyTPOaTTOuG1ZRNXdPA6RvKY+fpY=
35
github.com/Microsoft/go-winio v0.4.11 h1:zoIOcVf0xPN1tnMVbTtEdI+P8OofVk3NObnwOQ6nK2Q=
46
github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcyvVC4A4RozmA=
57
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=
68
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
79
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
810
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
9-
github.com/docker/distribution v2.6.2+incompatible h1:4FI6af79dfCS/CYb+RRtkSHw3q1L/bnDjG1PcPZtQhM=
10-
github.com/docker/distribution v2.6.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
11-
github.com/docker/docker v1.13.1 h1:5VBhsO6ckUxB0A8CE5LlUJdXzik9cbEbBTQ/ggeml7M=
12-
github.com/docker/docker v1.13.1/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
11+
github.com/docker/distribution v2.7.0+incompatible h1:neUDAlf3wX6Ml4HdqTrbcOHXtfRN0TFIwt6YFL7N9RU=
12+
github.com/docker/distribution v2.7.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
1313
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
1414
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
1515
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
@@ -41,6 +41,10 @@ github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs=
4141
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
4242
github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU=
4343
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
44+
github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ=
45+
github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
46+
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
47+
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
4448
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
4549
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
4650
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@@ -55,8 +59,6 @@ github.com/prometheus/procfs v0.0.0-20181126161756-619930b0b471 h1:yLaU2uaatUJcb
5559
github.com/prometheus/procfs v0.0.0-20181126161756-619930b0b471/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
5660
github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg=
5761
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
58-
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50 h1:4bT0pPowCpQImewr+BjzfUKcuFW+KVyB8d1OF3b6oTI=
59-
github.com/stevvooe/resumable v0.0.0-20180830230917-22b14a53ba50/go.mod h1:1pdIZTAHUz+HDKDVZ++5xg/duPlhKAIzw9qy42CWYp4=
6062
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
6163
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
6264
github.com/tedsuo/ifrit v0.0.0-20180802180643-bea94bb476cc h1:LUUe4cdABGrIJAhl1P1ZpWY76AwukVszFdwkVFVLwIk=

main.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import (
77
"regexp"
88
"strings"
99

10-
docker_types "github.com/docker/docker/api/types"
11-
docker_filters "github.com/docker/docker/api/types/filters"
12-
docker_client "github.com/docker/docker/client"
10+
docker_client "docker.io/go-docker"
11+
docker_types "docker.io/go-docker/api/types"
12+
docker_filters "docker.io/go-docker/api/types/filters"
1313
"github.com/golang/glog"
1414
"github.com/prometheus/client_golang/prometheus"
1515
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -32,11 +32,17 @@ var (
3232
"io.kubernetes.pod.uid": "pod_uid",
3333
"io.kubernetes.pod.name": "pod_name",
3434
}
35-
metricsAddr string
35+
metricsAddr string
36+
dockerClient *docker_client.Client
3637
)
3738

3839
func init() {
3940
flag.StringVar(&metricsAddr, "listen-address", ":9102", "The address to listen on for HTTP requests.")
41+
dockerClient, err := docker_client.NewEnvClient()
42+
if err != nil {
43+
glog.Fatal(err)
44+
}
45+
dockerClient.NegotiateAPIVersion(context.Background())
4046
}
4147

4248
func main() {
@@ -69,18 +75,13 @@ func main() {
6975
for log := range logCh {
7076
podUID := getPodUIDFromLog(log.Message)
7177
if podUID != "" {
72-
cli, err := docker_client.NewEnvClient()
73-
if err != nil {
74-
glog.Fatal(err)
75-
}
76-
77-
container, err := getContainerFromPod(podUID, cli)
78+
container, err := getContainerFromPod(podUID, dockerClient)
7879

7980
if err != nil {
8081
glog.Warningf("Could not get container for pod UID %s: %v", podUID, err)
82+
} else {
83+
prometheusCount(container)
8184
}
82-
83-
prometheusCount(container)
8485
}
8586
}
8687
}

vendor/docker.io/go-docker/Gopkg.toml

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/docker.io/go-docker/README.md

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/docker.io/go-docker/api/README.md

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/docker.io/go-docker/api/common.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/docker.io/go-docker/api/common_unix.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/docker.io/go-docker/api/common_windows.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)