Skip to content

Commit

Permalink
Merge pull request #2005 from mrueg/prep-v2.8.1
Browse files Browse the repository at this point in the history
Prep v2.8.1
  • Loading branch information
k8s-ci-robot authored Feb 22, 2023
2 parents 2fd22c4 + f6f119c commit fb15826
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v2.8.1 / 2023-02-22

* [BUGFIX] Don't crash on non-existent paths @rexagod #1998
* [BUGFIX] Fix public Builder compatibility with BuilderInterface @clamoriniere #1994

## v2.8.0 / 2023-02-10

Note: The `--version` flag was removed as `kube-state-metrics version` also provides the same information. See #1956
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ OS ?= $(shell uname -s | tr A-Z a-z)
ALL_ARCH = amd64 arm arm64 ppc64le s390x
PKG = github.com/prometheus/common
PROMETHEUS_VERSION = 2.40.6
GO_VERSION = 1.19.4
GO_VERSION = 1.19.6
IMAGE = $(REGISTRY)/kube-state-metrics
MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
USER ?= $(shell id -u -n)
Expand Down Expand Up @@ -66,7 +66,8 @@ build-local:
build: kube-state-metrics

kube-state-metrics:
${DOCKER_CLI} run --rm -v "${PWD}:/go/src/k8s.io/kube-state-metrics" -w /go/src/k8s.io/kube-state-metrics -e GOOS=$(OS) -e GOARCH=$(ARCH) golang:${GO_VERSION} make build-local
# Need to update git setting to prevent failing builds due to https://github.com/docker-library/golang/issues/452
${DOCKER_CLI} run --rm -v "${PWD}:/go/src/k8s.io/kube-state-metrics" -w /go/src/k8s.io/kube-state-metrics -e GOOS=$(OS) -e GOARCH=$(ARCH) golang:${GO_VERSION} git config --global --add safe.directory "*" && make build-local

test-unit:
GOOS=$(shell uname -s | tr A-Z a-z) GOARCH=$(ARCH) $(TESTENVVAR) go test --race $(FLAGS) $(PKGS)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Generally, it is recommended to use the latest release of kube-state-metrics. If
| **v2.5.0** | v1.24 |
| **v2.6.0** | v1.24 |
| **v2.7.0** | v1.25 |
| **v2.8.0** | v1.26 |
| **v2.8.1** | v1.26 |
| **main** | v1.26 |


Expand All @@ -91,7 +91,7 @@ release.
#### Container Image

The latest container image can be found at:
* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.0` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`)
* `registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.1` (arch: `amd64`, `arm`, `arm64`, `ppc64le` and `s390x`)

### Metrics Documentation

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.8.0
2.8.1
2 changes: 1 addition & 1 deletion examples/autosharding/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
2 changes: 1 addition & 1 deletion examples/autosharding/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
rules:
- apiGroups:
Expand Down
2 changes: 1 addition & 1 deletion examples/autosharding/role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
roleRef:
Expand Down
2 changes: 1 addition & 1 deletion examples/autosharding/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
rules:
Expand Down
2 changes: 1 addition & 1 deletion examples/autosharding/service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
2 changes: 1 addition & 1 deletion examples/autosharding/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
spec:
Expand Down
6 changes: 3 additions & 3 deletions examples/autosharding/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
spec:
Expand All @@ -18,7 +18,7 @@ spec:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
spec:
automountServiceAccountToken: true
containers:
Expand All @@ -34,7 +34,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.0
image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.1
livenessProbe:
httpGet:
path: /healthz
Expand Down
2 changes: 1 addition & 1 deletion examples/standard/cluster-role-binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
2 changes: 1 addition & 1 deletion examples/standard/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
rules:
- apiGroups:
Expand Down
6 changes: 3 additions & 3 deletions examples/standard/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
spec:
Expand All @@ -17,11 +17,11 @@ spec:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
spec:
automountServiceAccountToken: true
containers:
- image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.0
- image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.8.1
livenessProbe:
httpGet:
path: /healthz
Expand Down
2 changes: 1 addition & 1 deletion examples/standard/service-account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
2 changes: 1 addition & 1 deletion examples/standard/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
labels:
app.kubernetes.io/component: exporter
app.kubernetes.io/name: kube-state-metrics
app.kubernetes.io/version: 2.8.0
app.kubernetes.io/version: 2.8.1
name: kube-state-metrics
namespace: kube-system
spec:
Expand Down
13 changes: 11 additions & 2 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import (
"k8s.io/kube-state-metrics/v2/pkg/options"
)

// Make sure the public Builder implements the public BuilderInterface.
// New internal Builder methods should be added to the public BuilderInterface.
var _ ksmtypes.BuilderInterface = &Builder{}

// Builder helps to build store. It follows the builder pattern
// (https://en.wikipedia.org/wiki/Builder_pattern).
type Builder struct {
Expand Down Expand Up @@ -61,6 +65,11 @@ func (b *Builder) WithNamespaces(n options.NamespaceList) {
b.internal.WithNamespaces(n)
}

// WithFieldSelectorFilter sets the fieldSelector property of a Builder.
func (b *Builder) WithFieldSelectorFilter(fieldSelectorFilter string) {
b.internal.WithFieldSelectorFilter(fieldSelectorFilter)
}

// WithSharding sets the shard and totalShards property of a Builder.
func (b *Builder) WithSharding(shard int32, totalShards int) {
b.internal.WithSharding(shard, totalShards)
Expand Down Expand Up @@ -103,8 +112,8 @@ func (b *Builder) WithAllowAnnotations(annotations map[string][]string) {
}

// WithAllowLabels configures which labels can be returned for metrics
func (b *Builder) WithAllowLabels(l map[string][]string) {
b.internal.WithAllowLabels(l)
func (b *Builder) WithAllowLabels(l map[string][]string) error {
return b.internal.WithAllowLabels(l)
}

// WithGenerateStoresFunc configures a custom generate store function
Expand Down
6 changes: 5 additions & 1 deletion pkg/customresourcestate/registry_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,11 @@ func (c compiledGauge) value(it interface{}) (*eachValue, error) {
Value: 0,
}, nil
}
// Don't error if there was not a type-casting issue (`toFloat64`), but rather a failed lookup.
// no it means no iterables were passed down, meaning that the path resolution never happened
if it == nil {
return nil, fmt.Errorf("got nil while resolving path")
}
// Don't error if there was not a type-casting issue (`toFloat64`).
return nil, nil
}
value, err := toFloat64(got, c.NilIsZero)
Expand Down
12 changes: 12 additions & 0 deletions pkg/customresourcestate/registry_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package customresourcestate

import (
"encoding/json"
"errors"
"reflect"
"testing"

Expand Down Expand Up @@ -194,6 +195,17 @@ func Test_values(t *testing.T) {
}, wantResult: []eachValue{
newEachValue(t, 1.6563744e+09),
}},
{name: "non-existent path", each: &compiledGauge{
compiledCommon: compiledCommon{
path: mustCompilePath(t, "foo"),
labelFromPath: map[string]valuePath{
"name": mustCompilePath(t, "name"),
},
},
ValueFrom: mustCompilePath(t, "creationTimestamp"),
}, wantResult: nil, wantErrors: []error{
errors.New("[foo]: got nil while resolving path"),
}},
{name: "array", each: &compiledGauge{
compiledCommon: compiledCommon{
path: mustCompilePath(t, "status", "condition_values"),
Expand Down

0 comments on commit fb15826

Please sign in to comment.