diff options
| author | Michael Matloob <matloob@golang.org> | 2025-03-18 13:00:42 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2025-03-18 11:22:30 -0700 |
| commit | 6b18311bbc94864af48d10aad73fd4eb7ea0d9a1 (patch) | |
| tree | 4577680b7ea1f349d8a93f186444edd63af10c8f /src | |
| parent | a17c092c2c5e8ad45482ebbb9e17ef7f92edb96c (diff) | |
| download | go-6b18311bbc94864af48d10aad73fd4eb7ea0d9a1.tar.xz | |
cmd/go/internal/clean: add logging to help debug openbsd flakes
This change adds extra logging in the case where there's an error
removing all the files in the gomodcache using modfetch.RemoveAll.
It logs the names of the files found in GOMODCACHE as well as their
modes. The modes are included because they should all be writable by the
time we call robustio.RemoveAll.
For #68087
Change-Id: Id9ae68bf6a3392baf88ec002d08fed1faf525927
Reviewed-on: https://go-review.googlesource.com/c/go/+/658816
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/go/internal/clean/clean.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/cmd/go/internal/clean/clean.go b/src/cmd/go/internal/clean/clean.go index 37566025ce..18c5ae23fc 100644 --- a/src/cmd/go/internal/clean/clean.go +++ b/src/cmd/go/internal/clean/clean.go @@ -7,8 +7,10 @@ package clean import ( "context" + "errors" "fmt" "io" + "io/fs" "os" "path/filepath" "runtime" @@ -216,6 +218,15 @@ func runClean(ctx context.Context, cmd *base.Command, args []string) { if !cfg.BuildN { if err := modfetch.RemoveAll(cfg.GOMODCACHE); err != nil { base.Error(err) + + // Add extra logging for the purposes of debugging #68087. + // We're getting ENOTEMPTY errors on openbsd from RemoveAll. + // Check for os.ErrExist, which can match syscall.ENOTEMPTY + // and syscall.EEXIST, because syscall.ENOTEMPTY is not defined + // on all platforms. + if runtime.GOOS == "openbsd" && errors.Is(err, fs.ErrExist) { + logFilesInGOMODCACHE() + } } } } @@ -228,6 +239,29 @@ func runClean(ctx context.Context, cmd *base.Command, args []string) { } } +// logFilesInGOMODCACHE reports the file names and modes for the files in GOMODCACHE using base.Error. +func logFilesInGOMODCACHE() { + var found []string + werr := filepath.WalkDir(cfg.GOMODCACHE, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + var mode string + info, err := d.Info() + if err == nil { + mode = info.Mode().String() + } else { + mode = fmt.Sprintf("<err: %s>", info.Mode()) + } + found = append(found, fmt.Sprintf("%s (mode: %s)", path, mode)) + return nil + }) + if werr != nil { + base.Errorf("walking files in GOMODCACHE (for debugging go.dev/issue/68087): %v", werr) + } + base.Errorf("files in GOMODCACHE (for debugging go.dev/issue/68087):\n%s", strings.Join(found, "\n")) +} + var cleaned = map[*load.Package]bool{} // TODO: These are dregs left by Makefile-based builds. |
