-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add nil checks and debug logs for CNI client #4306
Conversation
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.
LGTM
@@ -48,9 +50,10 @@ func NewCNIClient(paths []string) CNI { | |||
func (c *cniClient) Add(ctx context.Context, config PluginConfig) (types.Result, error) { | |||
rt := BuildRuntimeConfig(config) | |||
net, err := BuildNetworkConfig(config) | |||
if err != nil { | |||
if err != nil || net == nil || net.Network == nil { |
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.
If the net is nil, will the err be nil or something else?
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.
Thanks, err would be nil, so that's not helpful at all. I'll update this.
Summary
Make additional nil checks after creating the network configuration to protect against panics due to the nested struct. Also add a debug log for operators.
Implementation details
Add 2 new separate nil checks and corresponding debug lines.
Testing
make test
New tests cover the changes: No new tests.
Description for the changelog
Add nil checks and debug logs for CNI client
Additional Information
Does this PR include breaking model changes? If so, Have you added transformation functions?
No
Does this PR include the addition of new environment variables in the README?
No
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.