github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/controllers/core/podlogstream/logwriter.go (about) 1 package podlogstream 2 3 import ( 4 "bytes" 5 "fmt" 6 "io" 7 ) 8 9 var failureMsg = []byte("failed to create fsnotify watcher: too many open files") 10 var newline = []byte("\n") 11 12 // Kubernetes has a bug where it will dump certain kinds of errors to the 13 // pod log stream. 14 // https://github.com/tilt-dev/tilt/issues/2487 15 type errorCapturingWriter struct { 16 underlying io.Writer 17 18 newlineTerminated bool 19 errorTerminated string 20 } 21 22 func (w *errorCapturingWriter) Write(p []byte) (n int, err error) { 23 w.newlineTerminated = bytes.HasSuffix(p, newline) 24 if bytes.HasSuffix(p, failureMsg) { 25 w.errorTerminated = 26 fmt.Sprintf("%s. Consider adjusting inotify limits: https://kind.sigs.k8s.io/docs/user/known-issues/#pod-errors-due-to-too-many-open-files", 27 string(failureMsg)) 28 } else { 29 w.errorTerminated = "" 30 } 31 32 return w.underlying.Write(p) 33 }