Update golangci-lint and adjust code for new gosec diagnostics. Use
root-scoped filesystem operations where appropriate, preserve explicit
user path behavior for SSH keys, and avoid background contexts in
request-scoped cleanup paths.
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
In the case where the context provided to MultiReader.Reader is
cancelled, the writer will be deleted.
Before this, closeWriter was not called in that codepath, when meant
that MultiReader.handle would never see the writer and never close it.
* I don't have an isolated repro, but when running a few hundred of
Dagger's tests I was seeing several thousand goroutines blocked on
waiting for the progress pipe's context to be done.
Now, we just call closeWriter when it gets deleted so that the pipe's
goroutine doesn't leak.
* After this change, those thousands of leaked goroutines are entirely
gone.
Signed-off-by: Erik Sipsma <erik@sipsma.dev>