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

support to set root dir of container log #2797

Conversation

wangforthinker
Copy link
Contributor

Signed-off-by: allen.wang allen.wq@alipay.com

Ⅰ. Describe what this PR did

The PR allows user to set container log path by parameters log-opt. There are two ways to set container log path.

  1. Set root dir of container log by pouch daemon config. For example:

Start pouchd with --log-opt.

/usr/local/bin/pouchd --log-opt root-dir=/tmp/daemon_log

Or set it to pouch config file like this:

{
...
"default-log-config": {
        "Config":{
            "root-dir":"/tmp/daemon_log"
        }
    },
...
}

By this way, all new container will be applied this feature. The container log path will be /tmp/daemon_log/<cid>/json.log

  1. Set root dir of container log by container create config. For example:
pouch run -d --name=test --log-opt root-key=/tmp/container_log busybox:latest sh -c "echo hello"

By this way, only the created container with "--log-opt root-key=/tmp/container_log" will be applied this feature. The container log path will be /tmp/container_log/<cid>/json.log.

the second way has the high priority.

Ⅱ. Does this pull request fix one issue?

fix #2783.

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

add test.

Ⅳ. Describe how to verify it

by test.

Ⅴ. Special notes for reviews

@codecov
Copy link

codecov bot commented Apr 9, 2019

Codecov Report

Merging #2797 into master will decrease coverage by <.01%.
The diff coverage is 62.16%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2797      +/-   ##
==========================================
- Coverage   69.41%   69.41%   -0.01%     
==========================================
  Files         278      278              
  Lines       17340    17373      +33     
==========================================
+ Hits        12037    12059      +22     
- Misses       3965     3975      +10     
- Partials     1338     1339       +1
Flag Coverage Δ
#criv1alpha2_test 39.26% <35.13%> (-0.06%) ⬇️
#integration_test_0 36.56% <40.54%> (+0.04%) ⬆️
#integration_test_1 35.25% <35.13%> (-0.06%) ⬇️
#integration_test_2 36.48% <59.45%> (+0.09%) ⬆️
#integration_test_3 35.37% <51.35%> (ø) ⬆️
#node_e2e_test 35.11% <35.13%> (-0.02%) ⬇️
#unittest 28.72% <0%> (-0.07%) ⬇️
Impacted Files Coverage Δ
daemon/mgr/container.go 60.89% <33.33%> (+0.29%) ⬆️
daemon/mgr/container_validation.go 42.52% <33.33%> (-0.41%) ⬇️
daemon/mgr/container_logs.go 82.5% <50%> (-1.92%) ⬇️
daemon/mgr/container_logger.go 78.43% <75%> (-4.91%) ⬇️
pkg/streams/utils.go 82.14% <0%> (-7.15%) ⬇️
daemon/mgr/spec_linux.go 79% <0%> (-1.07%) ⬇️
daemon/mgr/container_utils.go 81.81% <0%> (-0.57%) ⬇️
cri/v1alpha2/cri.go 71.48% <0%> (+0.25%) ⬆️
ctrd/container.go 55.25% <0%> (+0.95%) ⬆️
... and 1 more

daemon/mgr/container_logger.go Outdated Show resolved Hide resolved
daemon/mgr/container_logger.go Outdated Show resolved Hide resolved
@wangforthinker wangforthinker force-pushed the feature/specific-container-log-path branch from c55e5af to 1aba38c Compare April 11, 2019 03:46
Signed-off-by: allen.wang <allen.wq@alipay.com>
@HusterWan HusterWan self-requested a review April 11, 2019 14:10
@HusterWan
Copy link
Contributor

LGTM

@pouchrobot pouchrobot added the LGTM one maintainer or community participant agrees to merge the pull reuqest. label Apr 11, 2019
@allencloud allencloud merged commit 9f56fef into AliyunContainerService:master Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/log LGTM one maintainer or community participant agrees to merge the pull reuqest. size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Proposal] Support to set root dir of container log file.
4 participants