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

feat(persistentvolume): claimRef info to labels #1244

Merged

Conversation

Duologic
Copy link
Contributor

@Duologic Duologic commented Oct 3, 2020

What this PR does / why we need it:

Adds a new metrics to provide claimRef information to Prometheus. In
tracking down lingering PVs, it would be of interest to know where the
PV came from. With the claimRef information, it is easier to track down
the resource owners and inform that they have unclaimed PVs lingering
around.

Main motivation is that PVs cost money at cloud providers, if PVs stick
around for long, the costs might increase significantly.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 3, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @Duologic!

It looks like this is your first PR to kubernetes/kube-state-metrics 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kube-state-metrics has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 3, 2020
@Duologic
Copy link
Contributor Author

Duologic commented Oct 3, 2020

I'm a bit unsure what to do best if there is no spec.claimRef. Feel free to put in some suggestions.

Copy link
Member

@lilic lilic 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 your PR, couple of comments and you need to also generate the docs, hence the failing tets.

internal/store/persistentvolume.go Outdated Show resolved Hide resolved
internal/store/persistentvolume.go Outdated Show resolved Hide resolved
internal/store/persistentvolume.go Outdated Show resolved Hide resolved
Metrics: []*metric.Metric{
{
LabelKeys: []string{
"apiversion",
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain the usecase for the apiserver value?

{
LabelKeys: []string{
"apiversion",
"kind",
Copy link
Member

Choose a reason for hiding this comment

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

Can this be anything else but PVC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to make an assumption here, the same reason I kept the apiversion around. I have no hard arguments to keep it around.

@brancz
Copy link
Member

brancz commented Oct 7, 2020

Can claimref change over the lifetime of a PV? If not then this would be a better fit for the general info metric I would say.

@Duologic
Copy link
Contributor Author

Considering a PV can exist without a PVC, a PV could be unclaimed and thus without a claimref, the claimref is added/updated by a process that binds a PV to a PVC. I do think that once the PV has a claimref, it is very unlikely that the name/namespace will change, but technically it could as it is part of the 'binding' process.

I'm up for adding it to the info metric, but I don't know what impact that change might have, feel free to tell me where to put it as I lack the confidence to make a decision. 😊

Upon reading a bit in random github issues to see how relevant the apiversion/kind is, they seem unlikely to contain anything else than v1/PVC, I think we can drop those labels because of that.

@lilic
Copy link
Member

lilic commented Oct 13, 2020

Upon reading a bit in random github issues to see how relevant the apiversion/kind is, they seem unlikely to contain anything else than v1/PVC, I think we can drop those labels because of that.

Yep my thinking exactly. 👍

@brancz
Copy link
Member

brancz commented Oct 16, 2020

Taking all this information into consideration, I would say: let's drop the kind/apiversion, and have this be a separate metric and not part of the info metric since there is a chance this may change over the lifetime of the PV.

@Duologic
Copy link
Contributor Author

That should do it, shall I squash it or do we do that on merge?

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.

Small nit on naming, then should be good to go.

internal/store/persistentvolume.go Outdated Show resolved Hide resolved
@brancz
Copy link
Member

brancz commented Oct 16, 2020

Let's squash the changes I'd say.

Adds a new metrics to provide claimRef information to Prometheus. In
tracking down lingering PVs, it would be of interest to know where the
PV came from. With the claimRef information, it is easier to track down
the resource owners and inform that they have unclaimed PVs lingering
around.

Main motivation is that PVs cost money at cloud providers, if PVs stick
around for long, the costs might increase significantly.
@Duologic Duologic force-pushed the duologic/persistentvolume_claimref branch from eddecae to 96b0183 Compare October 19, 2020 06:46
@Duologic
Copy link
Contributor Author

Addressed comments, squashed and rebased on current master.

@Duologic Duologic requested review from brancz and lilic October 19, 2020 06:49
Copy link
Member

@lilic lilic left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks for the contribution!

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Duologic, lilic

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 Oct 19, 2020
@k8s-ci-robot k8s-ci-robot merged commit 3117f5f into kubernetes:master Oct 19, 2020
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.

4 participants