Skip to content

Commit

Permalink
Merge pull request #429 from brancz/cut-1.3.1
Browse files Browse the repository at this point in the history
Cut 1.3.1
  • Loading branch information
k8s-ci-robot authored Apr 12, 2018
2 parents b1bf9a0 + cd3b284 commit 43fcd3c
Show file tree
Hide file tree
Showing 43 changed files with 15,386 additions and 15 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ sudo: required

language: go

go:
- "1.10"

install:
- mkdir -p $HOME/gopath/src/k8s.io
- mv $TRAVIS_BUILD_DIR $HOME/gopath/src/k8s.io/kube-state-metrics
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v1.3.1 / 2018-04-12

* [BUGFIX] Use Go 1.10.1 fixing TLS and memory issues.
* [BUGFIX] Fix Pod unknown state.

## v1.3.0 / 2018-04-04

After a testing period of 12 days, there were no additional bugs found or features introduced.
Expand Down
38 changes: 38 additions & 0 deletions Godeps/Godeps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
FLAGS =
BUILDENVVAR = CGO_ENABLED=0
TESTENVVAR =
REGISTRY = quay.io/coreos
TAG = $(shell git describe --abbrev=0)
Expand All @@ -9,6 +8,7 @@ BuildDate = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
Commit = $(shell git rev-parse --short HEAD)
ALL_ARCH = amd64 arm arm64 ppc64le s390x
PKG=k8s.io/kube-state-metrics
GO_VERSION=1.10.1

IMAGE = $(REGISTRY)/kube-state-metrics
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
Expand All @@ -28,7 +28,7 @@ doccheck:
@echo OK

build: clean
GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) $(BUILDENVVAR) go build -ldflags "-s -w -X ${PKG}/version.Release=${TAG} -X ${PKG}/version.Commit=${Commit} -X ${PKG}/version.BuildDate=${BuildDate}" -o kube-state-metrics
docker run --rm -v "$$PWD":/go/src/k8s.io/kube-state-metrics -w /go/src/k8s.io/kube-state-metrics -e GOOS=$(shell uname -s | tr A-Z a-z) -e GOARCH=$(ARCH) -e CGO_ENABLED=0 golang:${GO_VERSION} go build -ldflags "-s -w -X ${PKG}/version.Release=${TAG} -X ${PKG}/version.Commit=${Commit} -X ${PKG}/version.BuildDate=${BuildDate}" -o kube-state-metrics

test-unit: clean build
GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) $(TESTENVVAR) go test --race $(FLAGS) $(PKGS)
Expand All @@ -49,8 +49,8 @@ all-push: $(addprefix sub-push-,$(ALL_ARCH))

container: .container-$(ARCH)
.container-$(ARCH):
docker run --rm -v "$$PWD":/go/src/k8s.io/kube-state-metrics -w /go/src/k8s.io/kube-state-metrics -e GOOS=linux -e GOARCH=$(ARCH) -e CGO_ENABLED=0 golang:${GO_VERSION} go build -ldflags "-s -w -X ${PKG}/version.Release=${TAG} -X ${PKG}/version.Commit=${Commit} -X ${PKG}/version.BuildDate=${BuildDate}" -o kube-state-metrics
cp -r * $(TEMP_DIR)
GOOS=linux GOARCH=$(ARCH) $(BUILDENVVAR) go build -o $(TEMP_DIR)/kube-state-metrics
docker build -t $(MULTI_ARCH_IMG):$(TAG) $(TEMP_DIR)

ifeq ($(ARCH), amd64)
Expand Down
15 changes: 9 additions & 6 deletions collectors/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/kubernetes/pkg/util/node"
)

var (
Expand Down Expand Up @@ -352,12 +353,14 @@ func (pc *podCollector) collectPod(ch chan<- prometheus.Metric, p v1.Pod) {
labelKeys, labelValues := kubeLabelsToPrometheusLabels(p.Labels)
addGauge(podLabelsDesc(labelKeys), 1, labelValues...)

if p := p.Status.Phase; p != "" {
addGauge(descPodStatusPhase, boolFloat64(p == v1.PodPending), string(v1.PodPending))
addGauge(descPodStatusPhase, boolFloat64(p == v1.PodRunning), string(v1.PodRunning))
addGauge(descPodStatusPhase, boolFloat64(p == v1.PodSucceeded), string(v1.PodSucceeded))
addGauge(descPodStatusPhase, boolFloat64(p == v1.PodFailed), string(v1.PodFailed))
addGauge(descPodStatusPhase, boolFloat64(p == v1.PodUnknown), string(v1.PodUnknown))
if phase := p.Status.Phase; phase != "" {
addGauge(descPodStatusPhase, boolFloat64(phase == v1.PodPending), string(v1.PodPending))
addGauge(descPodStatusPhase, boolFloat64(phase == v1.PodSucceeded), string(v1.PodSucceeded))
addGauge(descPodStatusPhase, boolFloat64(phase == v1.PodFailed), string(v1.PodFailed))
// This logic is directly copied from: https://github.com/kubernetes/kubernetes/blob/d39bfa0d138368bbe72b0eaf434501dcb4ec9908/pkg/printers/internalversion/printers.go#L597-L601
// For more info, please go to: https://github.com/kubernetes/kube-state-metrics/issues/410
addGauge(descPodStatusPhase, boolFloat64(phase == v1.PodRunning && !(p.DeletionTimestamp != nil && p.Status.Reason == node.NodeUnreachablePodReason)), string(v1.PodRunning))
addGauge(descPodStatusPhase, boolFloat64(phase == v1.PodUnknown || (p.DeletionTimestamp != nil && p.Status.Reason == node.NodeUnreachablePodReason)), string(v1.PodUnknown))
}

if !p.CreationTimestamp.IsZero() {
Expand Down
35 changes: 33 additions & 2 deletions collectors/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/util/node"
)

type mockPodStore struct {
Expand Down Expand Up @@ -481,15 +482,35 @@ func TestPodCollector(t *testing.T) {
Namespace: "ns1",
},
Status: v1.PodStatus{
Phase: "Running",
Phase: v1.PodRunning,
},
}, {
ObjectMeta: metav1.ObjectMeta{
Name: "pod2",
Namespace: "ns2",
},
Status: v1.PodStatus{
Phase: "Pending",
Phase: v1.PodPending,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod3",
Namespace: "ns3",
},
Status: v1.PodStatus{
Phase: v1.PodUnknown,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "pod4",
Namespace: "ns4",
DeletionTimestamp: &metav1.Time{},
},
Status: v1.PodStatus{
Phase: v1.PodRunning,
Reason: node.NodeUnreachablePodReason,
},
},
},
Expand All @@ -504,6 +525,16 @@ func TestPodCollector(t *testing.T) {
kube_pod_status_phase{namespace="ns2",phase="Running",pod="pod2"} 0
kube_pod_status_phase{namespace="ns2",phase="Succeeded",pod="pod2"} 0
kube_pod_status_phase{namespace="ns2",phase="Unknown",pod="pod2"} 0
kube_pod_status_phase{namespace="ns3",phase="Failed",pod="pod3"} 0
kube_pod_status_phase{namespace="ns3",phase="Pending",pod="pod3"} 0
kube_pod_status_phase{namespace="ns3",phase="Running",pod="pod3"} 0
kube_pod_status_phase{namespace="ns3",phase="Succeeded",pod="pod3"} 0
kube_pod_status_phase{namespace="ns3",phase="Unknown",pod="pod3"} 1
kube_pod_status_phase{namespace="ns4",phase="Failed",pod="pod4"} 0
kube_pod_status_phase{namespace="ns4",phase="Pending",pod="pod4"} 0
kube_pod_status_phase{namespace="ns4",phase="Running",pod="pod4"} 0
kube_pod_status_phase{namespace="ns4",phase="Succeeded",pod="pod4"} 0
kube_pod_status_phase{namespace="ns4",phase="Unknown",pod="pod4"} 1
`,
metrics: []string{"kube_pod_status_phase"},
}, {
Expand Down
2 changes: 1 addition & 1 deletion scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ PROMETHEUS_VERSION=2.0.0
mkdir -p $KUBE_STATE_METRICS_LOG_DIR

# setup a Kubernetes cluster
curl -sLo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
curl -sLo minikube https://storage.googleapis.com/minikube/releases/v0.25.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/

minikube version

Expand Down
52 changes: 52 additions & 0 deletions vendor/golang.org/x/text/internal/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions vendor/golang.org/x/text/internal/internal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/golang.org/x/text/internal/match.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 43fcd3c

Please sign in to comment.