Skip to content
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

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Add nil checks and debug logs for CNI client #4306

merged 1 commit into from
Aug 27, 2024

Conversation

ohsoo
Copy link
Contributor

@ohsoo ohsoo commented Aug 22, 2024

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.

Copy link
Contributor

@JoseVillalta JoseVillalta left a comment

Choose a reason for hiding this comment

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

LGTM

@ohsoo ohsoo marked this pull request as ready for review August 23, 2024 16:02
@ohsoo ohsoo requested a review from a team as a code owner August 23, 2024 16:02
@@ -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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@ohsoo ohsoo added the bot/test label Aug 23, 2024
@ohsoo ohsoo changed the title Add nil checks and debug log for CNI client Add nil checks and debug logs for CNI client Aug 23, 2024
@ohsoo ohsoo added the bot/test label Aug 23, 2024
@ohsoo ohsoo added the bot/test label Aug 26, 2024
@ohsoo ohsoo merged commit 53aebd9 into aws:dev Aug 27, 2024
40 checks passed
@ohsoo ohsoo deleted the multieni branch August 27, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants