Skip to content
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

Go bindings - v4 specgen requires v5 image - inferrence error #19772

Closed
kisamoto opened this issue Aug 28, 2023 · 12 comments
Closed

Go bindings - v4 specgen requires v5 image - inferrence error #19772

kisamoto opened this issue Aug 28, 2023 · 12 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@kisamoto
Copy link

Issue Description

Using the v4 podman bindings in a basic example and trying to pull an image and start a container. When calling go run, getting a build error related to v5 containers/image.

$ go run ./main.go
go build github.com/proglottis/gpgme:
# pkg-config --cflags  -- gpgme
Package gpgme was not found in the pkg-config search path.
Perhaps you should add the directory containing `gpgme.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gpgme' found
pkg-config: exit status 1
# github.com/containers/image/v5/internal/manifest
/.gvm/pkgsets/go1.21/global/pkg/mod/github.com/containers/image/v5@v5.26.1/internal/manifest/oci_index.go:154:42: type func(a v1.Descriptor, b v1.Descriptor) bool of func(a, b imgspecv1.Descriptor) bool {…} does not match inferred type func(a v1.Descriptor, b v1.Descriptor) int for func(a E, b E) int
go build github.com/containers/storage/pkg/devicemapper:
# pkg-config --cflags  -- devmapper
Package devmapper was not found in the pkg-config search path.
Perhaps you should add the directory containing `devmapper.pc'
to the PKG_CONFIG_PATH environment variable
No package 'devmapper' found
pkg-config: exit status 1
$ go mod why -m github.com/containers/image/v5
# github.com/containers/image/v5
github.com/kisamoto/container-test/podman
github.com/containers/podman/v4/pkg/specgen
github.com/containers/image/v5/manifest

Steps to reproduce the issue

Steps to reproduce the issue

  1. Import and use "github.com/containers/podman/v4/pkg/specgen"
  2. go mod tidy and go run
  3. Receive error: /.gvm/pkgsets/go1.21/global/pkg/mod/github.com/containers/image/v5@v5.26.1/internal/manifest/oci_index.go:154:42: type func(a v1.Descriptor, b v1.Descriptor) bool of func(a, b imgspecv1.Descriptor) bool {…} does not match inferred type func(a v1.Descriptor, b v1.Descriptor) int for func(a E, b E) int

Describe the results you received

When running, receiving:

/.gvm/pkgsets/go1.21/global/pkg/mod/github.com/containers/image/v5@v5.26.1/internal/manifest/oci_index.go:154:42: type func(a v1.Descriptor, b v1.Descriptor) bool of func(a, b imgspecv1.Descriptor) bool {…} does not match inferred type func(a v1.Descriptor, b v1.Descriptor) int for func(a E, b E) int

Describe the results you expected

Successful build and run of application with podman bindings

podman info output

host:
  arch: amd64
  buildahVersion: 1.31.2
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.7-2.fc38.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.7, commit: '
  cpuUtilization:
    idlePercent: 57.24
    systemPercent: 3.2
    userPercent: 39.55
  cpus: 16
  databaseBackend: boltdb
  distribution:
    distribution: fedora
    variant: workstation
    version: "38"
  eventLogger: journald
  freeLocks: 2031
  hostname: workhorse
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.3.8-200.fc38.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 3535065088
  memTotal: 67326689280
  networkBackend: cni
  networkBackendInfo:
    backend: cni
    dns: {}
  ociRuntime:
    name: crun
    package: crun-1.8.7-1.fc38.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.8.7
      commit: 53a9996ce82d1ee818349bdcc64797a1fa0433c4
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20230823.ga7e4bfb-1.fc38.x86_64
    version: |
      pasta 0^20230823.ga7e4bfb-1.fc38.x86_64
      Copyright Red Hat
      GNU Affero GPL version 3 or later <https://www.gnu.org/licenses/agpl-3.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.1-1.fc38.x86_64
    version: |-
      slirp4netns version 1.2.1
      commit: 09e31e92fa3d2a1d3ca261adaeb012c8d75a8194
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 8589131776
  swapTotal: 8589930496
  uptime: 51h 4m 26.00s (Approximately 2.12 days)
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
  - quay.io
