Skip to content

New subcommand: image-builder prefetch [HMS-11467] - #2792

Merged
supakeen merged 5 commits into
osbuild:mainfrom
achilleas-k:cmd/fetch-sources
Oct 28, 2026
Merged

supakeen merged 5 commits into
osbuild:mainfrom
achilleas-k:cmd/fetch-sources

Conversation

@achilleas-k

Copy link
Copy Markdown
Member

Add new subcommand for pre-fetching sources defined in a manifest, preparing the osbuild source cache for a fully offline, hermetic build.

Tests mock the osbuild binary by overwriting the $PATH env, instead of modifying the command itself like we do in other places. The tests check that the arguments passed to osbuild are the expected ones for the subcommand.

I opened #2791 because I think we have too much code for mocking such things in slightly different ways.

The 'cache' option maps directly to osbuild's 'cache' / 'store' option.
Use the same description in image-builder that we have in osbuild, only
prefix it with 'osbuild' to make it clear this is an option that's
passed through to osbuild itself.
@achilleas-k

Copy link
Copy Markdown
Member Author

I'm still not entirely happy with the way we define our subcommands and their flags. There's some non-trivial interactions between arguments that we haven't fully mapped out yet and are difficult to trace the way they're written now. Ideally, we would centralise argument handling so we can clearly define, for example, how the progress, verbose, and format options interact.

Add dedicated functions for specific flagsets and flags that are shared
among subcommands.  The new function takes any cobra.Command and adds a
set of flags to it.

Flag sharing becomes more explicit here.  For the 'build' subcommand,
instead of directly inheriting the flags from 'manifest' and 'upload',
it reuses the same functions those two subcommands use to define their
flag set.  For flagsets, the benefits are small: It allows us to add a
flag to 'manifest' or 'upload' without it being immediately inherited by
'build' if we need to.  For single flags that are shared between
subcommands ('rpmmd-cache' and, soon, 'cache') it makes it easier to
share the definition and help text.
Add new subcommand for pre-fetching sources defined in a manifest,
preparing the osbuild source cache for a fully offline, hermetic build.
Test the new command using only a mocked osbuild binary that saves the
command line args for verification.
The flag isn't moved to its own function like we did with the other ones
because the description differs for each subcommand (valid values).
@achilleas-k

Copy link
Copy Markdown
Member Author

I'm open to suggestions for a better name for the command, btw.

@brlane-rht brlane-rht 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.

Looks ok, although I'm not sure of the use case. When would you have a manifest you wanted to prefetch without actually running the build?

@supakeen

supakeen commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Looks ok, although I'm not sure of the use case. When would you have a manifest you wanted to prefetch without actually running the build?

Hermetic build systems (like Konflux) want to do the networking separately from the build.


As for the name (because the code seems mostly fine anyhow); prefetch is OK and if you really want to I'd accept it but putting it on the main command might be a bit too much, especially knowing there will be other commands as well. Do we want to put it behind a subcommand maybe?

This kinda depends on how many steps we'll have and how the 'use prefetch' is going to be codified; if it's just going to be an argument on build then it makes sense to have prefetch be top-level as well.

Correct me if I'm wrong but we're going to have something like:

  1. image-builder manifest ... > manifest.json
  2. image-builder prefetch manifest.json ./prefetched
  3. image-builder build --prefetched ./prefetched --from-manifest manifest.json

Or such? I think knowing the other steps is probably a good way to figure out if prefetch fits on the top-level :)

@brlane-rht

Copy link
Copy Markdown
Contributor
  • image-builder manifest ... > manifest.json

  • image-builder prefetch manifest.json ./prefetched

  • image-builder build --prefetched ./prefetched --from-manifest manifest.json

Or maybe image-builder manifest --prefetch ./cachedir ... so you don't need to keep the manifest around, just use the same args you'd use with build.

@achilleas-k

Copy link
Copy Markdown
Member Author

Correct me if I'm wrong but we're going to have something like:

1. `image-builder manifest ... > manifest.json`

2. `image-builder prefetch manifest.json ./prefetched`

3. `image-builder build --prefetched ./prefetched --from-manifest manifest.json`

Or such? I think knowing the other steps is probably a good way to figure out if prefetch fits on the top-level :)

This is what I was thinking, yes, though --prefetched ./prefetched isn't necessary, that's covered by the --cache option.

But maybe we should examine all possibilities before merging here. There are a lot of other options here. For example, we could avoid new subcommands entirely:

  • image-builder manifest > manifest.json
  • image-builder build --prefetch manifest.json
  • image-builder build --manifest manifest.json

or as Brian suggested, the prefetch can be part of the manifest subcommand.

The other extreme is adding new subcommands for everything (I don't like this):

  • image-builder manifest > manifest.json
  • image-builder prefetch manifest.json
  • image-builder build-manifest manifest.json

My plan when writing this was what you suggested. The next step would be to add a --manifest option to the build command (and think a bit about how we carry the export pipeline name).

@achilleas-k

Copy link
Copy Markdown
Member Author

so you don't need to keep the manifest around, just use the same args you'd use with build

I think it's important that we use the manifest to connect all three operations, otherwise there will always be a risk, however small, that the build call will produce a manifest with slightly different packages (for example, if a repository update happens between prefetch and build).

@brlane-rht

Copy link
Copy Markdown
Contributor

I think it's important that we use the manifest to connect all three operations, otherwise there will always be a risk, however small, that the build call will produce a manifest with slightly different packages (for example, if a repository update happens between prefetch and build).

So then a new question is, do we even need to add this to image-builder? We're basically passing it through to osbuild already so instead add a fetch-only command to osbuild and pass it the manifest, and document that for users.

@achilleas-k

Copy link
Copy Markdown
Member Author

We're basically passing it through to osbuild already so instead add a fetch-only command to osbuild and pass it the manifest, and document that for users.

Normally I would agree but the main reason for this is integrating with Konflux and giving that tool the ability to break down the steps so it can control the environment for each (generate manifest with network access, fetch sources with network access, do the build without). We want to provide a nice interface for that build system to do all these through image-builder directly, even if those things are pretty much straight passthrough to osbuild itself. It lets use control the flow better, like reusing default paths or command line options. It also means that users (human or otherwise) get the same control of output, whether that's a progress bar, direct output from osbuild, or a json response.

@supakeen

Copy link
Copy Markdown
Member

While osbuild is user-callable I'd prefer things to flow through image-builder for a user friendly CLI as well.

@supakeen supakeen left a comment •

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.

I'm fine with having the prefetch command be on the main executable; it's generic over all manifests/sources and just warms the cache. Naming discussion on actually enforcing 'only use cache' (because that's what's really going on) is for later.

@supakeen
supakeen added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
@supakeen
supakeen added this pull request to the merge queue Oct 28, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 28, 2026
@supakeen
supakeen added this pull request to the merge queue Oct 28, 2026
Merged via the queue into osbuild:main with commit 6a8937f Oct 28, 2026
51 of 55 checks passed
@achilleas-k
achilleas-k deleted the cmd/fetch-sources branch October 28, 2026 12:38
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