Skip to content

Commit 8ce90ab

Browse files
committed
refactor: hardcode boundary audit socket path
Always create socket at /tmp/boundary-audit.sock instead of using CLI flag or env var. This simplifies configuration since boundary uses the same well-known path.
1 parent 1f90597 commit 8ce90ab

File tree

2 files changed

+8
-21
lines changed

2 files changed

+8
-21
lines changed

agent/agent.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ type Options struct {
101101
Clock quartz.Clock
102102
SocketServerEnabled bool
103103
SocketPath string // Path for the agent socket server socket
104-
BoundaryLogSocket string // Path for the boundary audit log socket
105104
}
106105

107106
type Client interface {
@@ -209,7 +208,6 @@ func New(options Options) Agent {
209208
containerAPIOptions: options.DevcontainerAPIOptions,
210209
socketPath: options.SocketPath,
211210
socketServerEnabled: options.SocketServerEnabled,
212-
boundaryLogSocket: options.BoundaryLogSocket,
213211
}
214212
// Initially, we have a closed channel, reflecting the fact that we are not initially connected.
215213
// Each time we connect we replace the channel (while holding the closeMutex) with a new one
@@ -293,7 +291,6 @@ type agent struct {
293291
socketServerEnabled bool
294292
socketPath string
295293
socketServer *agentsocket.Server
296-
boundaryLogSocket string
297294
}
298295

299296
func (a *agent) TailnetConn() *tailnet.Conn {
@@ -400,25 +397,23 @@ func (a *agent) initSocketServer() {
400397
a.logger.Debug(a.hardCtx, "socket server started", slog.F("path", a.socketPath))
401398
}
402399

403-
// startBoundaryLogProxyServer starts the boundary log proxy socket server if
404-
// configured via the --boundary-log-socket flag or CODER_AGENT_BOUNDARY_LOG_SOCKET
405-
// env var.
406-
func (a *agent) startBoundaryLogProxyServer() {
407-
if a.boundaryLogSocket == "" {
408-
return
409-
}
400+
// boundaryAuditSocketPath is the well-known path for the boundary audit log socket.
401+
// Boundary connects to this socket to send audit logs to the agent.
402+
const boundaryAuditSocketPath = "/tmp/boundary-audit.sock"
410403

411-
proxy := boundarylogproxy.NewServer(a.logger, a.boundaryLogSocket)
404+
// startBoundaryLogProxyServer starts the boundary log proxy socket server.
405+
// The socket is always created at the well-known path so boundary can connect.
406+
func (a *agent) startBoundaryLogProxyServer() {
407+
proxy := boundarylogproxy.NewServer(a.logger, boundaryAuditSocketPath)
412408
if err := proxy.Start(a.hardCtx); err != nil {
413409
a.logger.Warn(a.hardCtx, "failed to start boundary log proxy", slog.Error(err))
414410
return
415411
}
416412

417413
a.boundaryLogProxy = proxy
418414
a.logger.Info(a.hardCtx, "boundary log proxy server started",
419-
slog.F("socket_path", a.boundaryLogSocket))
415+
slog.F("socket_path", boundaryAuditSocketPath))
420416
}
421-
422417
// forwardBoundaryLogs forwards buffered boundary audit logs to coderd.
423418
// This is called via startAgentAPI to ensure the API client is always current.
424419
func (a *agent) forwardBoundaryLogs(ctx context.Context, aAPI proto.DRPCAgentClient27) error {

cli/agent.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ func workspaceAgent() *serpent.Command {
5959
devcontainerDiscoveryAutostart bool
6060
socketServerEnabled bool
6161
socketPath string
62-
boundaryLogSocket string
6362
)
6463
agentAuth := &AgentAuth{}
6564
cmd := &serpent.Command{
@@ -322,7 +321,6 @@ func workspaceAgent() *serpent.Command {
322321
},
323322
SocketPath: socketPath,
324323
SocketServerEnabled: socketServerEnabled,
325-
BoundaryLogSocket: boundaryLogSocket,
326324
})
327325

328326
if debugAddress != "" {
@@ -496,12 +494,6 @@ func workspaceAgent() *serpent.Command {
496494
Description: "Specify the path for the agent socket.",
497495
Value: serpent.StringOf(&socketPath),
498496
},
499-
{
500-
Flag: "boundary-log-socket",
501-
Env: "CODER_AGENT_BOUNDARY_LOG_SOCKET",
502-
Description: "Path to the boundary audit log socket. If set, the agent listens for boundary logs on this socket and forwards them to coderd.",
503-
Value: serpent.StringOf(&boundaryLogSocket),
504-
},
505497
}
506498
agentAuth.AttachOptions(cmd, false)
507499
return cmd

0 commit comments

Comments
 (0)