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

Skip to content

Commit 0abe0a1

Browse files
committed
fix status
1 parent cba296c commit 0abe0a1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cli/speedtest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func speedtest() *cobra.Command {
7575
if err != nil {
7676
continue
7777
}
78-
status := conn.Status()
78+
status := conn.Status(true)
7979
if len(status.Peers()) != 1 {
8080
continue
8181
}

scaletest/agentconn/run.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (r *Runner) Run(ctx context.Context, _ string, logs io.Writer) error {
8787

8888
// Ensure DERP for completeness.
8989
if r.cfg.ConnectionMode == ConnectionModeDerp {
90-
status := conn.Status()
90+
status := conn.Status(true)
9191
if len(status.Peers()) != 1 {
9292
return xerrors.Errorf("check connection mode: expected 1 peer, got %d", len(status.Peers()))
9393
}
@@ -141,9 +141,10 @@ func waitForDisco(ctx context.Context, logs io.Writer, conn *codersdk.WorkspaceA
141141
for i := 0; i < pingAttempts; i++ {
142142
_, _ = fmt.Fprintf(logs, "\tDisco ping attempt %d/%d...\n", i+1, pingAttempts)
143143
pingCtx, cancel := context.WithTimeout(ctx, defaultRequestTimeout)
144-
_, _, err := conn.Ping(pingCtx)
144+
_, p2p, err := conn.Ping(pingCtx)
145145
cancel()
146146
if err == nil {
147+
_, _ = fmt.Fprintf(logs, "\tDisco ping succeeded after %d attempts, p2p = %v\n", i+1, p2p)
147148
break
148149
}
149150
if i == pingAttempts-1 {
@@ -171,11 +172,11 @@ func waitForDirectConnection(ctx context.Context, logs io.Writer, conn *codersdk
171172

172173
for i := 0; i < directConnectionAttempts; i++ {
173174
_, _ = fmt.Fprintf(logs, "\tDirect connection check %d/%d...\n", i+1, directConnectionAttempts)
174-
status := conn.Status()
175+
status := conn.Status(true)
175176

176177
var err error
177178
if len(status.Peers()) != 1 {
178-
_, _ = fmt.Fprintf(logs, "\t\tExpected 1 peer, found %d", len(status.Peers()))
179+
_, _ = fmt.Fprintf(logs, "\t\tExpected 1 peer, found %d\n", len(status.Peers()))
179180
err = xerrors.Errorf("expected 1 peer, got %d", len(status.Peers()))
180181
} else {
181182
peer := status.Peer[status.Peers()[0]]

tailnet/conn.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func (c *Conn) RemoveAllPeers() error {
353353
func (c *Conn) UpdateNodes(nodes []*Node) error {
354354
c.mutex.Lock()
355355
defer c.mutex.Unlock()
356-
status := c.Status()
356+
status := c.Status(true)
357357
for _, peer := range c.netMap.Peers {
358358
peerStatus, ok := status.Peer[peer.Key]
359359
if !ok {
@@ -424,8 +424,8 @@ func (c *Conn) UpdateNodes(nodes []*Node) error {
424424
}
425425

426426
// Status returns the current ipnstate of a connection.
427-
func (c *Conn) Status() *ipnstate.Status {
428-
sb := &ipnstate.StatusBuilder{}
427+
func (c *Conn) Status(wantPeers bool) *ipnstate.Status {
428+
sb := &ipnstate.StatusBuilder{WantPeers: wantPeers}
429429
c.wireguardEngine.UpdateStatus(sb)
430430
return sb.Status()
431431
}

0 commit comments

Comments
 (0)