Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7cce7a9

Browse files
authored
test: Write URL after signal listen to fix flake (#2456)
The URL could be read before the signal was listening, causing this test to flake: https://github.com/coder/coder/runs/6936820170?check_suite_focus=true
1 parent f09ab03 commit 7cce7a9

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

cli/server.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,6 @@ func server() *cobra.Command {
408408
errCh <- wg.Wait()
409409
}()
410410

411-
// This is helpful for tests, but can be silently ignored.
412-
// Coder may be ran as users that don't have permission to write in the homedir,
413-
// such as via the systemd service.
414-
_ = config.URL().Write(client.URL.String())
415-
416411
hasFirstUser, err := client.HasFirstUser(cmd.Context())
417412
if !hasFirstUser && err == nil {
418413
cmd.Println()
@@ -442,6 +437,12 @@ func server() *cobra.Command {
442437
stopChan := make(chan os.Signal, 1)
443438
defer signal.Stop(stopChan)
444439
signal.Notify(stopChan, os.Interrupt)
440+
441+
// This is helpful for tests, but can be silently ignored.
442+
// Coder may be ran as users that don't have permission to write in the homedir,
443+
// such as via the systemd service.
444+
_ = config.URL().Write(client.URL.String())
445+
445446
select {
446447
case <-cmd.Context().Done():
447448
coderAPI.Close()

coderd/provisionerdaemons.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (api *API) ListenProvisionerDaemon(ctx context.Context) (client proto.DRPCP
9696
},
9797
})
9898
go func() {
99-
err = server.Serve(ctx, serverSession)
99+
err := server.Serve(ctx, serverSession)
100100
if err != nil && !xerrors.Is(err, io.EOF) {
101101
api.Logger.Debug(ctx, "provisioner daemon disconnected", slog.Error(err))
102102
}

0 commit comments

Comments
 (0)