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

Skip to content

Conversation

@kolyshkin
Copy link
Collaborator

@kolyshkin kolyshkin commented Aug 10, 2020

/kind bug

  • test/stats.bats: fix typo in a variable name
  • test/stats.bats: improve test case
  • test/stats.bats: fix/improve container stats test case

See individual commits for more details.

Currently blocked by #4080 and #4068.

NONE

@wgahnagl @haircommander PTAL

@openshift-ci-robot openshift-ci-robot added dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/bug Categorizes issue or PR as related to a bug. labels Aug 10, 2020
@openshift-ci-robot openshift-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Aug 10, 2020
test/stats.bats Outdated
[ "$status" -eq 0 ]
ctr1_memory_bytes="$output"
run echo $ctr2_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value'
jq -e '.stats[0].attributes.id == "'$ctr2_id'"' <<< "$output"
Copy link
Member

Choose a reason for hiding this comment

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

we lost ctr1_memory_bytes here
I think these would be better if we just did

    ctr1_stats_JSON=$(crictl stats -o json --id "$ctr1_id")
    ctr2_stats_JSON=$(crictl stats -o json --id "$ctr2_id")
    ctr1_memory_bytes=$(echo $ctr1_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value')
    ctr2_memory_bytes=$(echo $ctr2_stats_JSON | jq -e '.stats[0].memory.workingSetBytes.value')

maybe echoing them between?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we lost ctr1_memory_bytes here

Sorry, I don't understand what you mean here. ctr1_memory_bytes is assigned here: 01813a8#diff-103e5e134054b75239970c4fbec2f5e0R68

I think these would be better if we just did

you're right, and it's better to take it one step further:

set -o pipefail
ctr1_mem=$(crictl stats -o json --id "$ctr1_id" | jq -e '.stats[0].memory.workingSetBytes.value')
ctr2_mem=$(crictl stats -o json --id "$ctr2_id" | jq -e '.stats[0].memory.workingSetBytes.value')

maybe echoing them between

please see the updated commit.

Initially I wanted to change as little as possible. Ended up with more radical approach. Let me know what you think.

@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #4064 into master will increase coverage by 0.27%.
The diff coverage is 42.42%.

@@            Coverage Diff             @@
##           master    #4064      +/-   ##
==========================================
+ Coverage   41.11%   41.39%   +0.27%     
==========================================
  Files         109      110       +1     
  Lines        9030     9061      +31     
==========================================
+ Hits         3713     3751      +38     
+ Misses       4978     4970       -8     
- Partials      339      340       +1     

@haircommander
Copy link
Member

I am also looking at this, it seems the test needs a bit more love...

@haircommander
Copy link
Member

@kolyshkin wdyt about 71d459d
along with ac89cc3
for this PR?

@kolyshkin
Copy link
Collaborator Author

wdyt about 71d459d

Makes sense. Added on top of my changes under your authorship, PTAL @haircommander

One issue though is I'm not sure if memory usage will be different in this case :-\

@openshift-ci-robot openshift-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 11, 2020
@kolyshkin
Copy link
Collaborator Author

/retest

@kolyshkin
Copy link
Collaborator Author

kolyshkin commented Aug 11, 2020

One issue though is I'm not sure if memory usage will be different in this case :-\

As I suspected :(

 not ok 162 container stats
 # (in test file ./stats.bats, line 60)
 #   `[ "$ctr1_mem" != "$ctr2_mem" ]' failed

I think we need to run one redis and one sleep container. @wgahnagl @haircommander WDYT?

@kolyshkin
Copy link
Collaborator Author

Nope, it's actually worse:

# time="2020-08-11 19:45:37.742730039Z" level=debug msg="Unable to account working set stats: total_inactive_file (1572753408) > memory usage (585728)" file="oci/oci_linux.go:93"
# time="2020-08-11 19:45:37.742849336Z" level=debug msg="Response: &ListContainerStatsResponse{Stats:[]*ContainerStats{&ContainerStats{Attributes:&ContainerAttributes{Id:40b7b98e5cec3e9a707e08bea4148321651e449e292e0798a293d1ced034dc42,Metadata:&ContainerMetadata{Name:podsandbox1-sleep2,Attempt:0,},Labels:map[string]string{},Annotations:map[string]string{pod: podsandbox,},},Cpu:&CpuUsage{Timestamp:1597175137741166571,UsageCoreNanoSeconds:&UInt64Value{Value:14685727,},},Memory:&MemoryUsage{Timestamp:1597175137741166571,WorkingSetBytes:&UInt64Value{Value:0,},},WritableLayer:nil,},},}" file="go-grpc-middleware/chain.go:25" id=262d79c6-f8a0-4482-9361-28c17833a167 name=/runtime.v1alpha2.RuntimeService/ListContainerStats
# 
# checking  != 

@kolyshkin
Copy link
Collaborator Author

With the fix from #4068 the stats are returned now, but not picked up by the test. Looking...

# time="2020-08-12 00:57:03.836301478Z" level=debug msg="Response: &ListContainerStatsResponse{Stats:[]*ContainerStats{&ContainerStats{Attributes:&ContainerAttributes{Id:8c76cf6cc3b5378f03a4cd07a7ca1d187b49af2b42682ebabe5112c3049535fd,Metadata:&ContainerMetadata{Name:podsandbox1-sleep2,Attempt:0,},Labels:map[string]string{},Annotations:map[string]string{pod: podsandbox,},},Cpu:&CpuUsage{Timestamp:1597193823835530399,UsageCoreNanoSeconds:&UInt64Value{Value:16799547,},},Memory:&MemoryUsage{Timestamp:1597193823835530399,WorkingSetBytes:&UInt64Value{Value:442368,},},WritableLayer:nil,},},}" file="go-grpc-middleware/chain.go:25" id=2c85e237-7ddc-4124-a5fc-2e815c496fd1 name=/runtime.v1alpha2.RuntimeService/ListContainerStats

@kolyshkin
Copy link
Collaborator Author

The test is passing now, but failing with CONTAINER_CGROUP_MANAGER=cgroupfs. Looking...

@kolyshkin
Copy link
Collaborator Author

The test is passing now, but failing with CONTAINER_CGROUP_MANAGER=cgroupfs. Looking...

The issue ^^^ is filed as #4075, and the fix is in #4080. Moving this one to draft until the fix is merged.

@kolyshkin kolyshkin marked this pull request as draft August 14, 2020 04:52
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 14, 2020
@kolyshkin
Copy link
Collaborator Author

So, this one is blocked by #4080 and #4068 -- once they are merged, this test cases should pass with flying colors.

As pointed out by shellcheck:

> In test/stats.bats line 72:
>     run crictl stats -o json "$crt2_id"
>                               ^------^ SC2154: crt2_id is referenced but not assigned.

The test works just fine though, because

 1. it is the same as running crictl stats without ID, in which case it
    shows stats for all IDs.

 2. the values obtained are not compared in any way, just printed.

Signed-off-by: Kir Kolyshkin <[email protected]>
1. Ensure that stats are shown for the particular ID.

2. Simplify json checks:
   - use "here file" instead of echo and pipe
   - remove intermediate variable
   - remove useless run and status checks (set -e is sufficient

Signed-off-by: Kir Kolyshkin <[email protected]>
kolyshkin and others added 2 commits August 19, 2020 17:03
1. Make sure we actually compare the memory usage, rather than merely
   printing it. Add a comment describing what we're doing here.

2. Use "here file" instead of echo.

3. Make sure stats are provided for the given id.

4. Consolidate getting memory usage so there are less temp variables.

5. When possible, use

	var=$(cmd ... 2>&1)
	echo "$var"

   instead of

	run cmd ...
	[ "$status" -eq 0 ]
	echo "$output"
	var="$output"

   They are roughly the same, and `set -e` (set by bats) implicitly
   checks the exit code. The `2>&1` stance is needed to see the error

Signed-off-by: Kir Kolyshkin <[email protected]>
container_redis.json seems to intermittantly exit, which makes using it
as the basis for comparison for stats tretcherous.

Signed-off-by: Peter Hunt <[email protected]>
@kolyshkin
Copy link
Collaborator Author

rebased on top of the current master since #4080 and #4068 are merged now

@kolyshkin kolyshkin marked this pull request as ready for review August 20, 2020 06:40
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2020
@kolyshkin
Copy link
Collaborator Author

CI status failed to update again :-/ (and, according to tide, everything is green)

/retest

@kolyshkin
Copy link
Collaborator Author

/test integration_crun

@kolyshkin
Copy link
Collaborator Author

/retest

2 similar comments
@kolyshkin
Copy link
Collaborator Author

/retest

@kolyshkin
Copy link
Collaborator Author

/retest

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 21, 2020
@kolyshkin
Copy link
Collaborator Author

/retest

@openshift-ci-robot
Copy link

@kolyshkin: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/openshift-jenkins/e2e_crun_cgroupv2 3472cc5 link /test e2e_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.

@umohnani8
Copy link
Member

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2020
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kolyshkin, mrunalp, 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 [mrunalp,saschagrunert]

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

@mrunalp mrunalp merged commit cca8df4 into cri-o:master Aug 25, 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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. kind/bug Categorizes issue or PR as related to a bug. 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