Merge pull request #1148 from congliu01/log

Override container log path to empty if either of sandbox log directory or container log path is empty.
This commit is contained in:
Lantao Liu 2019-05-14 15:50:20 -07:00 committed by GitHub
commit 6e14e01307
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,9 +192,14 @@ func (c *criService) CreateContainer(ctx context.Context, r *runtime.CreateConta
meta.ImageRef = image.ID meta.ImageRef = image.ID
meta.StopSignal = image.ImageSpec.Config.StopSignal meta.StopSignal = image.ImageSpec.Config.StopSignal
// Get container log path. // Validate log paths and compose full container log path.
if config.GetLogPath() != "" { if sandboxConfig.GetLogDirectory() != "" && config.GetLogPath() != "" {
meta.LogPath = filepath.Join(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, containerIO, err := cio.NewContainerIO(id,