mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: refactor autobuild/notify to use clock test (#13566)
Refactor autobuild/notify and tests to use the clock testing library. I also rewrote some of the comments because I didn't understand them when I was looking at the package.
This commit is contained in:
+2
-2
@@ -711,12 +711,12 @@ func tryPollWorkspaceAutostop(ctx context.Context, client *codersdk.Client, work
|
||||
lock := flock.New(filepath.Join(os.TempDir(), "coder-autostop-notify-"+workspace.ID.String()))
|
||||
conditionCtx, cancelCondition := context.WithCancel(ctx)
|
||||
condition := notifyCondition(conditionCtx, client, workspace.ID, lock)
|
||||
stopFunc := notify.Notify(condition, workspacePollInterval, autostopNotifyCountdown...)
|
||||
notifier := notify.New(condition, workspacePollInterval, autostopNotifyCountdown)
|
||||
return func() {
|
||||
// With many "ssh" processes running, `lock.TryLockContext` can be hanging until the context canceled.
|
||||
// Without this cancellation, a CLI process with failed remote-forward could be hanging indefinitely.
|
||||
cancelCondition()
|
||||
stopFunc()
|
||||
notifier.Close()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user