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

API - system service panics if events connection closes #6805

Closed
pzl opened this issue Jun 28, 2020 · 1 comment · Fixed by #6838
Closed

API - system service panics if events connection closes #6805

pzl opened this issue Jun 28, 2020 · 1 comment · Fixed by #6838
Assignees
Labels
HTTP API Bug is in RESTful API 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

@pzl
Copy link

pzl commented Jun 28, 2020

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

The system service command will crash (panic) if the events API was called, and an event is generated after the connection has closed

Steps to reproduce the issue:

  1. podman system service -t 0 tcp:localhost:7555

  2. curl http://localhost:7555/v1.0.0/libpod/events

  3. ctrl-c or SIGINT the curl command

  4. do anything to generate an event output (e.g. restart a container)

Describe the results you received:

panic: send on closed channel
	panic: close of closed channel

goroutine 120 [running]:
github.com/containers/libpod/libpod/events.EventLogFile.Read(0x56483c99e092, 0x4, 0xc00042cfc0, 0x21, 0xc00009f2c0, 0x56483df95d58, 0x0, 0x0, 0x0, 0x0, ...)
	_output/src/github.com/containers/libpod/libpod/events/logfile.go:69 +0x2dc
github.com/containers/libpod/libpod.(*Runtime).Events(0xc00040a300, 0xc00009f2c0, 0x56483df95d58, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, ...)
	_output/src/github.com/containers/libpod/libpod/events.go:83 +0x8e
github.com/containers/libpod/pkg/api/handlers/compat.GetEvents.func1(0xc00009f200, 0xc000750360, 0x56483df95d58, 0x0, 0x0, 0xc00009f2c0, 0xc00040a300, 0xc000081940)
	_output/src/github.com/containers/libpod/pkg/api/handlers/compat/events.go:51 +0x106
created by github.com/containers/libpod/pkg/api/handlers/compat.GetEvents
	_output/src/github.com/containers/libpod/pkg/api/handlers/compat/events.go:49 +0x53f

Describe the results you expected:

continue to run

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

Version:      2.0.1
API Version:  1
Go Version:   go1.14.4
Git Commit:   a11c4ead10177a66ef2810a0a92ea8ce2299da07
Built:        Sat Jun 27 16:04:26 2020
OS/Arch:      linux/amd64

Output of podman info --debug:

host:
  arch: amd64
  buildahVersion: 1.15.0
  cgroupVersion: v1
  conmon:
    package: Unknown
    path: /usr/bin/conmon
    version: 'conmon version 2.0.18, commit: 7b3e303be8f1aea7e0d4a784c8e64a75c14756a4'
  cpus: 8
  distribution:
    distribution: arch
    version: unknown
  eventLogger: file
  hostname: warehouse
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 5.7.6-arch1-1
  linkmode: dynamic
  memFree: 23595421696
  memTotal: 33619288064
  ociRuntime:
    name: runc
    package: Unknown
    path: /usr/bin/runc
    version: |-
      runc version 1.0.0-rc10
      commit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
      spec: 1.0.1-dev
  os: linux
  remoteSocket:
    path: /run/podman/podman.sock
  rootless: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 0
  swapTotal: 0
  uptime: 2h 52m 28.74s (Approximately 0.08 days)
registries:
  localhost:5001:
    Blocked: false
    Insecure: true
    Location: localhost:5001
    MirrorByDigestOnly: false
    Mirrors: []
    Prefix: localhost:5001
  search:
  - localhost:5001
  - docker.io
  - registry.fedoraproject.org
  - quay.io
  - registry.access.redhat.com
  - registry.centos.org
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 21
    paused: 0
    running: 21
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev
  graphRoot: /var/lib/containers/storage
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Using metacopy: "true"
  imageStore:
    number: 34
  runRoot: /var/run/containers/storage
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 1
  Built: 1593288266
  BuiltTime: Sat Jun 27 16:04:26 2020
  GitCommit: a11c4ead10177a66ef2810a0a92ea8ce2299da07
  GoVersion: go1.14.4
  OsArch: linux/amd64
  Version: 2.0.1

Package info (e.g. output of rpm -q podman or apt list podman):

Name            : podman
Version         : 2.0.1-1
Description     : Tool and library for running OCI-based containers in pods
Architecture    : x86_64
URL             : https://github.com/containers/libpod
Licenses        : Apache
Groups          : None
Provides        : None
Depends On      : cni-plugins  conmon  device-mapper  iptables  libseccomp  runc  slirp4netns  libsystemd  fuse-overlayfs  skopeo
Optional Deps   : podman-docker: for Docker-compatible CLI
                  btrfs-progs: support btrfs backend devices [installed]
                  catatonit: --init flag support
                  crun: support for unified cgroupsv2
Required By     : aimrip  arch-repo  bookstack  cockpit-podman  elastic  entertainment  git-host  homedns  monica-crm  organizr  registry  traefik
                  transmission-vpn  unifi  vpn-out  webstore
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 89.15 MiB
Packager        : Morten Linderud <[email protected]>
Build Date      : Sat 27 Jun 2020 04:04:26 PM EDT
Install Date    : Sat 27 Jun 2020 09:47:01 PM EDT
Install Reason  : Explicitly installed
Install Script  : No
Validated By    : Signature

Additional environment details (AWS, VirtualBox, physical, etc.):

physical machine

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 28, 2020
@baude
Copy link
Member

baude commented Jun 28, 2020

I can repro this. @jwhonce ptal

@mheon mheon added the HTTP API Bug is in RESTful API label Jun 30, 2020
@mheon mheon self-assigned this Jun 30, 2020
mheon added a commit to mheon/libpod that referenced this issue Jul 2, 2020
We weren't actually halting the goroutine that sent events, so it
would continue sending even when the channel closed (the most
notable cause being early hangup - e.g. Control-c on a curl
session). Use a context to cancel the events goroutine and stop
sending events.

Fixes containers#6805

Signed-off-by: Matthew Heon <[email protected]>
mheon added a commit to mheon/libpod that referenced this issue Jul 6, 2020
We weren't actually halting the goroutine that sent events, so it
would continue sending even when the channel closed (the most
notable cause being early hangup - e.g. Control-c on a curl
session). Use a context to cancel the events goroutine and stop
sending events.

Fixes containers#6805

Signed-off-by: Matthew Heon <[email protected]>
skorhone pushed a commit to skorhone/libpod that referenced this issue Jul 7, 2020
We weren't actually halting the goroutine that sent events, so it
would continue sending even when the channel closed (the most
notable cause being early hangup - e.g. Control-c on a curl
session). Use a context to cancel the events goroutine and stop
sending events.

Fixes containers#6805

Signed-off-by: Matthew Heon <[email protected]>
@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 Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
HTTP API Bug is in RESTful API 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

Successfully merging a pull request may close this issue.

5 participants