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

generic ephemeral volume: add metrics #99115

Merged
merged 3 commits into from Mar 2, 2021

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Feb 16, 2021

What type of PR is this?

/kind feature

What this PR does / why we need it:

As discussed during the production readiness review, a metric for the
PVC create operations is useful. The "ephemeral_volume" workqueue
metrics were already added in the initial implementation.

Special notes for your reviewer:

The new code follows the example set by the endpoints controller.

Does this PR introduce a user-facing change?

added `ephemeral_volume_controller_create[_failures]_total` counters to kube-controller-manager metrics

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

- [KEP]: https://github.com/pohly/enhancements/blob/master/keps/sig-storage/1698-generic-ephemeral-volumes/README.md#monitoring-requirements

/sig storage

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. sig/storage Categorizes an issue or PR as relevant to SIG Storage. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 16, 2021
@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 16, 2021
@pohly
Copy link
Contributor Author

pohly commented Feb 16, 2021

/retest

@jsafrane
Copy link
Member

/assign @gnufied

StabilityLevel: metrics.ALPHA,
},
[]string{"reason"},
)
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 provide an example of how metrics appear in prometheus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My tentative update of the KEP has such examples: https://github.com/kubernetes/enhancements/pull/2513/files

Is that what you were looking for or shall I add it here, for example to the commit message?

Copy link
Member

Choose a reason for hiding this comment

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

ah nvm. I also see this captured in release-notes.

@gnufied
Copy link
Member

gnufied commented Feb 22, 2021

Before we merge this change - do we know this metric can be extracted from api-server logs or api-server somehow? I would think that api-server logs should contain some information about incoming PVC creation requests (may not be as metric directly).

@pohly
Copy link
Contributor Author

pohly commented Feb 22, 2021

I would think that api-server logs should contain some information about incoming PVC creation requests (may not be as metric directly).

The ask from the production readiness review was explicitly to add metrics. Extracting the same information via log analysis might work, but it's simply not the same thing.

@gnufied
Copy link
Member

gnufied commented Feb 22, 2021

cc @kubernetes/sig-instrumentation-members @logicalhan

@gnufied
Copy link
Member

gnufied commented Feb 22, 2021

The ask from the production readiness review was explicitly to add metrics. Extracting the same information via log analysis might work, but it's simply not the same thing.

I understand. I am bit concerned about creating approximately 20-25 new timeseries metric because reason is being used a a dimension.

@pohly
Copy link
Contributor Author

pohly commented Feb 22, 2021

I am bit concerned about creating approximately 20-25 new timeseries metric because reason is being used a a dimension.

I have no strong opinion either way. I can implement whatever is considered appropriate for this feature. We can also reduce the status to just success/failure, status just seemed a bit more flexible. If we use a boolean, what are a good name and values for such a dimension?

reason = "Unknown"
}
}
ephemeralvolumemetrics.EphemeralVolumeCreate.WithLabelValues(reason).Inc()
Copy link
Member

Choose a reason for hiding this comment

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

Is reason practically bound here? What kind of values are we expecting here for this to be valuable?

@@ -279,6 +283,14 @@ func (ec *ephemeralController) handleVolume(pod *v1.Pod, vol v1.Volume) error {
Spec: ephemeral.VolumeClaimTemplate.Spec,
}
_, err = ec.kubeClient.CoreV1().PersistentVolumeClaims(pod.Namespace).Create(context.TODO(), pvc, metav1.CreateOptions{})
reason := ""
Copy link
Member

@brancz brancz Feb 23, 2021

Choose a reason for hiding this comment

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

Having reason possible to be an empty string is going to make querying this metric awkward. I think we probably want a label that distinguishes between success and failure, or have separate metrics for each of those.

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'm fine with a label success that has values yes and no. Is that okay or are there better names? I am not sure what is used elsewhere.

Copy link
Member

Choose a reason for hiding this comment

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

The best practice is to have two metrics one for failures and one for all. Then you can naturally query failures / total and understand the percentage. The number of series you produce is identical, so this doesn't produce any more load or anything on the metrics system than what we already have here.

Copy link
Contributor Author

@pohly pohly Feb 23, 2021

Choose a reason for hiding this comment

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

I've changed to to count ephemeral_volume_controller_create_total and ephemeral_volume_controller_create_failures. Is that okay?

Note that my updated tests initially failed because GetCounterMetricValue didn't work for a Counter. I'm including the fix for that (= adding the missing Metric interface implementation).

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that works!

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 23, 2021
@fedebongio
Copy link
Contributor

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Feb 23, 2021
@pohly
Copy link
Contributor Author

pohly commented Feb 23, 2021

/retest

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2021
@pohly
Copy link
Contributor Author

pohly commented Mar 2, 2021

@gnufied I had to rebase to get rid of the modified BUILD file. Can you lgtm again?

@brancz Can I get an lgtm from you, too? logicalhan is out.

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Mar 2, 2021
@pohly
Copy link
Contributor Author

pohly commented Mar 2, 2021

/remove-sig api-machinery

@k8s-ci-robot k8s-ci-robot removed the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Mar 2, 2021
@brancz
Copy link
Member

brancz commented Mar 2, 2021

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 2, 2021
@pohly
Copy link
Contributor Author

pohly commented Mar 2, 2021

/retest

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.

Just a tiny naming change to align with guidelines

EphemeralVolumeCreateFailures = metrics.NewCounter(
&metrics.CounterOpts{
Subsystem: EphemeralVolumeSubsystem,
Name: "create_failures",
Copy link
Member

Choose a reason for hiding this comment

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

I apologize for not catching this earlier. The guidelines are to always end counters with _total so this one needs that as well.

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, please take another look.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 2, 2021
@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 2, 2021
@brancz
Copy link
Member

brancz commented Mar 2, 2021

/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 Mar 2, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

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

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

As discussed during the production readiness review, a metric for the
PVC create operations is useful. The "ephemeral_volume" workqueue
metrics were already added in the initial implementation.

The new code follows the example set by the endpoints controller.
GetCounterMetricValue has an unchecked conversion to metrics.Metric,
something that didn't work for a *Counter because it didn't implement
that interface.
A CounterVector with status as label may create unnecessary overhead
and using the success case with the empty label value wasn't
easy. It's better to have two seperate counters, one for total number
of calls and one for failed calls.
@pohly
Copy link
Contributor Author

pohly commented Mar 2, 2021

/retest

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2021
@brancz
Copy link
Member

brancz commented Mar 2, 2021

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2021
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@k8s-ci-robot k8s-ci-robot merged commit d1a2af5 into kubernetes:master Mar 2, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.21 milestone Mar 2, 2021
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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants