Files
teleport/lib/utils/cert
rosstimothy fc95c42e2a Remove (auth.Server) SetClock (#60526)
The ability to alter the auth server clock existed
to allow tests to inject a fake clock. While this sounds
great it introduces opportunity for data races if other
components are already consuming the existing clock. For
example:

```

==================
WARNING: DATA RACE
Write at 0x00c003014720 by goroutine 168:
  github.com/gravitational/teleport/lib/auth.(*Server).SetClock()
      /__w/teleport.e/teleport.e/lib/auth/auth.go:2308 +0x88
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:629 +0x11ad
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:621 +0x1092
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local.func21()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:290 +0x14e
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44

Previous read at 0x00c003014720 by goroutine 9018:
  github.com/gravitational/teleport/lib/auth.(*Server).GenerateHostCerts()
      /__w/teleport.e/teleport.e/lib/auth/auth.go:5127 +0x59d
  github.com/gravitational/teleport/lib/auth.GenerateIdentity()
      /__w/teleport.e/teleport.e/lib/auth/init.go:1606 +0x450
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).reRegister()
      /__w/teleport.e/teleport.e/lib/service/connect.go:450 +0x25a
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).rotate()
      /__w/teleport.e/teleport.e/lib/service/connect.go:1160 +0xaa7
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncServiceRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:1017 +0x20b
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:996 +0x1c9
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationStateAndBroadcast()
      /__w/teleport.e/teleport.e/lib/service/connect.go:962 +0x4e
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).syncRotationStateCycle()
      /__w/teleport.e/teleport.e/lib/service/connect.go:906 +0xcb
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).periodicSyncRotationState()
      /__w/teleport.e/teleport.e/lib/service/connect.go:870 +0x5f3
  github.com/gravitational/teleport/lib/service.(*TeleportProcess).periodicSyncRotationState-fm()
      <autogenerated>:1 +0x33
  github.com/gravitational/teleport/lib/service.(*LocalService).Serve()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:605 +0x35
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).serve.func1()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:328 +0x4a2

Goroutine 168 (running) created at:
  testing.(*T).Run()
      /opt/go/src/testing/testing.go:1997 +0x9d2
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:285 +0x691
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44

Goroutine 9018 (running) created at:
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).serve()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:317 +0x10a
  github.com/gravitational/teleport/lib/service.(*LocalSupervisor).Start()
      /__w/teleport.e/teleport.e/lib/service/supervisor.go:360 +0x2f6
  github.com/gravitational/teleport/lib/client_test.startAndWait()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:804 +0x91
  github.com/gravitational/teleport/lib/client_test.startAndWait()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:802 +0x45
  github.com/gravitational/teleport/lib/client_test.newStandaloneTeleport()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:621 +0x1092
  github.com/gravitational/teleport/lib/client_test.TestTeleportClient_Login_local.func21()
      /__w/teleport.e/teleport.e/lib/client/api_login_test.go:290 +0x14e
  testing.tRunner()
      /opt/go/src/testing/testing.go:1934 +0x21c
  testing.(*T).Run.gowrap1()
      /opt/go/src/testing/testing.go:1997 +0x44
==================  
```

The setter is also redundant - Auth already exposes a way
to be constructed with a custom clock. In order to get rid
of the races once and for all, the clock setter was removed and
all tests have been updated to plumb the clock through on
construction.
2025-10-29 15:19:44 +00:00
..