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

Network connect/disconnect events don't include network ID/name #21311

Closed
danegsta opened this issue Jan 19, 2024 · 9 comments · Fixed by #21409
Closed

Network connect/disconnect events don't include network ID/name #21311

danegsta opened this issue Jan 19, 2024 · 9 comments · Fixed by #21409
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. network Networking related issue or feature remote Problem is in podman-remote

Comments

@danegsta
Copy link

Issue Description

Podman network events as emitted by podman events (connect, disconnect) don't include the network name or ID, making it impossible to use events to watch for changes to a specific network. Looking at the source code, the network name is included in the low level event data, but seems to be lost when converting between libpod Events and Docker compatible events via ConvertToEntitiesEvent and ConvertToLibpodEvent.

Steps to reproduce the issue

Steps to reproduce the issue

  1. Run podman events --format json
  2. In another terminal window, connect or disconnect a container to any networks podman network connect <network> <container> or podman network disconenct <network> <container>
  3. Check the contents of the Connect and Disconnect events emitted

Describe the results you received

I see events like this emitted:

{"ID":"3d9d442dab9029e5e1b5d82307972ce3ff9b9f49d0473b4b762f256bdee1f96f","Status":"disconnect","Time":"2024-01-19T13:48:43.873758119-08:00","Type":"network","Attributes":{"podId":""}}
{"ID":"3d9d442dab9029e5e1b5d82307972ce3ff9b9f49d0473b4b762f256bdee1f96f","Status":"connect","Time":"2024-01-19T14:10:31.823991946-08:00","Type":"network","Attributes":{"podId":""}}

Each network event includes the ID of the relevant container, but not the ID or name of the network the container was connected to (or disconnected from).

Describe the results you expected

I expect to see events like:

{"ID":"3d9d442dab9029e5e1b5d82307972ce3ff9b9f49d0473b4b762f256bdee1f96f","Status":"disconnect","Time":"2024-01-19T13:48:43.873758119-08:00","Type":"network","Network":"test","Attributes":{"podId":""}}
{"ID":"3d9d442dab9029e5e1b5d82307972ce3ff9b9f49d0473b4b762f256bdee1f96f","Status":"connect","Time":"2024-01-19T14:10:31.823991946-08:00","Type":"network","Network":"test","Attributes":{"podId":""}}

podman info output

host:
  arch: arm64
  buildahVersion: 1.33.2
  cgroupControllers:
  - cpuset
  - cpu
  - io
  - memory
  - pids
  - rdma
  - misc
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.8-2.fc39.aarch64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.8, commit: '
  cpuUtilization:
    idlePercent: 99.54
    systemPercent: 0.22
    userPercent: 0.24
  cpus: 2
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: coreos
    version: "39"
  eventLogger: journald
  freeLocks: 2045
  hostname: localhost.localdomain
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.6.8-200.fc39.aarch64
  linkmode: dynamic
  logDriver: journald
  memFree: 616837120
  memTotal: 3795222528
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.9.0-1.fc39.aarch64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.9.0
    package: netavark-1.9.0-1.fc39.aarch64
    path: /usr/libexec/podman/netavark
    version: netavark 1.9.0
  ociRuntime:
    name: crun
    package: crun-1.12-1.fc39.aarch64
    path: /usr/bin/crun
    version: |-
      crun version 1.12
      commit: ce429cb2e277d001c2179df1ac66a470f00802ae
      rundir: /run/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^20231204.gb86afe3-1.fc39.aarch64
    version: |
      pasta 0^20231204.gb86afe3-1.fc39.aarch64-pasta
      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/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: true
  serviceIsRemote: true
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.2.2-1.fc39.aarch64
    version: |-
      slirp4netns version 1.2.2
      commit: 0ee2d87523e906518d34a6b423271e4826f71faf
      libslirp: 4.7.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.3
  swapFree: 0
  swapTotal: 0
  uptime: 36h 19m 18.00s (Approximately 1.50 days)
  variant: v8
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - docker.io
store:
  configFile: /usr/share/containers/storage.conf
  containerStore:
    number: 1
    paused: 0
    running: 1
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 99252940800
  graphRootUsed: 4171116544
  graphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "true"
    Supports volatile: "true"
    Using metacopy: "true"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 6
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 4.8.2
  Built: 1702300963
  BuiltTime: Mon Dec 11 05:22:43 2023
  GitCommit: ""
  GoVersion: go1.21.4
  Os: linux
  OsArch: linux/arm64
  Version: 4.8.2

