Skip to content

Commit d01b7a1

Browse files
Karlclaude
andcommitted
Fix macOS containerd timeout on prune --all
- Fast-fail in containerd.New() with os.Stat check before lazy gRPC dial, avoiding multi-second timeout when containerd socket is absent (e.g. macOS) - Make runSystemPruneAll warn-and-skip on per-backend scan/prune failures instead of returning an error, so unavailable backends don't abort the whole prune operation Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 7ae8c63 commit d01b7a1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

internal/cli/system_prune.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ func runSystemPruneAll(cmd *cobra.Command, dryRun, yes bool) error {
185185
return err
186186
})
187187
if err != nil {
188-
return fmt.Errorf("scan %s: %w", b.Name, err)
188+
fmt.Fprintf(output, "Warning: scan %s failed: %v\n", b.Name, err) //nolint:errcheck
189+
continue
189190
}
190191
allItems = append(allItems, result.Items...)
191192
}
@@ -257,7 +258,7 @@ func runSystemPruneAll(cmd *cobra.Command, dryRun, yes bool) error {
257258
return err
258259
})
259260
if err != nil {
260-
return fmt.Errorf("prune %s: %w", name, err)
261+
fmt.Fprintf(output, "Warning: prune %s failed: %v\n", name, err) //nolint:errcheck
261262
}
262263
}
263264
if !isJSON {

runtime/containerd/containerd.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ type Runtime struct {
2727
var _ runtime.Runtime = (*Runtime)(nil)
2828
var _ runtime.IsolationValidator = (*Runtime)(nil)
2929

30+
const containerdSock = "/run/containerd/containerd.sock"
31+
3032
// New connects to the containerd daemon and returns a Runtime.
3133
// It does not validate isolation prerequisites — that is done via ValidateIsolation.
3234
func New(_ context.Context) (*Runtime, error) {
33-
c, err := client.New("/run/containerd/containerd.sock")
35+
// Fast-fail if the socket file doesn't exist — avoids a slow dial timeout
36+
// on systems where containerd is not installed (e.g. macOS).
37+
if _, err := os.Stat(containerdSock); err != nil {
38+
return nil, fmt.Errorf("containerd socket not found at %s\n Is containerd running? Try: sudo systemctl start containerd", containerdSock)
39+
}
40+
c, err := client.New(containerdSock)
3441
if err != nil {
3542
return nil, fmt.Errorf("connect to containerd: %w\n Is containerd running? Try: sudo systemctl start containerd", err)
3643
}

0 commit comments

Comments
 (0)