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

Output to stderr when no log file path is passed #1275

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

couralex6
Copy link
Contributor

@couralex6 couralex6 commented Nov 2, 2020

What type of PR is this?
Bug fix

Which issue does this PR fix:
#1265

What does this PR do / Why do we need it:
Customers using Cilium in chaining mode were unable to create new pods after upgrading to CNI v1.7.x. Because no log file path was passed, zaplogger.go would default to stdout.
This change ensures that logs are being written to stderr when no log file path is passed.

If an issue # is not available please add repro steps and logs from IPAMD/CNI showing the issue:

Testing done on this change:
This was tested on a cluster with Cilium enabled in chaining mode . I reproduced the bug by installing CNI v1.7.5, which prevented new pods from being created. Pods were able to come up with this fix.

Automation added to e2e:
Added Unit Tests to test the following scenarios:

  • Empty log file path > log to zapcore.Lock(os.Stderr)
  • Actual file path > log to file path
  • String set to 'stdout' > log to zapcore.Lock(os.Stdout)

Will this break upgrades or downgrades. Has updating a running cluster been tested?:
No

Does this change require updates to the CNI daemonset config files to work?:
No

Does this PR introduce any user-facing change?:
No

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@couralex6 couralex6 force-pushed the master branch 3 times, most recently from ddba314 to 6b6faa3 Compare November 3, 2020 19:45
Copy link
Contributor

@nithu0115 nithu0115 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @couralex6

Copy link
Contributor

@nithu0115 nithu0115 left a comment

Choose a reason for hiding this comment

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

@couralex6, could you please update documentation under AWS_VPC_K8S_PLUGIN_LOG_FILE env var, saying that if external plugins like Cilium and chained together, the conf file does not include pluginLogfile variable to pass in via stdin when CNI plugin is called by kubelet. This will result in no log files under /var/log/aws-routed-eni/plugin.log. However, result of CNI plugin execution can be seen in Kubelet logs as CNI plugin by default write output of cmdAdd to os.Stdout. (something along these lines for justification)

@jayanthvn
Copy link
Contributor

@couralex6, could you please update documentation under AWS_VPC_K8S_PLUGIN_LOG_FILE env var, saying that if external plugins like Cilium and chained together, the conf file does not include pluginLogfile variable to pass in via stdin when CNI plugin is called by kubelet. This will result in no log files under /var/log/aws-routed-eni/plugin.log. However, result of CNI plugin execution can be seen in Kubelet logs as CNI plugin by default write output of cmdAdd to os.Stdout. (something along these lines for justification)

--> default to os.Stderr

Copy link
Contributor

@nithu0115 nithu0115 left a comment

Choose a reason for hiding this comment

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

Nice, @couralex6 /lgtm.

Compress: true,
}
assert.Equal(t, zapcore.AddSync(expectedLumberJackLogger), getPluginLogFilePath(inputPluginLogFile))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@jayanthvn jayanthvn left a comment

Choose a reason for hiding this comment

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

LGTM :)

@@ -19,6 +19,7 @@ import (

"github.com/stretchr/testify/assert"
"go.uber.org/zap/zapcore"
"gopkg.in/natefinch/lumberjack.v2"
Copy link
Contributor

Choose a reason for hiding this comment

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

@couralex6 - This looks to be a private repo. Can you please check if we can use it?

@shaikatz
Copy link

shaikatz commented Dec 6, 2020

Hi, when this PR is going to be released?

@jayanthvn
Copy link
Contributor

Hi @shaikatz, We are planning for the next release, I will provide you the dates in a week or so.

@AmitBenAmi
Copy link

Hi @jayanthvn
There have been already 2 releases since 1.7.6, but none of them fixed this issue.
Is this fix expected to be on v1.7.9 or any other release expected to be released soon?

@jayanthvn
Copy link
Contributor

Hi @AmitBenAmi

Sorry for the delay. Yes we are planning for a release In Jan/Feb. This will include this PR. Will update the exact date asap.

Thanks!

@jayanthvn jayanthvn modified the milestones: v1.7.9, v1.8.0, V1.7.9 Jan 19, 2021
@yaron-idan
Copy link

Hey @jayanthvn, is there any update on the release date for this PR? We are still blocked from upgrading our CNI.

@fawadkhaliq
Copy link

@yaron-idan the fix will be included in the next patch release (1.7.9) and sorry, we don't share release dates publicly. Expect the patch release to be out in the coming days (very soon)

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.

7 participants