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

Skip to content

Conversation

@bitoku
Copy link
Contributor

@bitoku bitoku commented Oct 6, 2025

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

The log format has changed since #9334 .

We changed the format from %+v to %#v because we thought it sometimes failed to print structs, but it was actually because the structs didn't have values.
For example, VersionRequest is sometimes like &VersionRequest{Version:,}:

In 1.33, it's printed with %+v as

May 15 15:51:45 ci-op-fi2q3184-9d9a4-buildhost crio[9683]: time="2025-05-15T15:51:45.812030634Z" level=debug msg="Request: &VersionRequest{Version:,}" file="interceptors/interceptors.go:64" id=29ca6d2c-933d-4916-a16e-4bf01d1ea977 name=/runtime.v1.RuntimeService/Version

but since 1.34 (protobuf dependency change), it's printed %+v as

time="2025-10-06T11:25:36.83281109Z" level=debug msg="Request: " file="interceptors/interceptors.go:64" id=99be283b-8114-49ae-abab-d6d3b15eefcc name=/runtime.v1.RuntimeService/Version

It was not that %+v failed to print the struct, but it's just there's no fields to print.


After the change from %+v to %#v, some information was removed, For example, ContainerCreateRequest is printed with %#v:

time="2025-10-06T11:29:39.511274359Z" level=debug msg="Request: &v1.CreateContainerRequest{state:impl.MessageState{NoUnkeyedLiterals:pragma.NoUnkeyedLiterals{}, DoNotCompare:pragma.DoNotCompare{}, DoNotCopy:pragma.DoNotCopy{}, atomicMessageInfo:(*impl.MessageInfo)(0xc0007afe38)}, PodSandboxId:\"edf07957cd365dc1751e1250cefb1701c8b72f769656261d31ad5851980352f4\", Config:(*v1.ContainerConfig)(0xc00094b560), SandboxConfig:(*v1.PodSandboxConfig)(0xc000a986c0), unknownFields:[]uint8(nil), sizeCache:0}" file="interceptors/interceptors.go:64" id=f9244e40-b6d6-418d-a666-d81605f2fee0 name=/runtime.v1.RuntimeService/CreateContainer

but with %+v:

time="2025-10-06T11:31:26.492458734Z" level=debug msg="Request: pod_sandbox_id:\"c30f8a8d25835a21ff5dcfede7a12200799f70625cd06663cc692dcd70fab685\" config:{metadata:{name:\"trap\" attempt:1} image:{image:\"quay.io/crio/fedora-crio-ci:latest\" user_specified_image:\"quay.io/crio/fedora-crio-ci:latest\"} command:\"/bin/sh\" command:\"-c\" command:\"trap \\\"sleep 600\\\" TERM && sleep 600\" working_dir:\"/\" envs:{key:\"PATH\" value:\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\"} envs:{key:\"TERM\" value:\"xterm\"} envs:{key:\"GLIBC_TUNABLES\" value:\"glibc.pthread.rseq=0\"} envs:{key:\"TESTDIR\" value:\"test/dir1\"} envs:{key:\"TESTFILE\" value:\"test/file1\"} labels:{key:\"batch\" value:\"no\"} labels:{key:\"type\" value:\"small\"} annotations:{key:\"daemon\" value:\"crio\"} annotations:{key:\"owner\" value:\"dragon\"} linux:{resources:{cpu_period:10000 cpu_quota:20000 cpu_shares:512 memory_limit_in_bytes:268435456 oom_score_adj:30} security_context:{capabilities:{add_capabilities:\"setuid\" add_capabilities:\"setgid\"} namespace_options:{pid:CONTAINER} selinux_options:{user:\"system_u\" role:\"system_r\" type:\"svirt_lxc_net_t\" level:\"s0:c4,c5\"} run_as_user:{}}}} sandbox_config:{metadata:{name:\"podsandbox1\" uid:\"redhat-test-crio\" namespace:\"redhat.test.crio\" attempt:1} hostname:\"crictl_host\" dns_config:{servers:\"8.8.8.8\"} labels:{key:\"group\" value:\"test\"} annotations:{key:\"com.example.test\" value:\"sandbox annotation\"} annotations:{key:\"owner\" value:\"hmeng\"} annotations:{key:\"security.alpha.kubernetes.io/seccomp/pod\" value:\"unconfined\"} linux:{cgroup_parent:\"pod_123-456.slice\" security_context:{namespace_options:{pid:CONTAINER} selinux_options:{user:\"system_u\" role:\"system_r\" type:\"svirt_lxc_net_t\" level:\"s0:c4,c5\"}}}}" file="interceptors/interceptors.go:64" id=d2b976ef-cfaa-4c2f-b0b1-7819f4a62a70 name=/runtime.v1.RuntimeService/CreateContainer

So with %#v, Config and SandboxConfig are hidden. This will make it harder to debug.

This PR changes the format to %+v again, and added removed information about the type of request/response.
You can compare how the logs changed by comparing at the ci-cgroupv2-e2e-features CI journal logs.

Which issue(s) this PR fixes:

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Changed GRPC debug log format to be more informative

@bitoku bitoku requested a review from mrunalp as a code owner October 6, 2025 11:39
@openshift-ci openshift-ci bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Oct 6, 2025
@openshift-ci openshift-ci bot requested review from QiWang19 and klihub October 6, 2025 11:39
@codecov
Copy link

codecov bot commented Oct 6, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.05%. Comparing base (7a2820a) to head (d25f3a5).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9501   +/-   ##
=======================================
  Coverage   67.04%   67.05%           
=======================================
  Files         202      202           
  Lines       28159    28155    -4     
=======================================
- Hits        18880    18878    -2     
+ Misses       7702     7697    -5     
- Partials     1577     1580    +3     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

operation := filepath.Base(info.FullMethod)
newCtx, span := opentelemetry.Tracer().Start(AddRequestNameAndID(ctx, info.FullMethod), info.FullMethod)
log.Debugf(newCtx, "Request: %#v", req)
log.Debugf(newCtx, "Request: %T: %+v", req, req)
Copy link
Member

Choose a reason for hiding this comment

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

Good catch! Do we want to add a small integration test for this?

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Oct 6, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bitoku, 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:

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 6, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 9cfcb90 into cri-o:main Oct 6, 2025
74 of 76 checks passed
@bitoku
Copy link
Contributor Author

bitoku commented Oct 7, 2025

/cherry-pick release-1.34

@openshift-cherrypick-robot

@bitoku: new pull request created: #9503

Details

In response to this:

/cherry-pick release-1.34

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-sigs/prow repository.

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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

3 participants