Podman in a container

No

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

Additional environment details

Podman Desktop (v1.6.4) on ARM64 MacOS

Additional information

No response

@danegsta danegsta added the kind/bug Categorizes issue or PR as related to a bug. label Jan 19, 2024
@github-actions github-actions bot added the remote Problem is in podman-remote label Jan 19, 2024
@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2024

I see

# podman network create dan
# podman network connect  dan 1dd1e1833e43

Generates

{"ID":"1dd1e1833e4342819009b03337e538d46e4fdfb06bd015e7afe6ece1082de055","network":"dan","Status":"connect","Time":"2024-01-20T06:59:28.725812363-05:00","Type":"network","Attributes":null}

@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2024

podman -v
podman version 4.8.3

@rhatdan
Copy link
Member

rhatdan commented Jan 20, 2024

After disconnect
{"ID":"1dd1e1833e4342819009b03337e538d46e4fdfb06bd015e7afe6ece1082de055","network":"dan","Status":"disconnect","Time":"2024-01-20T07:02:09.341769951-05:00","Type":"network","Attributes":null}

@rhatdan rhatdan closed this as completed Jan 20, 2024
@danegsta
Copy link
Author

This seems to specifically be an issue when podman is running in remote mode; I just grabbed a laptop I have Fedora installed on and I do see the network when running daemonless, but as soon as I enable the daemon and run the commands with --remote, I see the same behavior I reported above running podman with Podman Desktop/podman machine on my mac (which makes sense, since that's daemon based).

@danegsta
Copy link
Author

@rhatdan would it be possible to re-open this issue since it does seem to be broken when using a remote socket? I'm working on adding support for Podman to an orchestration library (dotnet/aspire#827) and being able to proactively monitor resources for changes definitely gives a better experience. It's not a blocker, but would be nice to have working consistently.

@rhatdan rhatdan reopened this Jan 23, 2024
@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2024

@Luap99 PTAL

@Luap99 Luap99 added the network Networking related issue or feature label Jan 24, 2024
@Luap99
Copy link
Member

Luap99 commented Jan 24, 2024

I don't have time to look into it

@rhatdan
Copy link
Member

rhatdan commented Jan 28, 2024

This is what I am seeing on the main branch

In one Window:

sh-5.2# ./bin/podman-remote  network connect dan elated_knuth
sh-5.2# ./bin/podman-remote  network disconnect dan elated_knuth

In a different window:

# podman events --format json
{"ID":"41a90bb0b4dc14f3e75718475d465b7d6d76aefa8499dfcede66f970422cd2d4","network":"dan","Status":"connect","Time":"2024-01-28T16:01:53.963418862-05:00","Type":"network","Attributes":null}
{"ID":"41a90bb0b4dc14f3e75718475d465b7d6d76aefa8499dfcede66f970422cd2d4","network":"dan","Status":"disconnect","Time":"2024-01-28T16:02:02.305422279-05:00","Type":"network","Attributes":null}

So this seems to be fixed in the upstream.

@rhatdan rhatdan closed this as completed Jan 28, 2024
@Luap99
Copy link
Member

Luap99 commented Jan 29, 2024

you need to check with podman-remote events

@Luap99 Luap99 reopened this Jan 29, 2024
rhatdan added a commit to rhatdan/podman that referenced this issue Feb 6, 2024
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label May 9, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators May 9, 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. network Networking related issue or feature remote Problem is in podman-remote
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants