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

feature: add LogPath in Inspect Response #2286

Merged
merged 1 commit into from
Sep 29, 2018

Conversation

allencloud
Copy link
Collaborator

Signed-off-by: Allen Sun allensun.shl@alibaba-inc.com

Ⅰ. Describe what this PR did

This pull request tries to add LogPath field in container instance and return this field in /containers/{id}/json API.

We know only when log driver is json-file, the LogPath is not empty, so the function does this:

// SetContainerLogPath sets the log path of container.
// LogPath would be as a field in `Inspect` response.
func (mgr *ContainerManager) SetContainerLogPath(c *Container) {
	if c.HostConfig.LogConfig == nil {
		return
	}

	// If the logdriver is json-file, the LogPath should be like
	// /var/lib/pouch/containers/5804ee42e505a5d9f30128848293fcb72d8cbc7517310bd24895e82a618fa454/json.log
	if c.HostConfig.LogConfig.LogDriver == "json-file" {
		c.LogPath = filepath.Join(mgr.Config.HomeDir, "containers", c.ID, "json.log")
	}
	return
}

Ⅱ. Does this pull request fix one issue?

fixes #2283

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

test cases added.

Ⅳ. Describe how to verify it

execute command

root@ubuntu:~# pouch inspect -f {{.LogPath}} 4e6aa
/var/lib/pouch/containers/4e6aad08d0961071c12faa0f137a44cd547d64958ff2c93c5aeb4c53f3b64a84/json.log

Ⅴ. Special notes for reviews

Signed-off-by: Allen Sun <allensun.shl@alibaba-inc.com>
@codecov
Copy link

codecov bot commented Sep 29, 2018

Codecov Report

Merging #2286 into master will increase coverage by 0.16%.
The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2286      +/-   ##
==========================================
+ Coverage   66.71%   66.87%   +0.16%     
==========================================
  Files         208      208              
  Lines       16937    16945       +8     
==========================================
+ Hits        11299    11332      +33     
+ Misses       4270     4259      -11     
+ Partials     1368     1354      -14
Flag Coverage Δ
#criv1alpha1test 32.62% <62.5%> (+0.01%) ⬆️
#criv1alpha2test 35.99% <62.5%> (+0.02%) ⬆️
#integrationtest 39.48% <75%> (-0.02%) ⬇️
#nodee2etest 33.57% <62.5%> (+0.31%) ⬆️
#unittest 23.74% <0%> (-0.02%) ⬇️
Impacted Files Coverage Δ
apis/server/container_bridge.go 79.48% <100%> (+0.07%) ⬆️
daemon/mgr/container.go 57.43% <100%> (+0.04%) ⬆️
daemon/mgr/container_logger.go 87.5% <66.66%> (-4.81%) ⬇️
ctrd/watch.go 75.75% <0%> (-4.55%) ⬇️
pkg/meta/store.go 62.5% <0%> (-1.57%) ⬇️
daemon/mgr/container_utils.go 83.13% <0%> (-1.21%) ⬇️
ctrd/container.go 59.76% <0%> (-0.48%) ⬇️
cri/v1alpha2/cri_utils.go 90.62% <0%> (+0.29%) ⬆️
cri/v1alpha1/cri.go 62.21% <0%> (+0.33%) ⬆️
... and 5 more

@@ -81,6 +81,7 @@ func (s *Server) getContainer(ctx context.Context, rw http.ResponseWriter, req *
State: c.State,
Config: c.Config,
HostConfig: c.HostConfig,
LogPath: c.LogPath,
Copy link
Contributor

Choose a reason for hiding this comment

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

for the existing running container, the LogPath is still empty.

Copy link
Contributor

@fuweid fuweid left a comment

Choose a reason for hiding this comment

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

LGTM

@fuweid fuweid merged commit 85ae3b7 into AliyunContainerService:master Sep 29, 2018
@allencloud allencloud deleted the add-logpath branch September 29, 2018 14:28
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.

[feature request]add LogPath field to the output of pouch inspect
3 participants