Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@haircommander
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

CRI stats has been in sore need of an update, and is targeted to be updated in 1.23. Part of this update is support in the main CRI implementations.

This PR is partially a refactor and partially a feature. In includes cleaning up some code that wasn't actually used and was thus wasteful, bumping CRI to get the new pod level stats calls, adding a StatsServer to give the ability to cache the stats on a periodic basis (rather than collect on-demand, as is default).

There still should be some test updates, but integration tests will be hard before critools adds support for the new fields and cuts a release. In the meantime, lots of this is reviewable.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Add a [crio.stats] table to the config for configuring all things stats-related.
Add ability (with config field StatsCollectionPeriod) to calculate and save stats for pods and containers, rather than return them on demand.
Add support for {,List}PodSandboxStats, which allows the kubelet to take advantage of the PodAndContainerStatsFromCRI feature gate--one that is set to be alpha in 1.23.

@openshift-ci openshift-ci bot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Oct 26, 2021
@openshift-ci openshift-ci bot requested a review from kolyshkin October 26, 2021 22:05
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 26, 2021
@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #5427 (9dedd51) into main (31faba4) will decrease coverage by 0.06%.
The diff coverage is 29.84%.

❗ Current head 9dedd51 differs from pull request most recent head dec3bf5. Consider uploading reports for the commit dec3bf5 to get more accurate results

@@            Coverage Diff             @@
##             main    #5427      +/-   ##
==========================================
- Coverage   43.52%   43.45%   -0.07%     
==========================================
  Files         118      120       +2     
  Lines       11890    11924      +34     
==========================================
+ Hits         5175     5182       +7     
- Misses       6220     6245      +25     
- Partials      495      497       +2     


func UpdateWithMemoryStatsFromFile(memoryStatPath, inactiveFileSearchString string, memory *types.MemoryUsage, usage uint64) error {
var totalInactive uint64
f, err := os.Open(memoryStatPath)
Copy link

Choose a reason for hiding this comment

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

G304: Potential file inclusion via variable
(at-me in a reply with help or ignore)

@haircommander haircommander force-pushed the cri-stats-enhancement branch 5 times, most recently from 31e8e0b to 3644f70 Compare October 28, 2021 13:48
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 28, 2021
@haircommander
Copy link
Member Author

/test integration_fedora

@haircommander
Copy link
Member Author

/retest

@haircommander haircommander added this to the 1.23 milestone Nov 5, 2021
Copy link
Member

@saschagrunert saschagrunert 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 few nits, otherwise LGTM

@fidencio
Copy link
Contributor

fidencio commented Nov 8, 2021

@haircommander, can you hold this one till Tomorrow? I'd like to do a review (together with some local tests) on this later Today / Tomorrow morning.

Comment on lines +806 to +811
rssBytes = m.Memory.RSS
pageFaults = m.Memory.PgFault
majorPageFaults = m.Memory.PgMajFault
Copy link
Contributor

Choose a reason for hiding this comment

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

For kata-containers, this is the part that differs from the approach taken before and that we should ensure the CRI runtime has access to the correct information.

Those are collect, and then passed up to the CRI runtime, here:
https://github.com/kata-containers/kata-containers/blob/e89c06e68bcd465cc79dc68945751a706f230bfe/src/runtime/pkg/containerd-shim-v2/metrics.go#L98-L146

It means that, theoretically, from the kata-containers everything needed here is already provided by kata-containers, but I still need to get to do some more tests on this.

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2021
@haircommander
Copy link
Member Author

comments addressed, PTAL @cri-o/cri-o-maintainers

@saschagrunert
Copy link
Member

Unfortunately this needs a rebase.

@haircommander
Copy link
Member Author

rebased!

- drop unneeded fields from stats call
- remove unneeded variable
- replace internal Metadata with CRI type
- as well as add CRIAttributes function
- update with most remaining required fields for container stats

Signed-off-by: Peter Hunt <[email protected]>
Signed-off-by: Peter Hunt <[email protected]>
Copy link
Member

@saschagrunert saschagrunert left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 23, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 23, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haircommander, kolyshkin, saschagrunert

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [haircommander,kolyshkin,saschagrunert]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@haircommander
Copy link
Member Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 23, 2021

@haircommander: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/openshift-jenkins/e2e_crun_cgroupv2 dec3bf5 link false /test e2e_cgroupv2
ci/openshift-jenkins/integration_crun_cgroupv2 dec3bf5 link false /test integration_cgroupv2

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

@haircommander
Copy link
Member Author

/retest-required

@openshift-bot
Copy link

/retest-required

Please review the full test history for this PR and help us cut down flakes.

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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants