Summary
While reviewing the End-to-End test suite utilities, I discovered a permanent file descriptor leak in tests/e2e/utils.go.
The helper function findLineInFile() opens a file using os.Open(filePath) but completely misses the defer file.Close() statement. It returns early if the pattern is found, or returns an error at the end, but in all execution paths, the file descriptor remains open and is permanently leaked.
Affected Code
File: tests/e2e/utils.go (Lines 243-259)
func findLineInFile(filePath string, pattern string) (string, error) {
file, err := os.Open(filePath)
if err != nil {
return "", fmt.Errorf("Failed to open %s: %v", filePath, err)
}
// BUG: Missing defer file.Close() here!
scanner := bufio.NewScanner(file)
for scanner.Scan() {
line := scanner.Text()
if strings.Contains(line, pattern) {
return line, nil // Leaks file descriptor
}
}
return "", fmt.Errorf("Pattern %s was not found in any line of %s", pattern, filePath) // Leaks file descriptor
}
Impact
Since this is an E2E testing utility function that is called repeatedly during test execution, the file descriptors accumulate over time. In a long-running test environment or CI pipeline, this will eventually exhaust the process's file descriptor limits (hitting the ulimit -n threshold) and cause the entire test suite to crash with a too many open files panic.
Summary
While reviewing the End-to-End test suite utilities, I discovered a permanent file descriptor leak in
tests/e2e/utils.go.The helper function
findLineInFile()opens a file usingos.Open(filePath)but completely misses thedefer file.Close()statement. It returns early if the pattern is found, or returns an error at the end, but in all execution paths, the file descriptor remains open and is permanently leaked.Affected Code
File:
tests/e2e/utils.go(Lines 243-259)Impact
Since this is an E2E testing utility function that is called repeatedly during test execution, the file descriptors accumulate over time. In a long-running test environment or CI pipeline, this will eventually exhaust the process's file descriptor limits (hitting the ulimit -n threshold) and cause the entire test suite to crash with a too many open files panic.