-
Notifications
You must be signed in to change notification settings - Fork 2k
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 init container metrics #541
Conversation
pkg/collectors/pod_test.go
Outdated
|
||
type cs_to_prom func(cs v1.ContainerStatus, ns string, pod string) string | ||
|
||
pod_to_prom := func(p v1.Pod, fn_cs cs_to_prom, fn_ics cs_to_prom) string { |
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.
in hindsight, refactoring this code in these methods may have made it more complex. But it makes changing things around a breeze and adding more pods/containers.
pkg/collectors/pod_test.go
Outdated
return sb.String() | ||
} | ||
|
||
mk_cs := func(name string, id int, ready bool, rc int32) v1.ContainerStatus { |
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.
i might need to change the name of these methods. let me know
i'm going to test this in our cluster, but wanted to get it out to get feedback. |
pkg/collectors/pod_test.go
Outdated
# HELP kube_pod_labels Kubernetes labels converted to Prometheus labels. | ||
# TYPE kube_pod_labels gauge | ||
# HELP kube_pod_container_status_ready Describes whether the containers readiness check succeeded. | ||
# TYPE kube_pod_container_status_ready gauge | ||
# HELP kube_pod_container_status_restarts_total The number of container restarts per container. | ||
# TYPE kube_pod_container_status_restarts_total counter | ||
# HELP kube_pod_init_container_status_restarts_total The number of init container restarts per container. |
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.
Can you fix the indentation?
pkg/collectors/pod.go
Outdated
@@ -382,21 +431,30 @@ func (pc *podCollector) collectPod(ch chan<- prometheus.Metric, p v1.Pod) { | |||
|
|||
var lastFinishTime float64 | |||
|
|||
for _, cs := range p.Status.ContainerStatuses { | |||
addGauge(descPodContainerInfo, 1, | |||
collectContainerStatusMetric := func(cs v1.ContainerStatus, info *prometheus.Desc, waiting *prometheus.Desc, _waitingReason *prometheus.Desc, running *prometheus.Desc, terminated *prometheus.Desc, terminatedReason *prometheus.Desc, restarts *prometheus.Desc) { |
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.
How about instead of passing in each metric description as arguments to the function, just passing in a single boolean e.g. isInitContainer
. The function then decides which metric descriptions to use based on that. Should make this less verbose.
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.
I agree it would reduce the params but not sure if that make it less verbose.
if init {
desc1 = init_metrics_desc1
...
}
else {
desc1 = metrics_desc1
...
}
addGauge(metrics_desc1, 1)
If i can make the change if you strongly feel about it
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.
What do others think?
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.
how about a third way? we pass a map instead of each single description, that way we have a single parameter and we can initialize the map just like the descriptions
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.
Sounds good. I made the change.
fd9a67a
to
c9275b7
Compare
sorry, as I was rebasing it, the rebase changes got split across my commits. So I decided to squash them together for better readability. I'm going to test these changes in our cluster, but the PR is ready for final review. Let me know if you folks have more feedbacks. |
c9275b7
to
cb096c5
Compare
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Sorry lost track of this. /reopen |
@brancz: Reopened this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: thedebugger If they are not already assigned, you can assign the PR to them by writing 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 |
Sorry for the delay. This needs a rebase. |
@thedebugger would you be able to update this PR? |
@brancz @tariq1890 hey, i can try doing it but it is going to be a lot of work since the code has changed a lot. Could we have a smaller turn around time so that we can break this cycle? Let me know. |
Usually turn around is very fast for this project, not sure why we dropped the ball here. Sorry! |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What this PR does / why we need it:
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #502