Skip to content

add log opts flag to pass in logging options#12422

Merged
jessfraz merged 1 commit intomoby:masterfrom
wlan0:logopts
May 8, 2015
Merged

add log opts flag to pass in logging options#12422
jessfraz merged 1 commit intomoby:masterfrom
wlan0:logopts

Conversation

@wlan0
Copy link
Copy Markdown
Contributor

@wlan0 wlan0 commented Apr 15, 2015

As per the discussions on this -- https://github.com/docker/docker/pull/11485/files

I'm dividing #11485 into two Pull requests, one for log-opts and one for max-size and max-file options.

This is the PR for log-opts.

@ibuildthecloud
@tiborvass
@LK4D4

Comment thread runconfig/parse.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you remove the commented lines?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ibuildthecloud I wanted to enforce a validation step at this point for the log options. The commented lines have a pattern for validating log options.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perhaps just a TODO? The commented code looks trivial

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, TODO should be ok.

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Apr 16, 2015

Shouldn't we pass this to logging drivers?

Comment thread opts/opts.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe SplitN with 2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That would allow one to specify an option like --map-opt key=value1=value2 I cant think of a use case for something like that. Are there any potential benefits of doing that?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just checked runconfig/parse.go, and it does splitN with n=2. For consistency between docker run and docker -d, i'll make it splitN

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Apr 16, 2015

Also tests for MapOpts needed.

@thaJeztah
Copy link
Copy Markdown
Member

Thanks for splitting it, @wlan0!

Comment thread opts/opts_test.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

makes sense to test 2 keys

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Apr 16, 2015

Why do you plan validation for daemon and not for run?

@wlan0
Copy link
Copy Markdown
Contributor Author

wlan0 commented Apr 16, 2015

@LK4D4 Addressed all your comments I think.

Good catch btw, we need validation for docker daemon as well.

Now there are,

  • Tests for MapOpts
  • Validation for docker daemon
  • other minor code changes

Comment thread opts/opts.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this basically strings.Contains check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Then I think better to use strings.Contains :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@LK4D4 This cannot be strings.Contains. strings.Contains will validate some-string=allowed-string, whereas we only want allowed-string=some-string to be valid.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah, okay.

@tiborvass
Copy link
Copy Markdown
Contributor

@wlan0 what is this PR supposed to do? Just introduce log-opt and passing it to the logging driver and that's it? If that's the case I would remove references to max-size etc. in the docs.

@wlan0
Copy link
Copy Markdown
Contributor Author

wlan0 commented Apr 22, 2015

@LK4D4 I've updated the code to initialize LogConfig.Config in docker/daemon.go:init()

@LK4D4
Copy link
Copy Markdown
Contributor

LK4D4 commented Apr 22, 2015

Code okay for me. I'm eager to see it's usage.
@tiborvass WDYT about adding it to syslog right here?

@ibuildthecloud
Copy link
Copy Markdown
Contributor

FYI, Syslog implementation using --log-opts in #12391

@tiborvass
Copy link
Copy Markdown
Contributor

@ibuildthecloud the PR you referenced doesn't use --log-opt or am I missing something?

@LK4D4 I think I'd prefer in a separate PR, so we can merge this, but I don't really mind.

Comment thread daemon/config.go Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@LK4D4 why not use opts.NewListOpts with opts.ValidateEnv like --label ?
Also there are already functions like convertKVStringsToMap that we can reuse.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have no idea :/ Wanna carry this?

@ibuildthecloud
Copy link
Copy Markdown
Contributor

Lol, wrong PR, too many late night drunken pull requests. Here's the right one #12668

Comment thread opts/opts.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: extra pair of parenthesis.

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented May 6, 2015

@wlan0 Can you please rebase?

@icecrime
Copy link
Copy Markdown
Contributor

icecrime commented May 6, 2015

Thanks, code LGTM.

@wlan0
Copy link
Copy Markdown
Contributor Author

wlan0 commented May 6, 2015

@icecrime rebased.
Oh, just saw your comment. :)

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented May 7, 2015

ah man so sorry needs rebase then you can ping me for review and merge thanks!

@wlan0
Copy link
Copy Markdown
Contributor Author

wlan0 commented May 8, 2015

@jfrazelle Rebased :)

@jessfraz
Copy link
Copy Markdown
Contributor

jessfraz commented May 8, 2015

LGTM thanks!

jessfraz pushed a commit that referenced this pull request May 8, 2015
add log opts flag to pass in logging options
@jessfraz jessfraz merged commit fe3bece into moby:master May 8, 2015
@wlan0
Copy link
Copy Markdown
Contributor Author

wlan0 commented May 8, 2015

Thanks all!

@ahmetb
Copy link
Copy Markdown
Contributor

ahmetb commented May 14, 2015

@LK4D4 @wlan0 so I can see that --log-opt is added to the daemon command. Does this PR also make --log-opts available on docker run because that's another place we configure logging drivers. (I can't see it documented in this PR.)

If one of you can provide more context I can start working on plumbing LoggingOpts to the logdrivers factory using logging.Context.

Comment thread daemon/config.go
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@wlan0 isn't this supposed to be &config.LogConfig.Config (not sure, just reading the code)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ahmetalpbalkan Config is a map, its already a reference type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants