Skip to content
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

Export Job's owner #681

Merged
merged 2 commits into from
Feb 26, 2019
Merged

Export Job's owner #681

merged 2 commits into from
Feb 26, 2019

Conversation

zuzzas
Copy link
Contributor

@zuzzas zuzzas commented Feb 25, 2019

What this PR does / why we need it:

This PR adds a Job's object owner metric similar to the Pod's owner. It is quite helpful when trying to correlate Jobs and CronJobs.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 25, 2019
Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good, just one comment and this needs a rebase.

if len(owners) == 0 {
ms = append(ms, &metric.Metric{
LabelKeys: labelKeys,
LabelValues: []string{"<none>", "<none>", "<none>"},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no metric should be appended if none exists, in prometheus that's queryable through the absent function

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aye, I've had the same concern, but I've taken the Pod collector as a reference. There is no such machinery there.
https://github.com/kubernetes/kube-state-metrics/blob/master/internal/collector/pod.go#L121

Copy link
Contributor Author

@zuzzas zuzzas Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be good to leave it as it is to preserve uniformity in how we present metrics.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. @brancz as changing this in pod.go would be a breaking change, should we do this with the v2.0 release?

Copy link
Member

@brancz brancz Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it right in this case, and add the pod case to the 2.0 release tracking issue: #569.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zuzzas IIUC, you need to delete the logic for appending <none> value metrics when the owners are empty as what @brancz proposed in comment https://github.com/kubernetes/kube-state-metrics/pull/681/files#r259773399

Copy link
Contributor Author

@zuzzas zuzzas Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That I understood, @andyxning. My question was about the case in Pod collector, which works differently. Right now my curiosity is satisfied and I'm adding a new feature.

Copy link
Contributor Author

@zuzzas zuzzas Feb 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done that in a separate commit: 15b93c4

Copy link
Contributor

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for preparing the patch!

internal/collector/job_test.go Outdated Show resolved Hide resolved
if len(owners) == 0 {
ms = append(ms, &metric.Metric{
LabelKeys: labelKeys,
LabelValues: []string{"<none>", "<none>", "<none>"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. @brancz as changing this in pod.go would be a breaking change, should we do this with the v2.0 release?

Signed-off-by: Andrey Klimentyev <andrey.klimentyev@flant.com>
Signed-off-by: Andrey Klimentyev <andrey.klimentyev@flant.com>
@brancz
Copy link
Member

brancz commented Feb 26, 2019

Thanks!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brancz, zuzzas

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2019
@k8s-ci-robot k8s-ci-robot merged commit 563ae1b into kubernetes:master Feb 26, 2019
@xiaoxi1989
Copy link

why not add owner info to pod metric?
like:
kube_pod_status_phase{endpoint="https-main",instance="10.128.0.119:8443",job="kube-state-metrics",namespace="grpc-test",phase="Pending",pod="cxxtest-b78d5b566-gkhds",service="kube-state-metrics", deploy="cxxtest"}

@brancz
Copy link
Member

brancz commented Aug 15, 2019

there can be multiple owners

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants