daemon, client: diskUsage: explicitly exclude "-1" for containers#52309
Merged
vvoland merged 2 commits intomoby:masterfrom Apr 13, 2026
Merged
daemon, client: diskUsage: explicitly exclude "-1" for containers#52309vvoland merged 2 commits intomoby:masterfrom
vvoland merged 2 commits intomoby:masterfrom
Conversation
c2880c4 to
d092510
Compare
vvoland
approved these changes
Apr 10, 2026
Comment on lines
+248
to
+255
| if img.Containers > 0 { | ||
| idu.ActiveCount++ | ||
| } else if i.Size != -1 && i.SharedSize != -1 { | ||
| } else if img.Containers == 0 && img.Size != -1 && img.SharedSize != -1 { | ||
| // Only count reclaimable size if we have size information | ||
| idu.Reclaimable += (i.Size - i.SharedSize) | ||
| // and container-count is known to be zero (-1 means no | ||
| // information was available). | ||
| reclaimable := img.Size - img.SharedSize | ||
| idu.Reclaimable += reclaimable |
Contributor
There was a problem hiding this comment.
nitty opinionated nit: switch would be a little bit more readable IMO 😅
Suggested change
| if img.Containers > 0 { | |
| idu.ActiveCount++ | |
| } else if i.Size != -1 && i.SharedSize != -1 { | |
| } else if img.Containers == 0 && img.Size != -1 && img.SharedSize != -1 { | |
| // Only count reclaimable size if we have size information | |
| idu.Reclaimable += (i.Size - i.SharedSize) | |
| // and container-count is known to be zero (-1 means no | |
| // information was available). | |
| reclaimable := img.Size - img.SharedSize | |
| idu.Reclaimable += reclaimable | |
| switch { | |
| case img.Containers <= 0: | |
| // No container-count information available; skip. | |
| case img.Containers > 0: | |
| du.ActiveCount++ | |
| case img.Size != -1 && img.SharedSize != -1: | |
| reclaimable := img.Size - img.SharedSize | |
| du.Reclaimable += reclaimable | |
| } |
Member
Author
There was a problem hiding this comment.
Ah, yes, I agree. Not sure why I didn't do that; usually i'm the one suggesting that 😂
I'll update
Member
Author
There was a problem hiding this comment.
Updated, but I made a small change 😂 😉
-case img.Containers <= 0:
+case img.Containers < 0:The Containers field is set to "-1" if no information was collected; in practice this should not happen when we collect diskusage information, but let's be explicit. Also rename the "i" variable to prevent it from being mistaken for the slice's index value. Follow-up to 46dba49 Signed-off-by: Sebastiaan van Stijn <[email protected]>
…ainers The Containers field is set to "-1" if no information was collected; in practice this should not happen when we collect diskusage information, but let's be explicit. Also rename the "i" variable to prevent it from being mistaken for the slice's index value. Follow-up to 46dba49 Signed-off-by: Sebastiaan van Stijn <[email protected]>
d092510 to
1a45789
Compare
vvoland
approved these changes
Apr 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Containers field is set to "-1" if no information was collected; in
practice this should not happen when we collect diskusage information,
but let's be explicit.
Also rename the "i" variable to prevent it from being mistaken for the
slice's index value.
Follow-up to 46dba49
- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)