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

KEP-2371: Add cgroup metrics + CRI implementation plan #3559

Merged
merged 1 commit into from
Oct 6, 2022

Conversation

danielye11
Copy link
Contributor

  • One-line PR description: Updating KEP with cgroup stats of cadvisor metrics, adding CRI implementation details
  • Other comments:

@k8s-ci-robot k8s-ci-robot added the kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory label Sep 27, 2022
@k8s-ci-robot
Copy link
Contributor

Welcome @danielye11!

It looks like this is your first PR to kubernetes/enhancements 🎉. 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/enhancements 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. 😃

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Sep 27, 2022

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added sig/node Categorizes an issue or PR as relevant to SIG Node. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 27, 2022
@k8s-ci-robot
Copy link
Contributor

Hi @danielye11. Thanks for your PR.

I'm waiting for a kubernetes 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 cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 27, 2022
| |N/A |container_memory_max_usage_bytes |N/A |cAdvisor |CRI or N/A | memory.max_usage_in_bytes | memory.max
| |N/A |container_memory_swap |N/A |cAdvisor |CRI or N/A | (memory.stat) swap | memory.swap.current - memory.current
|ProcessStats |ProcessCount |container_processes |Pod |cAdvisor |CRI | Process
|AcceleratorStats |Make |N/A (too lazy to find the mapping) |Container |cAdvisor |cAdvisor or N/A | accelerators/nvidia.go | accelerators/nvidia.go
Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK we still plan on dropping these. do we need to include them in this change?

@haircommander
Copy link
Contributor

table update LGTM, one question about a new addition. You also need to sign the CLA, and I would prefer if all of the commits were squashed together

@danielye11 danielye11 force-pushed the cri-api branch 3 times, most recently from 7a39434 to 822dae3 Compare October 1, 2022 04:16
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Oct 1, 2022
Comment on lines 480 to 494
message ListPodSandboxMetricsResponse {
repeated PodSandboxMetrics pod_metrics= 1;
repeated ContainerMetrics container_metrics = 2;
}

message PodSandboxMetrics {
string pod_sandbox_id = 1;
repeated Metric metrics = 2;
}

