Skip to content

Windows unit tests red on main since 2026-09-07: per-server log writer is never closed #1266

Closed

Description

@Dumbris

Unit Tests (windows-latest, 1.25) on main has failed on every push since 2026-09-07 (519c1d241; last green b2a1cdb88). It only runs on push to main, so PRs never see it. Not release-gating (release.yml does not depend on it), but main is red.

Failing tests

All in internal/server, all with the same shape:

--- FAIL: TestGetServerLogs_MissingFileReturnsEmptyNotError (1.93s)
    testing.go:1369: TempDir RemoveAll cleanup: unlinkat C:\Users\RUNNER~1\AppData\Local\Temp\...\server-never-logged.log: The process cannot access the file because it is being used by another process.

Also TestGetServerLogs_UnknownServerStillErrors, TestDiagnosticFixer_OAuthReauth_{ReachesTheCoordinator,DryRunDoesNotSignIn,RespectsWriteGates/*}, TestDiagnosticFixer_StdioShowLastLogs_{ReturnsRealTail,BoundsThePayload,MissingLogIsAFailure,CapCountsItsOwnFraming} (added by #1216 / #1218).

Root cause

The per-server upstream log writer is a lumberjack.Logger wrapped in zapcore.AddSync (internal/logs/logger.go createFileCore → CreateUpstreamServerLogger, consumed at internal/upstream/core/client.go:264). Nothing ever closes it: Server.Shutdown() / client disconnect only Sync() the zap logger, so the file handle stays open for the life of the process. On Linux/macOS RemoveAll unlinks an open file; on Windows it cannot, and t.TempDir() cleanup fails the test. The fixture comments in server_logs_missing_file_test.go / diagnostics_fixers_test.go already describe fighting this ("a per-server log writer that outlive Shutdown and then race t.TempDir()'s RemoveAll").

Fix

Give the upstream logger an owner that can close it: return the *lumberjack.Logger (or an io.Closer) from CreateUpstreamServerLogger, hold it on core.Client, and close it in the client's disconnect/close path so Server.Shutdown() releases every per-server file. That is also the product fix — a long-running core currently accumulates one open handle per server it has ever logged for. Once fixed, add a Windows-only leak check to the fixture (t.TempDir() already does it for free).

Activity

  1. added
    kind/test
    area/build-ci
    priority/medium
    on Sep 12, 2026
  2. Dumbris commented on Sep 12, 2026

    @Dumbris
    MemberAuthor

    Same root cause takes down the E2E Tests workflow on main too: its End-to-End Tests (windows-latest, 1.25) leg runs the same internal/server package and fails on the identical eleven tests (e.g. run 34685615417), and the ubuntu/macos legs are then cancelled by the matrix. E2E has been red on every main push since 4e304ba04 (2026-09-07) for this reason alone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/build-cikind/testpriority/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions