-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check for nil values when importing container definition #8150
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
Check for nil values when importing container definition #8150
Conversation
Also, ensure that the "image" attribute has been provided. Signed-off-by: Krzysztof Wilczyński <[email protected]>
|
/assign kwilczynski |
|
/test ci-e2e |
saschagrunert
left a comment
There was a problem hiding this 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]>
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov ReportAttention: Patch coverage is
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 |
|
/test e2e-gcp-ovn |
|
/cherry-pick release-1.30 |
|
@kwilczynski: new pull request created: #8157 DetailsIn response to this:
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. |
|
/cherry-pick release-1.29 |
|
@kwilczynski: #8150 failed to apply on top of branch "release-1.29": DetailsIn response to this:
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. |
|
OK. Requires manual cherry-pick. |
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
nilwithin theContainerConfigtype, and attempting to access such object attributes to dereference them will result in a panic.Thus, add
nilcheck to ensure that theLinuxfield of theContainerConfigtype has been set before accessing any fields from within it, which would prevent a potential panic.While at it, add a
niland 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?