portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
31.04k stars 2.48k forks source link

Log viewer seems to show logs in scrambled order #5305

Open john8329 opened 3 years ago

john8329 commented 3 years ago

Bug description The log viewer window seems to display log lines in a chaotic order when the service is crashing at every startup, making inspections more difficult.

Expected behavior The logs should not mix lines but display them in the same order as they were emitted by the container(s)

Steps to reproduce the issue:

  1. Create a service that crashes on startup
  2. Run it inside a global service with an restart policy set to on-failure
  3. Check the log viewer

Technical details:

Screenshot 2021-07-13 at 18 36 04

You can see in the screenshot that the golang trace is mixed with other lines (some details are obscured for security).

More details:

Screenshot 2021-07-13 at 18 45 34
srebala commented 3 years ago

Hi please share the service yaml used to reproduce this issue

john8329 commented 3 years ago
version: '3.7'
services:
  max:
    image: '###############'
    ports:
      - '#####:#####'
    volumes:
      - max_data:/opt/max/data
    environment:
      DB_HOST: 'database'
      DB_PORT: '#####'
      DB_USER: '#####'
      DB_PASS: '#####'
      DB_NAME: '#####'
      SERVER_NAME: ${CLIENT_NAME} Server
      PRINT_SERVICE_WEB_HOST: print
    networks:
      - backend
    depends_on:
      - print
      - database
    labels:
      #####.client-code: ${CLIENT_CODE}
      #####.client-name: ${CLIENT_NAME}
    deploy:
      mode: global
      restart_policy:
        condition: on-failure
...
john8329 commented 3 years ago

After doing some more tests today, I can confirm it's quite reproducible. New logs aren't shown, and old logs get mixed up. The timestamps should be the evidence. Happens only when seeing them from the service, not the container. Screenshot 2021-07-20 at 22 56 47

huib-portainer commented 3 years ago

This has come up before as well https://github.com/portainer/portainer/issues/1942.

SvenDowideit commented 3 years ago

I'm going to suggest that this is really a Docker issue - https://github.com/moby/moby/issues/33673 (and many others) and I think you can improve it by using one of the more complicated log drivers - but there is buffering in the system, preferring not-losing info instead of preferring order