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

Add metrics for cleanup controller #399

Merged

Conversation

justinblalock87
Copy link
Contributor

@justinblalock87 justinblalock87 commented Jul 30, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Adds metrics to the local PV node cleanup controller.

Release note:

Add metrics to local PV node cleanup controller.

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 30, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @justinblalock87. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 30, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 30, 2023
@justinblalock87
Copy link
Contributor Author

/cc @msau42

@k8s-ci-robot k8s-ci-robot requested a review from msau42 July 31, 2023 16:12
@msau42
Copy link
Contributor

msau42 commented Jul 31, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 31, 2023

var (
// APIServerRequestsTotal is used to collect accumulated count of apiserver requests.
APIServerRequestsTotal = prometheus.NewCounterVec(
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like client-go may already have metrics we can leverage: https://github.com/kubernetes/client-go/blob/master/tools/metrics/metrics.go. workqueue also has metrics that may be good to gather.

I'm not 100% sure, but I think you can enable those + other standard metrics with k8s.io/component-base/metrics. Example: https://github.com/kubernetes-csi/csi-lib-utils/blob/85029276ff37ed0f2dce8fd14353f058bc527dc9/metrics/metrics.go#L30C3-L30C32

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@msau42 msau42 Aug 1, 2023

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

pkg/metrics/node-cleanup/metrics.go Outdated Show resolved Hide resolved
},
)
// PersistentVolumeClaimDeleteFailedTotal is used to collect accumulated count of persistent volume claim delete failed attempts.
PersistentVolumeClaimDeleteFailedTotal = prometheus.NewCounter(
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you also want a pvc delete total metric?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a pvc delete total metric above, do you mean pv delete total? I don't have pv delete total because since the PV Deleter runs on a set interval, if the interval is too low, it calls the apiserver to delete the PV multiple times, skewing the metrics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I mean PV delete total. I guess the issue is that the informer lister may be delayed at removing the entry after the delete API call.

One solution we have done in the past, is to create a 2nd level cache. And when we delete the API objects, we'll delete it from the 2nd level cache too: https://github.com/kubernetes-sigs/sig-storage-local-static-provisioner/blob/master/pkg/cache/cache.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that the cache itself may take a while to implement and the current time crunch, can I add a TODO in the controller to implement the cache. I'm not sure that it is feasible with the time constraints.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds fine. In the meantime, I would go ahead and add the metric in and document the caveat of having a short sync period.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@justinblalock87
Copy link
Contributor Author

justinblalock87 commented Jul 31, 2023

/kind feature

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 31, 2023
@justinblalock87
Copy link
Contributor Author

/remove-kind bug

@k8s-ci-robot k8s-ci-robot removed the kind/bug Categorizes issue or PR as related to a bug. label Aug 1, 2023
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 1, 2023
@msau42
Copy link
Contributor

msau42 commented Aug 1, 2023

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: justinblalock87, msau42

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 Aug 1, 2023
@k8s-ci-robot k8s-ci-robot merged commit a1c19d5 into kubernetes-sigs:master Aug 1, 2023
12 checks passed
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants