Repository navigation
Don't fail container list when size lookup fails - #53921
Conversation
|
|
||
| ok := setupContainerWithName(t, "ok", d) | ||
| bad := setupContainerWithName(t, "bad", d) | ||
| bad.Created = ok.Created.Add(time.Millisecond) |
There was a problem hiding this comment.
nit: this isn't needed
| bad.Created = ok.Created.Add(time.Millisecond) |
There was a problem hiding this comment.
Removed in 31abdb8, along with the ok variable it left unused.
| // Don't fail the whole listing because the size of a | ||
| // single container can't be determined. | ||
| log.G(ctx).WithFields(log.Fields{ | ||
| "error": err, | ||
| "containerID": newC.ID, | ||
| }).Warn("failed to get container layer size") |
There was a problem hiding this comment.
Looks like in other places we made this a Debug;
Lines 71 to 77 in 553420b
That said, I'm wondering if we should also special-case "not found" errors if they are potentially expected. In that case we could even consider setting the sizes to 0. Could there also be a situation where only one (SizeRw or SizeRootFs) cannot be found? (writable layer already gone, but rootFS not?) 🤔
There was a problem hiding this comment.
Looks like there's some handling already for not found in the function we're calling, including some logging (so we could end up with multiple logs for the same error);
moby/daemon/containerd/service.go
Lines 343 to 366 in a0ae589
There was a problem hiding this comment.
Switched to Debug in 31abdb8. No double log: a missing rw snapshot comes back from service.go as 0, 0 plus NotFound without logging; the parent case it logs returns no error (SizeRootFs just under-counts). SizeRootFs is rw + parents, so if rw fails neither is available. Graphdriver returns 0, 0 for a missing layer, and system df sums SizeRw, so -1 skews it; happy to map NotFound to 0 if you prefer.
|
@drakeo338 can you please squash the commits? |
When listing containers with size=true, an error from GetContainerLayerSize for a single container (for example the containerd snapshotter failing to compute usage for a container whose snapshot is gone) was returned from the worker and made the whole request fail, so one broken container made 'docker ps -s' and 'docker system df' unusable. Log the error at debug level, as prune does for the same error, report the sizes of that container as -1, which is what the graphdriver image service already does when it cannot compute the size, and keep the container in the result. Signed-off-by: drakeo338 <[email protected]>
31abdb8 to
9f89432
Compare
|
Squashed into one commit, 9f89432, with the same tree as before. |
Summary
With
size=true, an error fromGetContainerLayerSizefor a single container (for example the containerd snapshotter failing on a container whose snapshot is gone) failed the whole container list, so one broken container madedocker ps -sanddocker system dfunusable. The list now logs the error at debug level, reports that container's sizes as -1 (as the graphdriver image service does for SizeRw whenSize()fails), and keeps the container in the result.TestContainerList_SizeErrorcovers it: it fails before the change and passes after.AI disclosure: written with Claude Code (AI-assisted, mostly AI-drafted); I reviewed the change and ran the daemon tests.
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)
Skipped.