containers / podman

Podman: A tool for managing OCI containers and pods.
https://podman.io
Apache License 2.0
22.36k stars 2.31k forks source link

[Quadlet] [Rootless] stop network not working #23124

Closed podhorsky-ksj closed 3 days ago

podhorsky-ksj commented 3 days ago

Issue Description

I'm fighting with network between containers. I cannot use pod, because I need to use different userns for every container (to have data in host with same uid as in container), which is impossible in pod.

I have found an issue with network quadlet. I have quadlet file sonarqube.network

[Unit]
Description=sonarqube

[Network]
NetworkName=sonarqube
Driver=ipvlan
Subnet=10.127.0.0/8
Internal=true
Gateway=10.127.0.1

[Install]
WantedBy=default.target

I started it with systemctl --user start sonarqube-network systemctl --user stop sonarqube-network is ignored, also daemon-reload. I had to remove the network with podman network rm.

Steps to reproduce the issue

  1. create network quadlet file rootless
  2. start it
  3. stop is not working,

Describe the results you received

network must be removed with podman network rm.

Describe the results you expected

all quadlet files should work the same way, but network does not.

podman info output

host:
  arch: amd64
  buildahVersion: 1.36.0
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: /usr/bin/conmon is owned by conmon 1:2.1.12-1
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: e8896631295ccb0bfdda4284f1751be19b483264'
  cpuUtilization:
    idlePercent: 95.89
    systemPercent: 1.11
    userPercent: 3
  cpus: 4
  databaseBackend: sqlite
  distribution:
    distribution: arch
    version: unknown
  eventLogger: journald
  freeLocks: 2046
  hostname: server-ksj
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 964
      size: 1
    - container_id: 1
      host_id: 10000
      size: 55537
    uidmap:
    - container_id: 0
      host_id: 964
      size: 1
    - container_id: 1
      host_id: 10000
      size: 55537
  kernel: 6.9.6-arch1-1
  linkmode: dynamic
  logDriver: journald
  memFree: 225394688
  memTotal: 8236285952
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: /usr/lib/podman/aardvark-dns is owned by aardvark-dns 1.11.0-1
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.11.0
    package: /usr/lib/podman/netavark is owned by netavark 1.11.0-2
    path: /usr/lib/podman/netavark
    version: netavark 1.11.0
  ociRuntime:
    name: crun
    package: /usr/bin/crun is owned by crun 1.15-1
    path: /usr/bin/crun
    version: |-
      crun version 1.15
      commit: e6eacaf4034e84185fd8780ac9262bbf57082278
      rundir: /run/user/964/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: /usr/bin/pasta is owned by passt 2024_06_07.8a83b53-1
    version: |
      pasta 2024_06_07.8a83b53
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.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:
    exists: true
    path: /run/user/964/podman/podman.sock
  rootlessNetworkCmd: pasta
  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: /etc/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: /usr/bin/slirp4netns is owned by slirp4netns 1.3.1-1
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 5
      libseccomp: 2.5.5
  swapFree: 4073979904
  swapTotal: 4294963200
  uptime: 42h 45m 13.00s (Approximately 1.75 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  docker.io:
    Blocked: false
    Insecure: true
    Location: docker.io
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: docker.io
    PullFromMirror: ""
  ghcr.io:
    Blocked: false
    Insecure: true
    Location: ghcr.io
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: ghcr.io
    PullFromMirror: ""
  registry.access.redhat.com:
    Blocked: false
    Insecure: true
    Location: registry.access.redhat.com
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: registry.access.redhat.com
    PullFromMirror: ""
  registry.redhat.io:
    Blocked: false
    Insecure: true
    Location: registry.redhat.io
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: registry.redhat.io
    PullFromMirror: ""
store:
  configFile: /home/sonarqube/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 2
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/sonarqube/.local/share/containers/storage
  graphRootAllocated: 240056360960
  graphRootUsed: 62659899392
  graphStatus:
    Backing Filesystem: btrfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 3
  runRoot: /run/user/964/containers
  transientStore: false
  volumePath: /home/sonarqube/.local/share/containers/storage/volumes
version:
  APIVersion: 5.1.1
  Built: 1717539130
  BuiltTime: Wed Jun  5 00:12:10 2024
  GitCommit: bda6eb03dcbcf12a5b7ae004c1240e38dd056d24-dirty
  GoVersion: go1.22.3
  Os: linux
  OsArch: linux/amd64
  Version: 5.1.1

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

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

Luap99 commented 3 days ago

You cannot remove a network while it used and as there is no process attached it would be impossible to set up dependencies so that the unit would be stopped automatically after all referring containers units are stopped. As such we decided to just leak the networks. I think volume work in the same way.

https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#network-units-network

Please note that stopping the corresponding service will not remove the podman network. In addition, updating an existing network is not supported. In order to update the network parameters you will first need to manually remove the podman network and then restart the service.