Skip to content

Conversation

Honny1
Copy link
Member

@Honny1 Honny1 commented Sep 12, 2025

Adds /libpod/local/build endpoint, client bindings, and path translation utilities to enable container builds from mounted directories to podman machine without tar uploads.

This optimization significantly speeds up build operations when working with remote Podman machines by eliminating redundant file transfers for already-accessible files.

This feature is non-functional on Windows when using the Hyper-V provider. The issue stems from the 9p filesystem protocol, which fails to correctly translate file attributes between the host and the virtual machine. This incompatibility causes certain container build operations to fail. As a result, this functionality has been disabled for Windows environments that utilize Hyper-V.

Fixes: https://issues.redhat.com/browse/RUN-3249
Fixes Build part of #26321

Benchmark

  • Command: podman build -t test ./test-context
  • Context Dir content:
$ du -a -h | sort -hr
 10G	.
1.0G	./random-9
1.0G	./random-8
1.0G	./random-7
1.0G	./random-6
1.0G	./random-5
1.0G	./random-4
1.0G	./random-3
1.0G	./random-2
1.0G	./random-10
1.0G	./random-1
4.0K	./Dockerfile
  • Dockerfile:
$ cat Dockerfile
FROM scratch
COPY random-1 random-1
COPY random-10 random-10

Benchmark Results:

Mac OS

  • Number of runs: 5
  • Machine:
    • Chip: Apple M3 Pro
    • RAM: 36 GB
    • SSD: 1 TB Apple SSD
  • Podman machine configuration:
    • CPUs: 4
    • Memory: 5.1 GB

Providers

applehv
  • Before: 67.84 s
  • After: 9.99 s
libkrun
  • Before: 70.18 s
  • After: 12.62 s

Windows

  • Number of runs: 5
  • Machine:
    • CPU: Intel Core i7-8665U
    • RAM: 32 GB
    • SSD: 500 GB Samsung 970 Evo Plus
  • Podman machine configuration:
    • CPUs: 8
    • Memory: 2048 MB

Providers

WSL
  • Before: 116.1 s
  • After: 53.86 s
Hyper-V
  • DNF

Does this PR introduce a user-facing change?

Added /libpod/local/build endpoint and client bindings to enable direct filesystem builds on macOS and Windows (WSL) without tar uploads, significantly speeding up build operations when working with remote Podman machines. This optimization eliminates redundant file transfers for already-accessible mounted directories.

Updated machine port discovery to iterate through all available machine providers instead of checking only a single provider. This change improves machine detection reliability across different provider configurations.

@openshift-ci openshift-ci bot added release-note do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Sep 12, 2025
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Sep 12, 2025
Copy link

[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore.

@Honny1 Honny1 force-pushed the build-local-api branch 4 times, most recently from cf65a4c to 25cc198 Compare September 19, 2025 12:01
@Honny1 Honny1 force-pushed the build-local-api branch 4 times, most recently from f4c1c04 to f19d0f3 Compare September 22, 2025 16:37
@Honny1 Honny1 marked this pull request as ready for review September 23, 2025 13:53
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 23, 2025
@baude
Copy link
Member

baude commented Sep 25, 2025

code LGTM ... if you get asked to fix things by others, adding a little commentary inside some of those functions might help the next person. again only if you have to repush and have time.

result[path] = mapping.RemotePath
}

logrus.Debugf("Translation map: %#v\n", result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need this ? This message has no context. Translation Map for what.

Comment on lines 161 to 171
func validateLocalPath(path string) error {
if !filepath.IsAbs(path) {
return fmt.Errorf("path %q is not absolute", path)
}

if err := fileutils.Exists(path); err != nil {
return err
}
return nil
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we have this function elsewhere as well, could we do a quick search before adding this again ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't find a similar function, but I moved it to the local API to be provided to others in the future.

return nil, utils.GetInternalServerError(fmt.Errorf("additionalbuildcontexts must be in name=value format: %q", url))
}

logrus.Debugf("name: %q, context: %q", name, value)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This message needs more context

if isStdIn {
stdinFile, err := tempManager.CreateTempFileFromReader(contextDir, "podman-build-stdin-*", os.Stdin)
if err != nil {
return nil, fmt.Errorf("processing stdin: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("processing stdin: %w", err)
return nil, fmt.Errorf("processing containerfile from stdin: %w", err)

@Honny1
Copy link
Member Author

Honny1 commented Oct 2, 2025

@baude, @flouthoc, I addressed your comments.

@Honny1 Honny1 requested a review from flouthoc October 2, 2025 16:00
@Honny1
Copy link
Member Author

Honny1 commented Oct 6, 2025

PTAL @Luap99 @mheon

}

for _, c := range containerFiles {
// Don not add path to containerfile if it is a URL
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Don not add path to containerfile if it is a URL
// Do not add path to containerfile if it is a URL

Nit

remoteContainerfile, ok = translationLocalAPIMap[containerfile]
if !ok {
if !isInContextDir {
return nil, fmt.Errorf("containerfile %q not found in translation map", containerfile)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return nil, fmt.Errorf("containerfile %q not found in translation map", containerfile)
return nil, fmt.Errorf("Containerfile %q not found in translation map", containerfile)

I'll just add this one and it's a nit, but a big nit. Customer facing verbaiage should list this with a capital C. I'll just comment here, but there are other intances.

@TomSweeneyRedHat
Copy link
Member

LGTM
in general. A few nitty things that could be cleaned up later if needed.

Honny1 added 2 commits October 8, 2025 10:19
… (only WSL)

Adds /libpod/local/build endpoint, client bindings, and path translation
utilities to enable container builds from mounted directories to podman machine without tar uploads.

This optimization significantly speeds up build operations when working with remote Podman machines by eliminating redundant file transfers for already-accessible files.

Fixes: https://issues.redhat.com/browse/RUN-3249

Signed-off-by: Jan Rodák <[email protected]>
Replace single provider.Get() with provider.GetAll() loop to search
across all available machine providers when finding machine by port.

Signed-off-by: Jan Rodák <[email protected]>
@Honny1
Copy link
Member Author

Honny1 commented Oct 8, 2025

I fixed the nits and rebased on the latest main.

@TomSweeneyRedHat
Copy link
Member

LGTM
Tests look to be flaking, I restarted.

Copy link
Collaborator

@flouthoc flouthoc left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented Oct 8, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: flouthoc, Honny1
Once this PR has been reviewed and has the lgtm label, please assign luap99 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TomSweeneyRedHat
Copy link
Member

Happy Green test buttons!

@baude baude added the 5.7 label Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.7 kind/api-change Change to remote API; merits scrutiny release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants