AliyunContainerService / pouch

An Efficient Enterprise-class Container Engine
https://pouchcontainer.io
Apache License 2.0
4.64k stars 949 forks source link

[bugfix] LogOpts doesn't take effect in pouchd config file #2938

Closed zjumoon01 closed 5 years ago

zjumoon01 commented 5 years ago

Configure LogOpts in /etc/pouch/config.json such as: "default-log-config": { "Type": "json-file", "Config": { "max-file": "5", "max-size": "300m" } } "max-file" and "max-size" are log options for pouchd. We create a container which will set its log options from pouchd. However, it doesn't take effect.

This patch will fix it. Config file and cmd flags will be merged. So we should set LogOpts from cmd flags "--log-opt" before merging.

Signed-off-by: baijia.wr baijia.wr@antfin.com

Ⅰ. Describe what this PR did

We set log options in config file of pouchd(/etc/pouch/config.json) such as "default-log-config": { "Type": "json-file", "Config": { "max-file": "5", "max-size": "300m" } } It doesn't take effect because cfg.DefaultLogConfig.LogOpts is reset to logOpts which comes from --log-opt in cmd flag. This patch will fix it.

Ⅱ. Does this pull request fix one issue?

NONE

Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

codecov[bot] commented 5 years ago

Codecov Report

Merging #2938 into master will increase coverage by 1.34%. The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2938      +/-   ##
==========================================
+ Coverage   66.77%   68.11%   +1.34%     
==========================================
  Files         289      291       +2     
  Lines       18312    18343      +31     
==========================================
+ Hits        12227    12495     +268     
+ Misses       4647     4387     -260     
- Partials     1438     1461      +23
Flag Coverage Δ
#criv1alpha2_test 34.78% <ø> (?)
#integration_test_0 36.13% <ø> (ø) :arrow_up:
#integration_test_1 35.49% <ø> (-0.09%) :arrow_down:
#integration_test_2 36.15% <ø> (+0.04%) :arrow_up:
#integration_test_3 35.56% <ø> (ø) :arrow_up:
#node_e2e_test 34.27% <ø> (+0.15%) :arrow_up:
#unittest 27.96% <ø> (ø) :arrow_up:
Impacted Files Coverage Δ
pkg/streams/utils.go 82.14% <0%> (-9.53%) :arrow_down:
ctrd/supervisord/daemon.go 49.32% <0%> (-1.36%) :arrow_down:
ctrd/image.go 67.03% <0%> (-0.74%) :arrow_down:
daemon/mgr/container_utils.go 76.26% <0%> (-0.51%) :arrow_down:
daemon/mgr/spec_apparmor_linux.go 20% <0%> (ø)
daemon/mgr/spec_seccomp_linux.go 71.42% <0%> (ø)
daemon/mgr/container.go 60.35% <0%> (+0.41%) :arrow_up:
daemon/mgr/container_types.go 71.32% <0%> (+1.47%) :arrow_up:
ctrd/container.go 53.15% <0%> (+1.52%) :arrow_up:
cri/ocicni/cni_manager.go 62.26% <0%> (+1.88%) :arrow_up:
... and 13 more