-
Notifications
You must be signed in to change notification settings - Fork 950
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
feature: init syslog functionality in pouchd #1500
feature: init syslog functionality in pouchd #1500
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1500 +/- ##
=========================================
- Coverage 40.55% 38.25% -2.3%
=========================================
Files 253 262 +9
Lines 16481 17874 +1393
=========================================
+ Hits 6684 6838 +154
- Misses 8941 10168 +1227
- Partials 856 868 +12
|
1. use logger.Info to contain container's information 2. add log driver validation in daemon 3. make the openContainerIO/attachContainerIO friendly Signed-off-by: Wei Fu <[email protected]>
Signed-off-by: Wei Fu <[email protected]>
Signed-off-by: Wei Fu <[email protected]>
Signed-off-by: Wei Fu <[email protected]>
1. add option in containerio 2. add syslog config validation in container mgr 3. add syslog option during init containerio Signed-off-by: Wei Fu <[email protected]>
Signed-off-by: Wei Fu <[email protected]>
apis/opts/log_options.go
Outdated
// convertKVStringsToMap converts ["key=value"] into {"key":"value"} | ||
// | ||
// TODO(fuwei): make it common in the opts.ParseXXX(). | ||
func convertKVStringsToMap(values []string) (map[string]string, error) { |
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.
How about encapsulating the function into pkg?
Since I think this is a common function there.
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.
make senses.
daemon/logger/syslog/validate.go
Outdated
// ErrInvalidSyslogFormat represents the invalid format. | ||
ErrInvalidSyslogFormat = errors.New("invalid syslog format") | ||
|
||
// ErrFailedToLoadX509KeyPair is to used to indicate that it's failed to load x590 key pair. |
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.
load x509 key pair
? 😄
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.
haha find a typo! good catch.
daemon/mgr/container_logger.go
Outdated
"github.com/sirupsen/logrus" | ||
) | ||
|
||
func optionsForContainerio(c *Container) []func(*containerio.Option) { |
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.
This function is only used for log options and in the file container_logger.go
Maybe the name logOptionsForContainerio
is more appropriate?
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.
make senses.
|
||
// Close closes the Syslog. | ||
func (s *Syslog) Close() error { | ||
return s.writer.Close() |
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.
Is it OK to close Syslog multiple times?
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.
In my opinion, I don't think we should care the multiple closes. Even if the srslog supports the case.
We should close the syslog once. If we closes it multiple times, we should reconsider that the logic is ok. And that we will introduce sync.Lock things if we support the case. Is it worth? 😄
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.
Yes, I totally agree that the backend should be closed only once.
But now pouchd will include all the backends in both Stdout
and Stderr
. when being closed, both of them will close all the backends. And this is unreasonable.
So my PR #1388 fixes this problem. The close of Stdout
and Stderr
only close the corresponding ring buffer. Only when the IO
is closed, all the backends will be closed 😄
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.
@YaoZengzeng we need to drain the ringbuffer, right? When we close the IO, we need to wait the data has been drained. 😄
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.
Yes, it is exactly what #1388 do. 😄
1. s/optionsForContainerio/logOptionsForContainerio/g 2. make the convertKVStringsToMap into pkg/utils 3. fix typo Signed-off-by: Wei Fu <[email protected]>
LGTM. |
Ⅰ. Describe what this PR did
Add syslog driver into PouchContainer so that user can use more log driver, not just jsonfile.
Ⅱ. Does this pull request fix one issue?
NONE
Ⅲ. Describe how you did it
Before add this feature, we have to do the following things:
After we do the above things, we can handle syslog like jsonfile. With syslog driver, user can write the log data in local syslog or send it to the remote syslog center.
In this PR, I introduce the third-party package srslog, which can handle the local and remote cases.
Ⅳ. Describe how to verify it
The user can use the following options to setup the syslog driver:
only driver
driver with tag
driver with tag and different format
Ⅴ. Special notes for reviews
I submitted several commits so that the reviewer can check commit one by one.
For example, first commit is to show the refactor small changed part. It can avoid to use big change to flood the reviewer. :)
After LGTM, we can use
squash
and change commit message before merge.Known issues: