puppetlabs-docker icon indicating copy to clipboard operation
puppetlabs-docker copied to clipboard

Fact docker fail when podman is installed to emulate docker

Open Ah-Puch opened this issue 1 year ago • 2 comments

Describe the Bug

We have a RHEL 9.4 server with podman installed as replacement for Docker. Podman installs a docker command to emulate docker using podman. Running puppet give us error for the fact docker

Error: Facter: Error while resolving custom fact fact='docker', resolution='': undefined method `[]' for nil:NilClass

Expected Behavior

Not to fail and produce expected fact parts.

Steps to Reproduce

Steps to reproduce the behavior:

  1. Install puppetlabs-docker 9.1.0 in puppet Environment
  2. Install podman
  3. run puppet agent -t or try to get fact

Environment

  • Version 9.1.0
  • Platform Red Hat Enterprise Linux 9.4 (Plow)
  • more details in additional context

Additional Context

Version enligt r10k

mod 'puppetlabs-docker', '9.1.0'

[root@demo ~]# docker info --format '{{json .}}' Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg. {"host":{"arch":"amd64","buildahVersion":"1.33.7","cgroupManager":"systemd","cgroupVersion":"v2","cgroupControllers":["cpuset","cpu","io","memory","hugetlb","pids","rdma","misc"],"conmon":{"package":"conmon-2.1.10-1.el9.x86_64","path":"/usr/bin/conmon","version":"conmon version 2.1.10, commit: fb8c4bf50dbc044a338137871b096eea8041a1fa"},"cpus":4,"cpuUtilization":{"userPercent":1.88,"systemPercent":0.57,"idlePercent":97.55},"databaseBackend":"sqlite","distribution":{"distribution":"rhel","version":"9.4"},"eventLogger":"journald","freeLocks":2048,"hostname":"ida-app.it.liu.se","idMappings":{"gidmap":null,"uidmap":null},"kernel":"5.14.0-427.22.1.el9_4.x86_64","logDriver":"journald","memFree":1202237440,"memTotal":8057892864,"networkBackend":"netavark","networkBackendInfo":{"backend":"netavark","version":"netavark 1.10.3","package":"netavark-1.10.3-1.el9.x86_64","path":"/usr/libexec/podman/netavark","dns":{"version":"aardvark-dns 1.10.0","package":"aardvark-dns-1.10.0-3.el9_4.x86_64","path":"/usr/libexec/podman/aardvark-dns"}},"ociRuntime":{"name":"crun","package":"crun-1.14.3-1.el9.x86_64","path":"/usr/bin/crun","version":"crun version 1.14.3\ncommit: 1961d211ba98f532ea52d2e80f4c20359f241a98\nrundir: /run/crun\nspec: 1.0.0\n+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL"},"os":"linux","remoteSocket":{"path":"/run/podman/podman.sock","exists":false},"serviceIsRemote":false,"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":false,"seccompEnabled":true,"seccompProfilePath":"/usr/share/containers/seccomp.json","selinuxEnabled":false},"slirp4netns":{"executable":"/usr/bin/slirp4netns","package":"slirp4netns-1.2.3-1.el9.x86_64","version":"slirp4netns version 1.2.3\ncommit: c22fde291bb35b354e6ca44d13be181c76a0a432\nlibslirp: 4.4.0\nSLIRP_CONFIG_VERSION_MAX: 3\nlibseccomp: 2.5.2"},"pasta":{"executable":"","package":"","version":""},"swapFree":6862602240,"swapTotal":6872363008,"uptime":"143h 54m 23.00s (Approximately 5.96 days)","variant":"","linkmode":"dynamic"},"store":{"configFile":"/etc/containers/storage.conf","containerStore":{"number":0,"paused":0,"running":0,"stopped":0},"graphDriverName":"overlay","graphOptions":{"overlay.mountopt":"nodev,metacopy=on"},"graphRoot":"/var/lib/containers/storage","graphRootAllocated":60343398400,"graphRootUsed":15093481472,"graphStatus":{"Backing Filesystem":"extfs","Native Overlay Diff":"false","Supports d_type":"true","Supports shifting":"false","Supports volatile":"true","Using metacopy":"true"},"imageCopyTmpDir":"/var/tmp","imageStore":{"number":0},"runRoot":"/run/containers/storage","volumePath":"/var/lib/containers/storage/volumes","transientStore":false},"registries":{"search":["registry.access.redhat.com","registry.redhat.io","docker.io"]},"plugins":{"volume":["local"],"network":["bridge","macvlan","ipvlan"],"log":["k8s-file","none","passthrough","journald"],"authorization":null},"version":{"APIVersion":"4.9.4-rhel","Version":"4.9.4-rhel","GoVersion":"go1.21.9 (Red Hat 1.21.9-2.el9_4)","GitCommit":"","BuiltTime":"Tue Apr 30 12:46:31 2024","Built":1714473991,"OsArch":"linux/amd64","Os":"linux"}}

Installed docker/podman packages

[root@demo ~]# rpm -qa | egrep -i "docker|podman" podman-remote-4.9.4-4.el9_4.x86_64 python3-podman-4.9.0-1.el9.noarch podman-4.9.4-4.el9_4.x86_64 podman-docker-4.9.4-4.el9_4.noarch cockpit-podman-84.1-1.el9.noarch

[root@demo ~]# lsb_release -a LSB Version: n/a Distributor ID: RedHatEnterprise Description: Red Hat Enterprise Linux 9.4 (Plow) Release: 9.4 Codename: n/a

[root@demo ~]# puppet agent --version 7.31.0

[root@demo ~]# puppet agent -t Info: Using environment 'production' Info: Retrieving pluginfacts Info: Retrieving plugin Info: Loading facts Error: Facter: Error while resolving custom fact fact='docker', resolution='': undefined method `[]' for nil:NilClass

[root@demo ~]# which docker /usr/bin/docker [root@demo ~]# ls -la /usr/bin/docker -rwxr-xr-x 1 root root 167 30 apr 12.48 /usr/bin/docker [root@demo ~]# more /usr/bin/docker #!/usr/bin/sh [ -e /etc/containers/nodocker ] ||
echo "Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg." >&2 exec /usr/bin/podman "$@"

Ah-Puch avatar Jul 01 '24 10:07 Ah-Puch

I am experiencing this issue.

If I install podman-docker to essentially use docker commands a d syntax on the podman binary this error shows, if I remove it then it's goes away.

Technically this may be considered a bug with the podman docker support and not this project but I'm not sure if it's aiming to be 1:1 compatible and I'm sure it's easier to catch the nil variable here.

So after some fiddling, it boils down to the docker networking list using camel case but podman is lower case; this line https://github.com/puppetlabs/puppetlabs-docker/blob/63e09a134c43475d5227544086e3affff466014d/lib/facter/docker.rb#L141 If it is lower case like so:

network_id = docker['network'][network]['id'][0..11]

Works on podman but fails on docker..

adamboutcher avatar Aug 09 '24 18:08 adamboutcher

I am experiencing this issue.

If I install podman-docker to essentially use docker commands a d syntax on the podman binary this error shows, if I remove it then it's goes away.

Technically this may be considered a bug with the podman docker support and not this project but I'm not sure if it's aiming to be 1:1 compatible and I'm sure it's easier to catch the nil variable here.

So after some fiddling, it boils down to the docker networking list using camel case but podman is lower case; this line

https://github.com/puppetlabs/puppetlabs-docker/blob/63e09a134c43475d5227544086e3affff466014d/lib/facter/docker.rb#L141

If it is lower case like so:

network_id = docker['network'][network]['id'][0..11]

Works on podman but fails on docker..

As per the above comment; this code works on both...

          if docker['network'][network]['Id'].nil?
            network_id = docker['network'][network]['id'][0..11]
       	  else
            network_id = docker['network'][network]['Id'][0..11]
       	  end

adamboutcher avatar Sep 04 '24 20:09 adamboutcher