Skip to content
This repository was archived by the owner on Sep 1, 2026. It is now read-only.

main: system subcommand - #537

Merged
achilleas-k merged 2 commits into
osbuild:mainfrom
supakeen:cache-subcommand
Jun 16, 2026
Merged

achilleas-k merged 2 commits into
osbuild:mainfrom
supakeen:cache-subcommand

Conversation

@supakeen

@supakeen supakeen commented Jun 1, 2026 •

Copy link
Copy Markdown
Member

Let's add a system subcommand that (initially) shows information about the cache location, its max-size and its current size.

This will be a good umbrella subcommand to hang other commands under such as prune to clear cache in the future.

€ sudo ./image-builder system
system:
  cache:
    path: /var/cache/image-builder/store
    size: 388024255
    max-size: unlimited

@supakeen
supakeen requested a review from a team as a code owner June 1, 2026 05:45

@avitova avitova left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small question. 🤏

Comment thread cmd/image-builder/system.go Resolved
Comment thread cmd/image-builder/system.go Resolved
Comment on lines +53 to +69
func calcDirSize(path string) (int64, error) {
var total int64
err := filepath.WalkDir(path, func(_ string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if !d.IsDir() {
info, err := d.Info()
if err != nil {
return err
}
total += info.Size()
}
return nil
})
return total, err
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

osbuild maintains a file in the root of the cache with the current size, so we could read that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it seems it's updated by calculating writes and deletes, not measuring. I checked mine right now and it's off from the real size on disk by quite a bit. Perhaps a bug for osbuild.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are a bit buggy I think, on the osbuild side and the code in this PR. Especially if mountpoints are set up.

supakeen added 2 commits June 16, 2026 14:21
Introduce a `system` subcommand that we can add additional subcommands
to to manage (for example) the cache.

Signed-off-by: Simon de Vlieger <[email protected]>
Print the current usage of the cache directory. Handle the case of it
being unlimited or unknown.

Signed-off-by: Simon de Vlieger <[email protected]>
@supakeen
supakeen requested review from achilleas-k and avitova June 16, 2026 12:21
@achilleas-k
achilleas-k enabled auto-merge June 16, 2026 15:16

@brlane-rht brlane-rht left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would argue that prettySystemStatus outputting yaml doesn't live up to its name, but it is better than json :)

@achilleas-k
achilleas-k added this pull request to the merge queue Jun 16, 2026
Merged via the queue into osbuild:main with commit 0471362 Jun 16, 2026
39 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants