New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retention policy metrics for KEP-1847 #1876
Conversation
/retest |
/retest |
c71fd2a
to
64a468c
Compare
/retest |
Hi, this is failing the e2e tests because the field in question is behind a feature gate. I have a conversation going on kubernetes/kubernetes#111299 which led to this PR, but haven't gotten any response. Does anyone here have any hints on how to get around the feature gate problem? Thanks! |
internal/store/statefulset_test.go
Outdated
@@ -63,6 +63,7 @@ func TestStatefulSetStore(t *testing.T) { | |||
# HELP kube_statefulset_created [STABLE] Unix creation timestamp | |||
# HELP kube_statefulset_labels [STABLE] Kubernetes labels converted to Prometheus labels. | |||
# HELP kube_statefulset_metadata_generation [STABLE] Sequence number representing a specific generation of the desired state for the StatefulSet. | |||
# HELP kube_statefulset_persistent_volume_claim_retention_policy Count of retention policy for StatefulSet template PVCs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation here seems to be off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx, tabs vs spaces is the gift that keeps on giving...
internal/store/statefulset_test.go
Outdated
if err := c.run(); err != nil { | ||
t.Errorf("unexpected collecting result in %vth run:\n%s", i, err) | ||
t.Errorf("unexpected collecting result in %v%s run:\n%s", i+1, ord, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.Errorf("unexpected collecting result in %v%s run:\n%s", i+1, ord, err) | |
t.Errorf("unexpected collecting result in run %v:\n%s" i, err) |
Let's reduce complexity here and rephrase the error message instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, note that we need to use i+1 to have the index match the names used in the test cases (which is the practical way to figure out which test failed).
@mrueg thanks for the comments, do you have any advice on the e2e test failure? I'm stuck with what to do. |
This seems to the be error:
Is this a new field? |
Yes, exactly. I guess I can just remove the new field from the testing manifest, and skip e2e testing on this feature? |
examples/standard/deployment.yaml
Outdated
@@ -21,7 +21,7 @@ spec: | |||
spec: | |||
automountServiceAccountToken: true | |||
containers: | |||
- image: registry.k8s.io/kube-state-metrics/kube-state-metrics:v2.6.0 | |||
- image: registry.k8s.io/kube-state-metrics/kube-state-metrics-amd64:v2.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got probably added by accident
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah everytime I run the e2e tests by hand this gets change :-/
5f5af02
to
0a8b56d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
internal/store/statefulset.go
Outdated
@@ -193,6 +193,30 @@ func statefulSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) [ | |||
} | |||
}), | |||
), | |||
*generator.NewFamilyGeneratorWithStability( | |||
"kube_statefulset_persistent_volume_claim_retention_policy", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"kube_statefulset_persistent_volume_claim_retention_policy", | |
"kube_statefulset_persistentvolumeclaim_retention_policy", |
Since we are talking about the PersistentVolumeClaim
kubernetes resource, it should be put in one word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
internal/store/statefulset_test.go
Outdated
@@ -95,6 +97,7 @@ func TestStatefulSetStore(t *testing.T) { | |||
kube_statefulset_status_observed_generation{namespace="ns1",statefulset="statefulset1"} 1 | |||
kube_statefulset_replicas{namespace="ns1",statefulset="statefulset1"} 3 | |||
kube_statefulset_metadata_generation{namespace="ns1",statefulset="statefulset1"} 3 | |||
kube_statefulset_persistent_volume_claim_retention_policy{namespace="ns1",statefulset="statefulset1",when_deleted="nil",when_scaled="nil"} 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the retention policy is nil it would be better to not expose the metric since it doesn't bring much value and the less timeseries we have to store, the better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
docs/statefulset-metrics.md
Outdated
@@ -11,6 +11,7 @@ | |||
| kube_statefulset_status_observed_generation | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> | STABLE | | |||
| kube_statefulset_replicas | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> | STABLE | | |||
| kube_statefulset_metadata_generation | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> | STABLE | | |||
| kube_statefulset_persistent_volume_claim_retention_policy | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> <br> `when_deleted`=<statefulset-when-deleted-pvc-policy> <br> `when_scaled`=<statefulset-when-scaled-pvc-policy> | ALPHA | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| kube_statefulset_persistent_volume_claim_retention_policy | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> <br> `when_deleted`=<statefulset-when-deleted-pvc-policy> <br> `when_scaled`=<statefulset-when-scaled-pvc-policy> | ALPHA | | |
| kube_statefulset_persistentvolumeclaim_retention_policy | Gauge | `statefulset`=<statefulset-name> <br> `namespace`=<statefulset-namespace> <br> `when_deleted`=<statefulset-when-deleted-pvc-policy> <br> `when_scaled`=<statefulset-when-scaled-pvc-policy> | ALPHA | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, just saw the presubmit fail on that :-) thx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
@mrueg Any other comments? Sorry to be a pest but this is blocking a k8s change that wants to make the code freeze. Thank you for your quick review! |
Thanks for the contribution! /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: logicalhan, mattcary, mrueg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
Add metrics for new StatefulSet fields from KEP-1847.
How does this change affect the cardinality of KSM: (increases, decreases or does not change cardinality)
Increases it by adding a new metric that has a cardinality of 5 x # stateful sets.