podman: Rest endpoint `/events` is cutting messages after 2048 chars while it should not
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
We can track podman events from clients by listening to /events
https://docs.podman.io/en/latest/_static/api.html?version=v4.1#operation/SystemEvents
The problem is that sometimes the events are cut, thus the client is only receiving a chunk of the full message, leading to invalid JSON content
Steps to reproduce the issue:
- I’ve tried with a simple nodejs client.
Basically it connects to /events and wait that it receive contents before displaying
If I use Podman as backend I receive the following data when running a container from quay.io/openshift/origin-hello-openshift
{"status":"create","id":"8e62a37e1f0562645905a7ae0def90f7d594f80b62bf393d97018ad0a64f02a5","from":"quay.io/openshift/origin-hello-openshift:latest","Type":"container","Action":"create","Actor":{"ID":"8e62a37e1f0562645905a7ae0def90f7d594f80b62bf393d97018ad0a64f02a5","Attributes":{"License":"GPLv2+","architecture":"x86_64","build-date":"2022-07-07T09:43:46.691337","com.redhat.build-host":"cpt-1008.osbs.prod.upshift.rdu2.redhat.com","com.redhat.component":"openshift-enterprise-base-container","com.redhat.license_terms":"https://www.redhat.com/agreements","containerExitCode":"0","description":"This is the base image from which all OpenShift Container Platform images inherit.","distribution-scope":"public","image":"quay.io/openshift/origin-hello-openshift:latest","io.buildah.version":"1.24.2","io.k8s.description":"ART equivalent image openshift-4.12-openshift-enterprise-base - rhel-8/base-repos","io.k8s.display-name":"4.12-base","io.openshift.build.commit.author":"","io.openshift.build.commit.date":"","io.openshift.build.commit.id":"6af294513f4fd83df5c821ec402fde182b3c390d","io.openshift.build.commit.message":"","io.openshift.build.commit.ref":"master","io.openshift.build.commit.url":"https://github.com/openshift/images/commit/50d342b487ce0f8a89046ddc1d93f390e4334b11","io.openshift.build.name":"","io.openshift.build.namespace":"","io.openshift.build.source-context-dir":"","io.openshift.build.source-location":"https://github.com/openshift/origin","io.openshift.ci.from.base":"sha256:1f7de7b0e1140b38ca08dcd402c2a88e91d438f080566781be3ab6b19bef3ba9","io.openshift.expose-services":"","io.openshift.maintainer.component":"Release","io.openshift.maintainer.product":"OpenShift Container Platform","io.openshift.tags":"openshift,base","maintainer":"Red Hat, Inc.","name":"unruffled_margulis","release":"202207070855.p0.g50d342b.assembly.stream","summary":"Provides the latest release of Red Hat Universal Base Image 8.","url":"https://access.redhat.com/containers/#/registry.access.redhat.com/openshift/ose-base/images/v4.12.0-2022070
and then
70855.p0.g50d342b.assembly.stream","vcs-ref":"6af294513f4fd83df5c821ec402fde182b3c390d","vcs-type":"git","vcs-url":"https://github.com/openshift/origin","vendor":"Red Hat, Inc.","version":"v4.12.0"}},"scope":"local","time":1658478438,"timeNano":1658478438576208167}
so we can see that data has been cut after exactly 2048 characters !
Describe the results you received:
messages are cut after 2048 characters
Describe the results you expected:
messages are not cut
I’ve tried with Docker as backend and here is the result:
receiving data chunk: {"status":"create","id":"db1e1cca9322e71d6c8d99433b94879030742b24afcea20f6a5a1350a64d7e01","from":"quay.io/openshift/origin-hello-openshift","Type":"container","Action":"create","Actor":{"ID":"db1e1cca9322e71d6c8d99433b94879030742b24afcea20f6a5a1350a64d7e01","Attributes":{"License":"GPLv2+","architecture":"x86_64","build-date":"2022-07-07T09:43:46.691337","com.redhat.build-host":"cpt-1008.osbs.prod.upshift.rdu2.redhat.com","com.redhat.component":"openshift-enterprise-base-container","com.redhat.license_terms":"https://www.redhat.com/agreements","description":"This is the base image from which all OpenShift Container Platform images inherit.","distribution-scope":"public","image":"quay.io/openshift/origin-hello-openshift","io.buildah.version":"1.24.2","io.k8s.description":"ART equivalent image openshift-4.12-openshift-enterprise-base - rhel-8/base-repos","io.k8s.display-name":"4.12-base","io.openshift.build.commit.author":"","io.openshift.build.commit.date":"","io.openshift.build.commit.id":"6af294513f4fd83df5c821ec402fde182b3c390d","io.openshift.build.commit.message":"","io.openshift.build.commit.ref":"master","io.openshift.build.commit.url":"https://github.com/openshift/images/commit/50d342b487ce0f8a89046ddc1d93f390e4334b11","io.openshift.build.name":"","io.openshift.build.namespace":"","io.openshift.build.source-context-dir":"","io.openshift.build.source-location":"https://github.com/openshift/origin","io.openshift.ci.from.base":"sha256:1f7de7b0e1140b38ca08dcd402c2a88e91d438f080566781be3ab6b19bef3ba9","io.openshift.expose-services":"","io.openshift.maintainer.component":"Release","io.openshift.maintainer.product":"OpenShift Container Platform","io.openshift.tags":"openshift,base","maintainer":"Red Hat, Inc.","name":"trusting_ardinghelli","release":"202207070855.p0.g50d342b.assembly.stream","summary":"Provides the latest release of Red Hat Universal Base Image 8.","url":"https://access.redhat.com/containers/#/registry.access.redhat.com/openshift/ose-base/images/v4.12.0-202207070855.p0.g50d342b.assembly.stream","vcs-ref":"6af294513f4fd83df5c821ec402fde182b3c390d","vcs-type":"git","vcs-url":"https://github.com/openshift/origin","vendor":"Red Hat, Inc.","version":"v4.12.0"}},"scope":"local","time":1658478727,"timeNano":1658478727409980525}
So we can clearly see that message is 2277 characters long as expected
Additional information you deem important (e.g. issue happens only occasionally):
Output of podman version:
current main branch
Output of podman info --debug:
current main branch
Package info (e.g. output of rpm -q podman or apt list podman):
build from source
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
here is the client I wrote to reproduce the issue
you need to change socketPath to try either on podman or docker
to test:
- launch this client:
node <name-of-this-file.js>when you seeReady to receive events.., you can continue - launch this container:
podman run --rm quay.io/openshift/origin-hello-openshiftto try with Podmandocker run --rm quay.io/openshift/origin-hello-openshiftto try with Docker
const http = require("http");
// uncomment the lines to use either podman or docker socket
const socketPath = '/Users/benoitf/.local/share/containers/podman/machine/podman-machine-default/podman.sock'
//const socketPath = "/var/run/docker.sock";
const path = "/v1.41/events";
const req = http.request({ method: "GET", socketPath, path }, (res) => {
console.log("Ready to receive events...");
res.on("data", (chunk) => {
console.log("receiving data chunk:", chunk.toString());
try {
JSON.parse(chunk.toString());
console.log("Valid-JSON");
} catch (error) {
console.log("Invalid JSON", error);
}
});
res.on("end", () => {
console.log("ending with status", res.statusCode);
});
});
req.end();
req.once("error", (err) => {
console.log("receive error", err);
});
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (23 by maintainers)
As an update, #15086 was merged: the docker API compatibility end-points that offer API streaming, we now buffer up to 8k. I tested the provided example which does work for me.