From fda2902f30a89edb92c31342640fef0a57ba191e Mon Sep 17 00:00:00 2001 From: Cong Liu Date: Fri, 10 May 2019 14:53:38 -0400 Subject: [PATCH] Validate log paths in sandbox and container config. Only compose full container log path if neither of the paths is empty. Otherwise container won't start properly. Signed-off-by: Cong Liu --- pkg/server/container_create.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/server/container_create.go b/pkg/server/container_create.go index d61cbb47a..f83f72482 100644 --- a/pkg/server/container_create.go +++ b/pkg/server/container_create.go @@ -192,9 +192,14 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta meta.ImageRef = image.ID meta.StopSignal = image.ImageSpec.Config.StopSignal - // Get container log path. - if config.GetLogPath() != "" { + // Validate log paths and compose full container log path. + if sandboxConfig.GetLogDirectory() != "" && config.GetLogPath() != "" { meta.LogPath = filepath.Join(sandboxConfig.GetLogDirectory(), config.GetLogPath()) + logrus.Debugf("Composed container full log path %q using sandbox log dir %q and container log path %q", + meta.LogPath, sandboxConfig.GetLogDirectory(), config.GetLogPath()) + } else { + logrus.Infof("Logging will be disabled due to empty log paths for sandbox (%q) or container (%q)", + sandboxConfig.GetLogDirectory(), config.GetLogPath()) } containerIO, err := cio.NewContainerIO(id,