Skip to content

Commit 750fb5c

Browse files
committed
fix: copilot issues
Signed-off-by: Gustavo Carvalho <gustavo.carvalho@container-solutions.com>
1 parent a4e9f40 commit 750fb5c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,10 @@ func (e *CommandCustodianExecutor) logCustodianProcessSockets(pid int, checkName
10011001
e.Logger.Warn("Failed collecting custodian child socket snapshot", "check_name", checkName, "pid", pid, "error", err)
10021002
return
10031003
}
1004+
if len(sockets) == 0 {
1005+
e.Logger.Debug("No custodian child sockets found", "check_name", checkName, "pid", pid)
1006+
return
1007+
}
10041008
e.Logger.Info("Custodian child socket snapshot", "check_name", checkName, "pid", pid, "socket_count", len(sockets), "sockets", sockets)
10051009
}
10061010

main_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,20 @@ func TestDiagnosticHelpers(t *testing.T) {
11461146
}
11471147
})
11481148

1149+
t.Run("does not info log empty socket snapshots", func(t *testing.T) {
1150+
var logs bytes.Buffer
1151+
executor := &CommandCustodianExecutor{Logger: hclog.New(&hclog.LoggerOptions{
1152+
Name: "test",
1153+
Level: hclog.Info,
1154+
Output: &logs,
1155+
})}
1156+
1157+
executor.logCustodianProcessSockets(-1, "test-policy")
1158+
if strings.Contains(logs.String(), "Custodian child socket snapshot") {
1159+
t.Fatalf("expected no info socket snapshot log for empty sockets, got %q", logs.String())
1160+
}
1161+
})
1162+
11491163
t.Run("reports unknown resource types", func(t *testing.T) {
11501164
hosts, known := awsEndpointHostsForCheck("aws.not-yet-mapped", []string{"eu-west-1"})
11511165
if known {

0 commit comments

Comments
 (0)