store:
  configFile: /home/kisamoto/.config/containers/storage.conf
  containerStore:
    number: 10
    paused: 0
    running: 0
    stopped: 10
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/kisamoto/.local/share/containers/storage
  graphRootAllocated: 1743887249408
  graphRootUsed: 877706051584
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 16
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/kisamoto/.local/share/containers/storage/volumes
version:
  APIVersion: 4.6.1
  Built: 1691705273
  BuiltTime: Fri Aug 11 00:07:53 2023
  GitCommit: ""
  GoVersion: go1.20.7
  Os: linux
  OsArch: linux/amd64
  Version: 4.6.1

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

No

Additional environment details

Additional environment details

Additional information

Additional information like issue happens only occasionally or issue happens with a particular architecture or on a particular setting

@kisamoto kisamoto added the kind/bug Categorizes issue or PR as related to a bug. label Aug 28, 2023
@vrothberg
Copy link
Member

Thanks for reaching out, @kisamoto.

/.gvm/pkgsets/go1.21/global/pkg/mod/github.com/containers/image/v5@v5.26.1/internal/manifest/oci_index.go:154:42: type func(a v1.Descriptor, b v1.Descriptor) bool of func(a, b imgspecv1.Descriptor) bool {…} does not match inferred type func(a v1.Descriptor, b v1.Descriptor) int for func(a E, b E) int

Which versions of Podman and c/image are using exactly? Can you share your go.mod?

@kisamoto
Copy link
Author

module github.com/kisamoto/container-test

go 1.21.0

require (
	github.com/containers/podman/v4 v4.6.1
)

require (
	github.com/containers/image/v5 v5.26.1 // indirect
)

@vrothberg
Copy link
Member

@kisamoto, can you upload github.com/kisamoto/container-test so I can take a look at the code?

@kisamoto
Copy link
Author

Sure :) https://github.com/kisamoto/conatiner-test

Thanks for your help!

@vrothberg
Copy link
Member

Thanks. It builds just fine in my environment, so the problem sees to be that containers/image and other dependencies leak into pkg/bindings. So you can either install the required build dependencies (devmapper, etc) or use build tag for building the project.

Can you try building with -tags "containers_image_openpgp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_graphdriver_overlay"?

@mtrmac
Copy link
Collaborator

mtrmac commented Aug 28, 2023

Compare containers/image#2066; this is almost certainly a wrong version of golang.org/x/exp. I didn’t now look into whether it’s a too old or a too new version, and I’m surprised that the dependencies as expressed in the various projects result in broken code; I’d expect Podman’s CI to catch that.

@kisamoto
Copy link
Author

@vrothberg thanks to the pointer from @mtrmac I have identified the problem.

I initially encountered this in a separate project and used the kisamoto/container-test to isolate it. Somehow the golang.org/x/exp version was conflicting.

If I specifically require golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 in the go.mod (as specified in containers/image@v5.26 then I no longer have this issue.

However if I require golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 (which was added by go mod tidy in the previous project) then I receive the "does not match inferred type" error listed before.

I think (although you can have final say) that this specific issue can be closed, however it may be worthwhile opening an additional issue to track if this error occurs in the future with newer versions of golang.org/x/exp.

Thanks for both of your help tracking this down!

@mtrmac
Copy link
Collaborator

mtrmac commented Aug 29, 2023

Short-term it would probably be easiest to update c/image to include the commit that has updated for that API break, see the c/image links above for the link cluster.

@kisamoto
Copy link
Author

So remove the indirect dependency in go.mod and replace with github.com/containers/image/v5 v5.27.0?

Are there any risks of incompatibility between this and other containers packages?

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@mtrmac
Copy link
Collaborator

mtrmac commented Oct 2, 2023

Generally c/image tries pretty hard not to break the API within the v5 major version; but the fairly extensive Podman test suite only runs with the c/image versions Podman actually uses, so it’s not quite 100% risk-free.

@Luap99
Copy link
Member

Luap99 commented Nov 28, 2023

I think this can be closed as it should build with newer versions.
In general if you build bindings it make sense to use our remote tags to exclude a bunch of system libs.

REMOTETAGS ?= remote exclude_graphdriver_btrfs btrfs_noversion exclude_graphdriver_devicemapper containers_image_openpgp

@Luap99 Luap99 closed this as completed Nov 28, 2023
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Feb 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

No branches or pull requests

4 participants