Skip to content

Commit

Permalink
Preserve PATH variable by default.
Browse files Browse the repository at this point in the history
For some reason Logstash's bootstrap script has been able to find the
JVM even though the PATH variable was unset, but this wasn't true when
running Logstash 5.4 via the docker.elastic.co/logstash/logstash:5.4.0
Docker image, resulting in a "Could not find any executable java
binary" error message.

It's not clear whether this is a general 5.x or 5.4 problem or if
it's related to the Docker image, but either way it's reasonable to
preserve the PATH variable by default. It's not likely to result in
non-hermetic tests, and if any such concerns arise it's easy to set
the variable to a fixed value or unset it (if the JVM can be found
anyway).
  • Loading branch information
magnusbaeck committed May 21, 2017
1 parent d1ce9dd commit 9b5511c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions logstash-filter-verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ var (

loglevels = []string{"CRITICAL", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"}

defaultKeptEnvVars = []string{
"PATH",
}

// Flags
diffCommand = kingpin.
Flag("diff-command", "Set the command to run to compare two events. The command will receive the two files to compare as arguments.").
Default("diff -u").
String()
keptEnvVars = kingpin.
Flag("keep-env", "Add this environment variable to the list of variables that will be preserved from the calling process's environment. Defaults to an empty list.").
Flag("keep-env", fmt.Sprintf("Add this environment variable to the list of variables that will be preserved from the calling process's environment. Initial list of variables: %s", strings.Join(defaultKeptEnvVars, ", "))).
PlaceHolder("VARNAME").
Strings()
loglevel = kingpin.
Expand Down Expand Up @@ -257,18 +261,20 @@ func main() {
userError(err.Error())
os.Exit(1)
}

allKeptEnvVars := append(defaultKeptEnvVars, *keptEnvVars...)
if *unixSockets {
if runtime.GOOS == "windows" {
userError("Use of Unix domain sockets for communication with Logstash is not supported on Windows.")
os.Exit(1)
}
fmt.Println("Use Unix domain sockets.")
if err = runParallelTests(*logstashPath, *logstashArgs, tests, *configPaths, diffCmd, *keptEnvVars); err != nil {
if err = runParallelTests(*logstashPath, *logstashArgs, tests, *configPaths, diffCmd, allKeptEnvVars); err != nil {
userError(err.Error())
os.Exit(1)
}
} else {
if err = runTests(*logstashPath, *logstashArgs, tests, *configPaths, diffCmd, *keptEnvVars); err != nil {
if err = runTests(*logstashPath, *logstashArgs, tests, *configPaths, diffCmd, allKeptEnvVars); err != nil {
userError(err.Error())
os.Exit(1)
}
Expand Down

0 comments on commit 9b5511c

Please sign in to comment.