mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
test(scaletest/workspacetraffic): fix test flake due to io.EOF on close (#21231)
Fixes coder/internal#119
This commit is contained in:
committed by
GitHub
parent
96fca0188e
commit
498c565fc7
@@ -147,8 +147,9 @@ func connectSSH(ctx context.Context, client *codersdk.Client, agentID uuid.UUID,
|
||||
var closers []func() error
|
||||
defer func() {
|
||||
if err != nil {
|
||||
for _, c := range closers {
|
||||
if err2 := c(); err2 != nil {
|
||||
// Reverse order, like defer.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
if err2 := closers[i](); err2 != nil {
|
||||
err = errors.Join(err, err2)
|
||||
}
|
||||
}
|
||||
@@ -227,8 +228,9 @@ func connectSSH(ctx context.Context, client *codersdk.Client, agentID uuid.UUID,
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, c := range closers {
|
||||
if err := c(); err != nil {
|
||||
// Reverse order, like defer.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
if err := closers[i](); err != nil {
|
||||
if !errors.Is(err, io.EOF) {
|
||||
merr = errors.Join(merr, err)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package workspacetraffic
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"math/rand"
|
||||
@@ -131,8 +132,11 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) (err error)
|
||||
closeConn := func() error {
|
||||
closeOnce.Do(func() {
|
||||
closeErr = conn.Close()
|
||||
if closeErr != nil {
|
||||
if errors.Is(closeErr, io.EOF) {
|
||||
closeErr = nil
|
||||
} else if closeErr != nil {
|
||||
logger.Error(ctx, "close agent connection", slog.Error(closeErr))
|
||||
closeErr = xerrors.Errorf("close agent connection: %w", closeErr)
|
||||
}
|
||||
})
|
||||
return closeErr
|
||||
|
||||
Reference in New Issue
Block a user