Skip to content

Commit

Permalink
Revert (unreleased) changes done in elastic#10687
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Pérez-Aradros Herce committed May 10, 2019
1 parent cdf0ec4 commit 67644b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
2 changes: 0 additions & 2 deletions filebeat/input/docker/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ type containers struct {
IDs []string `config:"ids"`
Path string `config:"path"`

Paths []string `config:"paths"`

// Stream can be all, stdout or stderr
Stream string `config:"stream"`
}
37 changes: 5 additions & 32 deletions filebeat/input/docker/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,10 @@ func NewInput(
return nil, errors.Wrap(err, "reading docker input config")
}

// Docker input should make sure that no callers should ever pass empty strings as container IDs or paths
// Docker input should make sure that no callers should ever pass empty strings as container IDs
// Hence we explicitly make sure that we catch such things and print stack traces in the event of
// an invocation so that it can be fixed.
var ids, paths []string
for _, p := range config.Containers.Paths {
if p != "" {
paths = append(paths, p)
} else {
logger.Error("Docker paths can't be empty for Docker input config")
logger.Debugw("Empty path for Docker logfile was received", logp.Stack("stacktrace"))
}
}

var ids []string
for _, containerID := range config.Containers.IDs {
if containerID != "" {
ids = append(ids, containerID)
Expand All @@ -76,23 +67,12 @@ func NewInput(
}
}

if len(ids) == 0 && len(paths) == 0 {
if len(ids) == 0 {
return nil, errors.New("Docker input requires at least one entry under 'containers.ids' or 'containers.paths'")
}

// IDs + Path and Paths are mutually exclusive. Ensure that only one of them are set in a given configuration
if len(ids) != 0 && len(paths) != 0 {
return nil, errors.New("can not provide both 'containers.ids' and 'containers.paths' in the same input config")
}

if len(ids) != 0 {
for idx, containerID := range ids {
cfg.SetString("paths", idx, path.Join(config.Containers.Path, containerID, "*.log"))
}
} else {
for idx, p := range paths {
cfg.SetString("paths", idx, p)
}
for idx, containerID := range ids {
cfg.SetString("paths", idx, path.Join(config.Containers.Path, containerID, "*.log"))
}

if err := checkStream(config.Containers.Stream); err != nil {
Expand All @@ -117,13 +97,6 @@ func NewInput(
}
}

if len(paths) != 0 {
// Set symlinks to true as CRI-O paths could point to symlinks instead of the actual path.
if err := cfg.SetBool("symlinks", -1, true); err != nil {
return nil, errors.Wrap(err, "update input config")
}
}

// Add stream to meta to ensure different state per stream
if config.Containers.Stream != "all" {
if context.Meta == nil {
Expand Down

0 comments on commit 67644b2

Please sign in to comment.