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

Skip to content

Conversation

@kwilczynski
Copy link
Contributor

@kwilczynski kwilczynski commented May 8, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

The Protocol Buffers specification does not mandate that the Linux Resources for a container definition be present or that any of its attributes be required—most values are left to be the default, often unset, values. This means that the container definition stored as JSON document also does not require nor mandate that the "linux" attribute (with any of its sub-attributes) has to be present, etc. As such, once the JSON document is parsed, any missing sections will be set to nil within the ContainerConfig type, and attempting to access such object attributes to dereference them will result in a panic.

Thus, add nil check to ensure that the Linux field of the ContainerConfig type has been set before accessing any fields from within it, which would prevent a potential panic.

While at it, add a nil and empty value check to verify whether the "image" section and attribute have been set, making it the one and only mandatory field within the JSON document that is the container definition. This also short-circuits error handling further down the execution stack, so we can fail early instead.

Which issue(s) this PR fixes:

Fixes #8083.

Special notes for your reviewer:

None

Does this PR introduce a user-facing change?

Check for nil values when importing container definition for a given container checkpoint to be restored.

Also, ensure that the "image" attribute has been provided.

Signed-off-by: Krzysztof Wilczyński <[email protected]>
@kwilczynski kwilczynski requested a review from mrunalp as a code owner May 8, 2024 10:08
@kwilczynski kwilczynski self-assigned this May 8, 2024
@openshift-ci openshift-ci bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels May 8, 2024
@kwilczynski
Copy link
Contributor Author

/assign kwilczynski

@kwilczynski kwilczynski changed the title Check for nil values when importing container definition [WIP] Check for nil values when importing container definition May 8, 2024
@openshift-ci openshift-ci bot requested review from QiWang19 and wgahnagl May 8, 2024 10:09
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2024
@kwilczynski
Copy link
Contributor Author

/test ci-e2e

@kwilczynski kwilczynski changed the title [WIP] Check for nil values when importing container definition Check for nil values when importing container definition May 8, 2024
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 8, 2024
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 nit, otherwise LGTM. 👍

Co-authored-by: Sascha Grunert <[email protected]>
Signed-off-by: Krzysztof Wilczyński <[email protected]>
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label May 8, 2024
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kwilczynski, 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 May 8, 2024
@codecov
Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 49.56%. Comparing base (2afe77b) to head (794ce67).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8150      +/-   ##
==========================================
- Coverage   49.57%   49.56%   -0.01%     
==========================================
  Files         153      153              
  Lines       16927    16930       +3     
==========================================
+ Hits         8391     8392       +1     
- Misses       7489     7490       +1     
- Partials     1047     1048       +1     

@kwilczynski
Copy link
Contributor Author

/test e2e-gcp-ovn

@openshift-merge-bot openshift-merge-bot bot merged commit 9712c53 into cri-o:main May 8, 2024
@kwilczynski kwilczynski deleted the fix/linux-resources-nil-panic branch May 8, 2024 23:54
@kwilczynski
Copy link
Contributor Author

kwilczynski commented May 9, 2024

/cherry-pick release-1.30

@openshift-cherrypick-robot

@kwilczynski: new pull request created: #8157

Details

In response to this:

/cherry-pick release-1.30
/cherry-pick release-1.29

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.

@kwilczynski
Copy link
Contributor Author

/cherry-pick release-1.29

@openshift-cherrypick-robot

@kwilczynski: #8150 failed to apply on top of branch "release-1.29":

Applying: Check for nil values when importing container definition
Using index info to reconstruct a base tree...
M	server/container_restore.go
Falling back to patching base and 3-way merge...
Auto-merging server/container_restore.go
CONFLICT (content): Merge conflict in server/container_restore.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Check for nil values when importing container definition
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

Details

In response to this:

/cherry-pick release-1.29

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.

@kwilczynski
Copy link
Contributor Author

OK. Requires manual cherry-pick.

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.

crio is crashed during container restore

3 participants