-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using pkg/bindings
Go API should not require native dependencies to be installed
#12548
Comments
We build the remote client with these golang build tags, which should remove most of the heinous stuff you are seeing. REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp Sure we would love to get rid of these bindings leakage, but it is fairly difficult to do, and we have not recently had the engineering time to look into it. |
Thanks @rhatdan for providing a work-around, that's greatly appreciated. I'll give that a go in tomorrow's working hours and see if that resolves the issue <3 Does it seem reasonable to you to keep this ticket open long term to track this until the root issue is resolved ? |
I can confirm that applying these build flags resolves the need to install the native dependencies. It feels like it could be potentially helpful to others to include these instructions in the documentation regarding the API client. |
Interested in opening a PR to fix the documentation? |
BTW Which bindings are you using. If you game me a simple go program that used the bindings I could take a look at where it is pulling in containers/storage and try to fix it. |
If you are referring to the comment I made, and then deleted. I resolved that issue, that was just the ol race detector/macos monterey bug (golang/go#49138). If you are referring generally, we are using most of the bindings available in
I'd be happy to do so. I'm technically on leave for Christmas now but I'll have some spare time to whip something up this weekend. |
A friendly reminder that this issue had no activity for 30 days. |
@strideynet are you going to open a PR? BTW Do you have a simple reproducer of the error you were hitting? |
A friendly reminder that this issue had no activity for 30 days. |
@baude after 4.0 we should take another look at this. |
A friendly reminder that this issue had no activity for 30 days. |
A friendly reminder that this issue had no activity for 30 days. |
Which bindings were you using that pulled in this requirement? |
I removed libbtrfs-devel package and can not get this to fail the build. |
A friendly reminder that this issue had no activity for 30 days. |
Working to fix containers#12548 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Hi @rhatdan I ran in to this on both Fedora and Ubuntu with Podman API v3.2.1 and v4.1.1.
package main
import (
"context"
"fmt"
"os"
"github.com/containers/podman/v4/pkg/bindings"
"github.com/containers/podman/v4/pkg/bindings/system"
)
func main() {
fmt.Println("Welcome to the Podman Go bindings tutorial")
// Get Podman socket location
sock_dir := os.Getenv("XDG_RUNTIME_DIR")
if sock_dir == "" {
sock_dir = "/tmp"
}
socket := "unix:" + sock_dir + "/podman/podman.sock"
// Connect to Podman socket
ctx, err := bindings.NewConnection(context.Background(), socket)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(ctx)
// Calling this function dramatically increases the dependencies and build complexity
info, err := system.Info(ctx, &system.InfoOptions{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Print(info)
} As @strideynet mentioned above, it looks like this has to do with crossing boundaries to access structures. All that being said, I did get it working in a container with the build flags you recommended! go build -tags exclude_graphdriver_btrfs,btrfs_noversion,exclude_graphdriver_devicemapper,containers_image_openpgp main.go |
Thanks for bringing that up, @byarbrough. It is definitely our goal to trim the (transitive) dependencies of pkg/bindings down as much as possible. |
Using libpod/define is fine and expected, maintaining the same types twice is will cause more work and problems. The correct way to fix this is to move all required types into separate packages without extra code. The main works seems to be in c/storage and c/image c/buildah and not podman itself. However those libraries are stable so they must keep backwards compat. Keep that in mind when working on it. |
My few cents. Today, I tried to use the Go binding with Podman. My docker image was bloated to 1GB due to Podman Go dependencies. I couldn't build my app in a separate Stage because podman bindings are linked statically to a system dependency. For now, I have to work with the podman binary directly. |
@StarpTech 1 GB sounds way too much. The vendor directory of Podman is around 50MB and compiled Podman is at around 40 MB. Did you clean up all build artifacts from your container image? |
What do you mean specifically? Basically, I did.
I gave up after that but I can recheck it. |
A friendly reminder that this issue had no activity for 30 days. |
Closes: containers#12548 [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
I am not sure what is the threshold to consider this fixed, since we can continue trimming dependencies and reduce the binary size. I've opened a PR to move some definitions around so we drag less stuff in the bindings: #21364 I also suggest using the Using the same example as in the #12548 (comment): Using podman main:
Using the tag
Using the tag
|
Closes: containers#12548 [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: containers#12548 [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Closes: containers#12548 [NO NEW TESTS NEEDED] Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Nice shrinkage. |
Instead of spawning a new process to run the podman CLI, this uses the podman bindings library to interact with podman via HTTP calls. There are a lot of dependencies added due to how the podman library is structured. See containers/podman#12548
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
As it stands, building an application that uses Podman via the HTTP API client (
pkg/bindings
) requires native dependencies (e.glibbtrfs
,libgpgme
etc) to be available on the machine. This provides a poor developer experience, especially to those on operating systems other than Linux where they may struggle to source the dependencies, and makes building applications that use this API much more difficult (these dependencies must also be installed as part of CI pipelines etc). As an engineer, I am unable to understand why I need these dependencies to leverage this API client, as they don't seem reasonable dependencies for an API client that makes HTTP requests (e.glibbtrfs
).We should explore options that would mean it's possible to use this API without the installation of those native dependencies. As far as I can tell, this is caused by the bindings packages relying on types defined in other packages where those dependencies are required as part of the runtime. If these types were extracted, or copied, and placed in separate packages, it should be possible to build applications using the Podman API Client without installing those native dependencies.
Many thanks,
The text was updated successfully, but these errors were encountered: