Skip to content

main: system subcommand#537

Open
supakeen wants to merge 2 commits into
osbuild:mainfrom
supakeen:cache-subcommand
Open

main: system subcommand#537
supakeen wants to merge 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

Introduce a `system` subcommand that we can add additional subcommands
to to manage (for example) the cache.

Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
@supakeen supakeen requested a review from a team as a code owner June 1, 2026 05:45
Print the current usage of the cache directory. Handle the case of it
being unlimited or unknown.

Signed-off-by: Simon de Vlieger <cmdr@supakeen.com>
@supakeen supakeen force-pushed the cache-subcommand branch from 0f215dd to 339db78 Compare June 1, 2026 07:59

@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
Comment thread cmd/image-builder/system.go
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants