PEASEC / podtender

Rust library for managing Podman
Apache License 2.0
6 stars 2 forks source link

Error inspecting container #1

Open sigaloid opened 1 year ago

sigaloid commented 1 year ago

Err(SerdeJsonErrorWithPath(Error { path: Path { segments: [Map { key: "NetworkSettings" }, Map { key: "Ports" }, Map { key: "8080/tcp" }, Seq { index: 0 }] }, original: Error("invalid type: map, expected a string", line: 1, column: 3813) }))

Output of curl command:

mattop@fedora ~> curl -G --unix-socket /home/(whoami)/podman.sock http://d/v4.0.0/libpod/containers/libreddit/json | jq
{
  "Id": "ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5",
  "Created": "2023-01-19T20:04:13.726971512-05:00",
  "Path": "libreddit",
  "Args": [
    "libreddit"
  ],
  "State": {
    "OciVersion": "1.0.2-dev",
    "Status": "running",
    "Running": true,
    "Paused": false,
    "Restarting": false,
    "OOMKilled": false,
    "Dead": false,
    "Pid": 247003,
    "ConmonPid": 247001,
    "ExitCode": 0,
    "Error": "",
    "StartedAt": "2023-01-19T20:04:13.976985849-05:00",
    "FinishedAt": "0001-01-01T00:00:00Z",
    "Health": {
      "Status": "",
      "FailingStreak": 0,
      "Log": null
    },
    "CgroupPath": "/user.slice/user-1000.slice/user@1000.service/user.slice/libpod-ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5.scope",
    "CheckpointedAt": "0001-01-01T00:00:00Z",
    "RestoredAt": "0001-01-01T00:00:00Z"
  },
  "Image": "6cd2fba796bdea5affa925d87dabe04ba9ba2f15e1b4f992833e58c101b8bb23",
  "ImageDigest": "sha256:f18b945652e8ebf6907a67110fa46c2e5a1e034675572174099d43dc9438a1de",
  "ImageName": "docker.io/libreddit/libreddit:latest",
  "Rootfs": "",
  "Pod": "",
  "ResolvConfPath": "/run/user/1000/containers/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/resolv.conf",
  "HostnamePath": "/run/user/1000/containers/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/hostname",
  "HostsPath": "/run/user/1000/containers/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/hosts",
  "StaticDir": "/home/mattop/.local/share/containers/storage/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata",
  "OCIConfigPath": "/home/mattop/.local/share/containers/storage/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/config.json",
  "OCIRuntime": "crun",
  "ConmonPidFile": "/run/user/1000/containers/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/conmon.pid",
  "PidFile": "/run/user/1000/containers/overlay-containers/ff1ec1a03953d46c82df3e38acf42aaa274b239b7dbb1bce64a9ffd8756711a5/userdata/pidfile",
  "Name": "libreddit",
  "RestartCount": 0,
  "Driver": "overlay",
  "MountLabel": "system_u:object_r:container_file_t:s0:c319,c907",
  "ProcessLabel": "system_u:system_r:container_t:s0:c319,c907",
  "AppArmorProfile": "",
  "EffectiveCaps": null,
  "BoundingCaps": [
    "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"
  ],
  "ExecIDs": [],
  "GraphDriver": {
    "Name": "overlay",
    "Data": {
      "LowerDir": "/home/mattop/.local/share/containers/storage/overlay/38d3b47e4bd4c3b5460a1a3b08d9a6dd9f9cac10c10a4834ae30fa8dab452b58/diff:/home/mattop/.local/share/containers/storage/overlay/b271078fec8771a45488c189f4df02f139c1cbb144077ea81d90684365f121ba/diff:/home/mattop/.local/share/containers/storage/overlay/3b2983badea405c79dd61b53a11c19d2be3532539b30a7453ab56bb45f968f95/diff:/home/mattop/.local/share/containers/storage/overlay/c4854dee0552f3fd1b7255bab8c250b1425fdd8193668fd8c94361c0788756cc/diff:/home/mattop/.local/share/containers/storage/overlay/8e012198eea15b2554b07014081c85fec4967a1b9cc4b65bd9a4bce3ae1c0c88/diff",
      "MergedDir": "/home/mattop/.local/share/containers/storage/overlay/159b7ed4092c19319ba1e3f3a21c469583fae893e9c8bd1b2d578cb99d04f7b9/merged",
      "UpperDir": "/home/mattop/.local/share/containers/storage/overlay/159b7ed4092c19319ba1e3f3a21c469583fae893e9c8bd1b2d578cb99d04f7b9/diff",
      "WorkDir": "/home/mattop/.local/share/containers/storage/overlay/159b7ed4092c19319ba1e3f3a21c469583fae893e9c8bd1b2d578cb99d04f7b9/work"
    }
  },
  "Mounts": [],
  "Dependencies": [],
  "NetworkSettings": {
    "EndpointID": "",
    "Gateway": "",
    "IPAddress": "",
    "IPPrefixLen": 0,
    "IPv6Gateway": "",
    "GlobalIPv6Address": "",
    "GlobalIPv6PrefixLen": 0,
    "MacAddress": "",
    "Bridge": "",
    "SandboxID": "",
    "HairpinMode": false,
    "LinkLocalIPv6Address": "",
    "LinkLocalIPv6PrefixLen": 0,
    "Ports": {
      "8080/tcp": [
        {
          "HostIp": "",
          "HostPort": "8080"
        }
      ]
    },
    "SandboxKey": "/run/user/1000/netns/netns-e6f680bd-dd60-f17b-e82f-27256e1121d8"
  },
  "Namespace": "",
  "IsInfra": false,
  "IsService": false,
  "Config": {
    "Hostname": "ff1ec1a03953",
    "Domainname": "",
    "User": "libreddit",
    "AttachStdin": false,
    "AttachStdout": false,
    "AttachStderr": false,
    "Tty": false,
    "OpenStdin": false,
    "StdinOnce": false,
    "Env": [
      "TERM=xterm",
      "container=podman",
      "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
      "HOME=/nonexistent",
      "HOSTNAME=ff1ec1a03953"
    ],
    "Cmd": [
      "libreddit"
    ],
    "Image": "docker.io/libreddit/libreddit:latest",
    "Volumes": null,
    "WorkingDir": "/",
    "Entrypoint": "",
    "OnBuild": null,
    "Labels": null,
    "Annotations": {
      "io.container.manager": "libpod",
      "io.kubernetes.cri-o.Created": "2023-01-19T20:04:13.726971512-05:00",
      "io.kubernetes.cri-o.TTY": "false",
      "io.podman.annotations.autoremove": "FALSE",
      "io.podman.annotations.init": "FALSE",
      "io.podman.annotations.privileged": "FALSE",
      "io.podman.annotations.publish-all": "FALSE",
      "org.opencontainers.image.stopSignal": "15"
    },
    "StopSignal": 15,
    "HealthcheckOnFailureAction": "none",
    "CreateCommand": [
      "podman",
      "run",
      "-d",
      "--name",
      "libreddit",
      "-p",
      "8080:8080",
      "libreddit/libreddit"
    ],
    "Umask": "0022",
    "Timeout": 0,
    "StopTimeout": 10,
    "Passwd": true,
    "sdNotifyMode": "container"
  },
  "HostConfig": {
    "Binds": [],
    "CgroupManager": "systemd",
    "CgroupMode": "private",
    "ContainerIDFile": "",
    "LogConfig": {
      "Type": "journald",
      "Config": null,
      "Path": "",
      "Tag": "",
      "Size": "0B"
    },
    "NetworkMode": "slirp4netns",
    "PortBindings": {
      "8080/tcp": [
        {
          "HostIp": "",
          "HostPort": "8080"
        }
      ]
    },
    "RestartPolicy": {
      "Name": "",
      "MaximumRetryCount": 0
    },
    "AutoRemove": false,
    "VolumeDriver": "",
    "VolumesFrom": null,
    "CapAdd": [],
    "CapDrop": [
      "CAP_AUDIT_WRITE",
      "CAP_MKNOD",
      "CAP_NET_RAW"
    ],
    "Dns": [],
    "DnsOptions": [],
    "DnsSearch": [],
    "ExtraHosts": [],
    "GroupAdd": [],
    "IpcMode": "shareable",
    "Cgroup": "",
    "Cgroups": "default",
    "Links": null,
    "OomScoreAdj": 0,
    "PidMode": "private",
    "Privileged": false,
    "PublishAllPorts": false,
    "ReadonlyRootfs": false,
    "SecurityOpt": [],
    "Tmpfs": {},
    "UTSMode": "private",
    "UsernsMode": "",
    "ShmSize": 65536000,
    "Runtime": "oci",
    "ConsoleSize": [
      0,
      0
    ],
    "Isolation": "",
    "CpuShares": 0,
    "Memory": 0,
    "NanoCpus": 0,
    "CgroupParent": "user.slice",
    "BlkioWeight": 0,
    "BlkioWeightDevice": null,
    "BlkioDeviceReadBps": null,
    "BlkioDeviceWriteBps": null,
    "BlkioDeviceReadIOps": null,
    "BlkioDeviceWriteIOps": null,
    "CpuPeriod": 0,
    "CpuQuota": 0,
    "CpuRealtimePeriod": 0,
    "CpuRealtimeRuntime": 0,
    "CpusetCpus": "",
    "CpusetMems": "",
    "Devices": [],
    "DiskQuota": 0,
    "KernelMemory": 0,
    "MemoryReservation": 0,
    "MemorySwap": 0,
    "MemorySwappiness": 0,
    "OomKillDisable": false,
    "PidsLimit": 2048,
    "Ulimits": [],
    "CpuCount": 0,
    "CpuPercent": 0,
    "IOMaximumIOps": 0,
    "IOMaximumBandwidth": 0,
    "CgroupConf": null
  }
}

Looks related to this: https://github.com/PEASEC/podtender/blob/main/src/containers/response_types.rs#L519-L520.

image Seems like it's not reading the HostIp and HostPort properties.

Reproducible on main as well. Happy to test any patches!

podman version 4.3.1
Fedora 37 
Linux 6.1.6-200.fc37.x86_64

PS: I hope this is not related to the 4.4.x minimum version - it's only been a week or so since the first beta RC of 4.4.0. I also attempted switching to =0.3.0 of this crate but got a different error (probably expected as it's out of date). But if this is specifically an issue of me not running the prerelease of podman, then let me know (I'm unable to switch over to it currently to test).

arctic-alpaca commented 1 year ago

Sorry for the late reply.

Podman 4.3.x was not supported because of this issue with the API: https://github.com/containers/podman/issues/16497 This might be the error you got with =0.3.0.

0.4.x will only support podman 4.4.x. With the release, is it possible for you to update podman?