Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agents/k8s-agent/agent_vnc_tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (m *VNCTunnelManager) CloseTunnel(sessionID string) error {

// Close connection
if tunnel.conn != nil {
tunnel.conn.Close()
_ = tunnel.conn.Close()
}

log.Printf("[VNCTunnel] Tunnel closed for session %s", sessionID)
Expand Down
2 changes: 1 addition & 1 deletion agents/k8s-agent/internal/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
ErrCommandFailed = stderrors.New("command execution failed")
ErrSessionNotFound = stderrors.New("session not found")
ErrTemplateNotFound = stderrors.New("template not found")
ErrResourceNotFound = stderrors.New("Kubernetes resource not found")
ErrResourceNotFound = stderrors.New("kubernetes resource not found")
)

// Kubernetes errors
Expand Down
8 changes: 4 additions & 4 deletions agents/k8s-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (a *K8sAgent) shutdown() {

if a.wsConn != nil {
// Close connection (writePump already stopped, safe to close directly)
a.wsConn.Close()
_ = a.wsConn.Close()
a.wsConn = nil
}

Expand Down Expand Up @@ -533,7 +533,7 @@ func (a *K8sAgent) registerAgent() error {
if err != nil {
return fmt.Errorf("HTTP request failed: %w", err)
}
defer resp.Body.Close()
defer func() { _ = resp.Body.Close() }()

// Check response status
// ISSUE #234: Accept 202 Accepted for pending approval workflow
Expand Down Expand Up @@ -580,11 +580,11 @@ func (a *K8sAgent) registerAgent() error {
// Check if still pending
var retryRegResp AgentRegistrationResponse
if err := json.NewDecoder(retryResp.Body).Decode(&retryRegResp); err != nil {
retryResp.Body.Close()
_ = retryResp.Body.Close()
log.Printf("[K8sAgent] Failed to decode retry response: %v. Continuing to wait...", err)
continue
}
retryResp.Body.Close()
_ = retryResp.Body.Close()

// Check approval status
if retryRegResp.ApprovalStatus == "pending" {
Expand Down
15 changes: 14 additions & 1 deletion api/internal/services/command_dispatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,20 @@ func TestProcessCommandAgentConnected(t *testing.T) {
t.Fatalf("Failed to register agent: %v", err)
}

time.Sleep(100 * time.Millisecond)
// Wait for the registration UPDATE to drain through the Run() goroutine
// before declaring the next expectation. See agent_hub_test.go for the
// underlying go-sqlmock <=1.5.2 race rationale.
deadline := time.After(2 * time.Second)
for {
if mock.ExpectationsWereMet() == nil {
break
}
select {
case <-deadline:
t.Fatal("timeout waiting for registration UPDATE to be consumed")
case <-time.After(5 * time.Millisecond):
}
}

// Start dispatcher
go dispatcher.Start()
Expand Down
Loading