message ContainerMetrics {
string container_id = 1;
repeated Metric metrics = 2;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

based on the structure of other CRI calls, I think I'd expect this more to be

essage ListPodSandboxMetricsResponse {
    repeated PodSandboxMetrics pod_metrics= 1;
}
message PodSandboxMetrics {
    string pod_sandbox_id = 1;
    repeated Metric metrics = 2;
    repeated ContainerMetrics container_metrics = 3;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Restructured

message ListPodSandboxMetricsRequest {}

message ListPodSandboxMetricsResponse {
repeated PodSandboxMetrics pod_metrics= 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: missing space beteween s and =

@@ -286,8 +286,7 @@ as cAdvisor is fine tuned to perform in an adequate manner.
### Stats Summary API

#### CRI Implementation
The CRI implementation will need to be extended to support reporting the full set of container-level from the [Summary API](#summary-container-stats-object).

The CRI implementation will need to be extended to support reporting the full set of container-level from the [Summary API](#summary-container-stats-object). A new GRPC call will also be added to the CRI that allows reporting for metrics currently exported by cAdvisor, but are outside the scope of the Summary API. This new GRPC call will return a Prometheus metric based response which Kubelet can export. Additionally, a feature gate will be added to only report Prometheus based metrics from the CRI when calling /stats endpoint. The additional metrics we support will need to be added to the individual container runtimes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, a feature gate will be added to only report Prometheus based metrics from the CRI when calling /stats endpoint.

1: I thought we'd reuse PodAndContainerStatsFromCRI for this?
2: isn't it /metrics/cadvisor not /stats

Copy link
Contributor

Choose a reason for hiding this comment

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

3: nit, I believe the capitalization is gRPC

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, updated in commit

@haircommander
Copy link
Contributor

/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 Oct 3, 2022
@haircommander
Copy link
Contributor

linter is saying to run hack/update-toc.sh

@haircommander
Copy link
Contributor

/lgtm

@bobbypage @mrunalp @derekwaynecarr PTAL

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2022
@bobbypage
Copy link
Member

Few small comments.

Thanks for updating the KEP, LGTM on the changes proposed.

/lgtm

@bobbypage
Copy link
Member

bobbypage commented Oct 3, 2022

One more thing, can you please also update https://github.com/kubernetes/enhancements/blob/master/keps/sig-node/2371-cri-pod-container-stats/kep.yaml#L20 to update latest-milestone from v1.25 to v1.26

This will address comment in #2371 (comment)

Thanks!

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2022
@danielye11
Copy link
Contributor Author

Updated latest-milestone to 1.26

@bobbypage
Copy link
Member

Thanks for updating

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 3, 2022
@bobbypage
Copy link
Member

/cc @dashpole

per SIG instrumentation

@k8s-ci-robot k8s-ci-robot requested a review from dashpole October 3, 2022 22:40
@@ -286,8 +287,7 @@ as cAdvisor is fine tuned to perform in an adequate manner.
### Stats Summary API

#### CRI Implementation
The CRI implementation will need to be extended to support reporting the full set of container-level from the [Summary API](#summary-container-stats-object).

The CRI implementation will need to be extended to support reporting the full set of container-level from the [Summary API](#summary-container-stats-object). A new gRPC call will also be added to the CRI that allows reporting for metrics currently exported by cAdvisor, but are outside the scope of the Summary API. This new gRPC call will return a Prometheus metric based response which Kubelet can export. Additionally, `PodAndContainerStatsFromCRI` feature gate support will be added to only report Prometheus based metrics from the CRI when calling `/metrics/cadvisor` endpoint when the feature gate is enabled. The additional metrics we support will need to be added to the individual container runtimes.
Copy link
Contributor

Choose a reason for hiding this comment

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

From previous release, the PRR Questionnaire section for "Does enabling the feature change any default behavior?" said "Enabling this behavior means some stats endpoints will not be filled: some entries in /metrics/cadvisor"

Is this still accurate with this change? Is there anything about the structure of the metrics or what metrics are available that should be included in that PRR section?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah this is still true. accelerator metrics, for instance, are being dropped. The table at the top has a column dedicated to saying whether we're aiming to support them

}

message Metric {
int64 timestamp = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are container runtimes expected to return cached (with timestamp in the past) metrics?

What if a container runtime wants to return "fresh" metrics each time this is called? Is there a way to omit the timestamp from the metric. I believe it is recommended to omit the timestamp from the prometheus exposition when that is the case.

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 believe container runtimes will return "fresh" metrics whenever the gRPC call ListPodSandboxMetrics is called (at least on containerd side) so I think it makes sense to have the timestamp. I suppose depending on container runtime implementations there can be cached metrics. We keep Metric and make another type similar to it that does not include timestamp.

Copy link
Contributor

Choose a reason for hiding this comment

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

we also could interpret a timestamp of 0 to mean omitted and leave it up to the CRI to say when they were collected (or say it was instantaneous)

Copy link
Contributor

Choose a reason for hiding this comment

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

If metrics are fresh, there is no need to attach timestamps. The timestamp will not be meaningfully different from the scrape time, and should not be attached to prometheus metrics.

Disk usage metrics in particular can be very expensive to collect, and are likely to be cached.

A timestamp of 0 meaning no timestamp works for me, but should be documented in the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to enforce they must be fresh. a CRI impl may want to cache them (cri-o may...). I think timestamp 0 as fresh is a good way to express it

Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

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

This is a reasonable approach. A few drawbacks that are worth including in the Drawbacks section:

  • This doesn't enforce that container runtimes continue to support the full /metrics/cadvisor endpoint. CRI implementations appear to be free to deviate and produce different metrics as they see fit.
  • Compared with the container runtime exposing these metrics directly, there is significant complexity (I have to implement a new CRI function using prometheus metrics as input), and some overhead from converting between prometheus, the CRI format, and back.

Update README.md

Update README.md

Add cpu stat linux cgroups v1

Add additional cgroup stats

Add some more v1 stats

Add v2 cpu metrics

Add spacing

Add additional v2 stats

Add spacing

Add network stats

Fix spacing

remove column

one network stat

commit

add

Add spacing

Add spacing

Add network stats

Add stats

Add v2 process usage stats

Add cri implementation plan

Update KEP with CRI API

Refactor CRI implementation

Resolve reviewer comments

Fix capitalization

Add backticks

Fix linting

Update latest-milestone

Clarify fresh metrics
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 6, 2022
@derekwaynecarr
Copy link
Member

for sig-node

/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 Oct 6, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielye11, derekwaynecarr

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 6, 2022
@k8s-ci-robot k8s-ci-robot merged commit f0a1067 into kubernetes:master Oct 6, 2022
@k8s-ci-robot k8s-ci-robot added this to the v1.26 milestone Oct 6, 2022
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/kep Categorizes KEP tracking issues and PRs modifying the KEP directory 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. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
Development

Successfully merging this pull request may close these issues.

7 participants