fix(tailnet): track agent names for http debug (#8744)

This commit is contained in:
Colin Adler
2023-07-26 18:44:10 +00:00
committed by GitHub
parent b5dec61cd5
commit 6b92abebb9
5 changed files with 23 additions and 18 deletions
+2 -2
View File
@@ -262,7 +262,7 @@ func (c *coordinator) ServeClient(conn net.Conn, id, agentID uuid.UUID) error {
logger := c.core.clientLogger(id, agentID)
logger.Debug(ctx, "coordinating client")
tc := NewTrackedConn(ctx, cancel, conn, id, logger, 0)
tc := NewTrackedConn(ctx, cancel, conn, id, logger, id.String(), 0)
defer tc.Close()
c.core.addClient(id, tc)
@@ -507,7 +507,7 @@ func (c *core) initAndTrackAgent(ctx context.Context, cancel func(), conn net.Co
overwrites = oldAgentSocket.Overwrites() + 1
_ = oldAgentSocket.Close()
}
tc := NewTrackedConn(ctx, cancel, conn, unique, logger, overwrites)
tc := NewTrackedConn(ctx, cancel, conn, unique, logger, name, overwrites)
c.agentNameCache.Add(id, name)
sockets, ok := c.agentToConnectionSockets[id]
+2 -1
View File
@@ -35,7 +35,7 @@ type TrackedConn struct {
overwrites int64
}
func NewTrackedConn(ctx context.Context, cancel func(), conn net.Conn, id uuid.UUID, logger slog.Logger, overwrites int64) *TrackedConn {
func NewTrackedConn(ctx context.Context, cancel func(), conn net.Conn, id uuid.UUID, logger slog.Logger, name string, overwrites int64) *TrackedConn {
// buffer updates so they don't block, since we hold the
// coordinator mutex while queuing. Node updates don't
// come quickly, so 512 should be plenty for all but
@@ -51,6 +51,7 @@ func NewTrackedConn(ctx context.Context, cancel func(), conn net.Conn, id uuid.U
id: id,
start: now,
lastWrite: now,
name: name,
overwrites: overwrites,
}
}