-
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: deamon support --log-driver and --log-opt options #1647
feature: deamon support --log-driver and --log-opt options #1647
Conversation
PTAL @fuweid |
main.go
Outdated
@@ -105,6 +107,10 @@ func setupFlags(cmd *cobra.Command) { | |||
flagSet.BoolVar(&cfg.NetworkConfig.BridgeConfig.IPForward, "ipforward", true, "Enable ipforward") | |||
flagSet.BoolVar(&cfg.NetworkConfig.BridgeConfig.UserlandProxy, "userland-proxy", false, "Enable userland proxy") | |||
|
|||
// log config | |||
flagSet.StringVar(&cfg.DefaultLogConfig.LogDriver, "log-driver", "", "Set default log driver") |
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.
I think we can set the log-driver
to jsonfile
, like mody does. WDTY?
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.
yep. If log-driver
is empty, CI will fail.
main.go
Outdated
@@ -19,6 +19,7 @@ import ( | |||
"github.com/alibaba/pouch/storage/quota" | |||
"github.com/alibaba/pouch/version" | |||
|
|||
"github.com/alibaba/pouch/apis/opts" |
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.
please put this line to previous group.
daemon/mgr/container.go
Outdated
LogDriver: types.LogConfigLogDriverJSONFile, | ||
} | ||
defaultConfig := mgr.Config.DefaultLogConfig | ||
config.HostConfig.LogConfig = &defaultConfig |
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.
The request maybe come from swarm. If it does, the config.HostConfig.LogConfig
is not nil but the value is empty. For this case, the config.HostConfig.LogConfig.LogDriver
is empty and config.HostConfig.LogConfig. LogOpts
is nil.
It isn't good practice in API design. However, we need to compatible with legacy system. Add other check that config.HostConfig.LogConfig
is empty or not. WDTY?
daemon/mgr/container.go
Outdated
} | ||
// note: request from swarm is not standard. config.HostConfig.LogConfig is not nil, but its value is empty. | ||
// We need to be compatible with this legacy system. | ||
if config.HostConfig.LogConfig == nil || config.HostConfig.LogConfig.LogDriver == "" { |
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.
Could we use helper function to check the config.HostConfig.LogConfig
is empty or not?
Like,
func isEmptyLogConfig(xx *types.LogConfig) bool {
if config.HostConfig.LogConfig == nil {
return true
}
return config.HostConfig.LogConfig.LogDriver == "" && len(config.HostConfig.LogConfig.LogOpts) == 0
}
WDTY?
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.
Yep. Thanks
main.go
Outdated
@@ -105,6 +107,10 @@ func setupFlags(cmd *cobra.Command) { | |||
flagSet.BoolVar(&cfg.NetworkConfig.BridgeConfig.IPForward, "ipforward", true, "Enable ipforward") | |||
flagSet.BoolVar(&cfg.NetworkConfig.BridgeConfig.UserlandProxy, "userland-proxy", false, "Enable userland proxy") | |||
|
|||
// log config | |||
flagSet.StringVar(&cfg.DefaultLogConfig.LogDriver, "log-driver", "jsonfile", "Set default log driver") |
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.
s/"jsonfile"/types.LogConfigLogDriverJSONFile 😄
8ef0499
to
5670b9c
Compare
5670b9c
to
72d3dc2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1647 +/- ##
===========================================
- Coverage 41.45% 18.12% -23.34%
===========================================
Files 273 226 -47
Lines 17714 15033 -2681
===========================================
- Hits 7344 2725 -4619
- Misses 9461 12127 +2666
+ Partials 909 181 -728
|
72d3dc2
to
6839d63
Compare
daemon/mgr/container.go
Outdated
@@ -414,6 +410,23 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty | |||
}, nil | |||
} | |||
|
|||
// set manager log config to the container's log config if the container's log config is not specified. | |||
func (mgr *ContainerManager) setDefaultLogConfig(logConfig *types.LogConfig) { |
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.
s/setDefaultLogConfig/setDefaultLogConfigIfMissing/g
daemon/mgr/container.go
Outdated
@@ -414,6 +410,23 @@ func (mgr *ContainerManager) Create(ctx context.Context, name string, config *ty | |||
}, nil | |||
} | |||
|
|||
// set manager log config to the container's log config if the container's log config is not specified. | |||
func (mgr *ContainerManager) setDefaultLogConfig(logConfig *types.LogConfig) { | |||
if logConfig == 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.
I don't think we can set the value to the config, since it is not pointer to pointer
ac009f4
to
ed72940
Compare
Signed-off-by: zhuangqh <zhuangqhc@gmail.com>
ed72940
to
725825b
Compare
LGTM |
Signed-off-by: zhuangqh zhuangqhc@gmail.com
Ⅰ. Describe what this PR did
pouchd could start with --log-driver and --log-opt as the default configuration of log driver.
Ⅱ. Does this pull request fix one issue?
fixes #1646
Ⅲ. Describe how you did it
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
Due to the defect of go-swagger v0.12, the validation of these options are temporarily noneffective.