pgcenter icon indicating copy to clipboard operation
pgcenter copied to clipboard

Top is not working when starting using docker

Open strav66 opened this issue 3 years ago • 20 comments

Docker postgrespro-standard work in centos 8.3

pgcenter 0.6.6 work in docker

docker exec -it srv-db-APSD-VO pgcenter --version
pgcenter v0.6.6 4f87424-master
docker exec -it srv-db-APSD-VO pgcenter top

изображение

pgcenter 0.7.0 not work docker:

docker exec -it srv-db-APSD-VO /opt/pgpro/data/pgcenter --version
pgcenter v0.7.0 45c8bf0d0098f377692be886691eba9ee6005808-release
docker exec -it srv-db-APSD-VO /opt/pgpro/data/pgcenter top -h localhost
panic: send on closed channel

goroutine 65 [running]:
github.com/lesovsky/pgcenter/top.collectStat(0x9e5620, 0xc000138c40, 0xc000122080, 0xc000382000, 0xc0001281e0)
        /home/runner/work/pgcenter/pgcenter/top/stat.go:57 +0x371
github.com/lesovsky/pgcenter/top.doWork.func1(0x9e5620, 0xc000138c40, 0xc000148000, 0xc000382000, 0xc000380000)
        /home/runner/work/pgcenter/pgcenter/top/ui.go:77 +0x65
created by github.com/lesovsky/pgcenter/top.doWork
        /home/runner/work/pgcenter/pgcenter/top/ui.go:76 +0xeb

strav66 avatar Mar 04 '21 10:03 strav66

Hi, thanks for report, What docker image is used?

lesovsky avatar Mar 04 '21 10:03 lesovsky

my build docker

Dockerfile.zip

strav66 avatar Mar 04 '21 10:03 strav66

What happen if run container and then run pgcenter being inside? Like:

docker run --rm -ti IMAGE /bin/bash
pgcenter top ...

lesovsky avatar Mar 04 '21 11:03 lesovsky

Работает, но странно: /opt/pgpro/data/pgcenter top -h localhost

изображение

нет статистики: процессор, память и т.д.

Если запускать так (внутри docker): /opt/pgpro/data/pgcenter top

тогда ругается: failed to connect to host=/var/run/postgresql user=postgres database=: dial error (dial unix /var/run/postgresql/.s.PGSQL.5432: connect: no such file or directory)

для 0.6.6 соответственно: pgcenter top -h localhost

изображение

pgcenter top

изображение

Всё отлично и со статистикой

strav66 avatar Mar 04 '21 12:03 strav66

I tested various cases using different docker images and bug reproduced in most of cases. Sometimes pgcenter starts as expected but at next, the same attempt it crashed again (even 0.6.6 might hang with black screen). I suspect there something related to UI processing when docker starts, but need to dig deeper. I changed the title of the issue to reflect the problem more precisely.

Also I strongly recommended to avoid using national languages and post comments using English.

lesovsky avatar Mar 04 '21 14:03 lesovsky

OK

tried 10 times sequentially run pgcenter 0.7.0: docker exec -it srv-db-APSD-VO /opt/pgpro/data/pgcenter top -h localhost 6 times started with errors, 4 times - ok (but without CPU statistics, etc.)

error: panic: send on closed channel

goroutine 53 [running]: github.com/lesovsky/pgcenter/top.collectStat(0x9e5620, 0xc000310040, 0xc000122080, 0xc000326000, 0xc0001281e0) /home/runner/work/pgcenter/pgcenter/top/stat.go:57 +0x371 github.com/lesovsky/pgcenter/top.doWork.func1(0x9e5620, 0xc000310040, 0xc000140000, 0xc000326000, 0xc000318010) /home/runner/work/pgcenter/pgcenter/top/ui.go:77 +0x65 created by github.com/lesovsky/pgcenter/top.doWork /home/runner/work/pgcenter/pgcenter/top/ui.go:76 +0xeb

pgcentert 0.6.6 - never broke (maybe I was just lucky)

strav66 avatar Mar 04 '21 14:03 strav66

Hi, check out new v0.8.0 release, both issues related to absence of stats and panic are fixed. Waiting for testing and feedback.

lesovsky avatar Mar 08 '21 13:03 lesovsky

pgcenter 0.8.0 works fine!

изображение

strav66 avatar Mar 09 '21 06:03 strav66

Addition: when exiting (closing pgcenter) an error occurs:

panic: runtime error: slice bounds out of range [:-1]

goroutine 49 [running]:
github.com/nsf/termbox-go.Init.func1()
        /home/runner/go/pkg/mod/github.com/nsf/[email protected]/api.go:95 +0x36a
created by github.com/nsf/termbox-go.Init
        /home/runner/go/pkg/mod/github.com/nsf/[email protected]/api.go:84 +0x730

strav66 avatar Mar 09 '21 07:03 strav66

Panic occurs at every time or spontaneously? What docker image do you use? Try to reproduce error using lesovsky/pgcenter:v0.8.0 image.

lesovsky avatar Mar 09 '21 07:03 lesovsky

Panic occurs at every time or spontaneously?

spontaneously

What docker image do you use?

my docker image

strav66 avatar Mar 09 '21 08:03 strav66

What about attempt to reproduce using lesovsky/pgcenter:v0.8.0 image?

my docker image

It is insufficient information, provide more details... base image, full command definition of how pgcenter was started (including docker opts).

lesovsky avatar Mar 09 '21 08:03 lesovsky

What about attempt to reproduce using lesovsky/pgcenter:v0.8.0 image?

tried lesovsky / pgcenter: v0.8.0 image The error was not reproduced

but it is not possible to use the name localhost with it! I think the error is related to localhost

my docker image

https://github.com/lesovsky/pgcenter/issues/87#issuecomment-790519621

It is insufficient information, provide more details... base image, full command definition of how pgcenter was started (including docker opts).

docker runs via docker-compose (docker-compose.yml.tar.gz): docker-compose up -d

pgcenter upload volume PGDATA run pgcenter and connect to a running docker with the command:

docker exec -it srv-db1C-ERP /opt/pgpro/data/pgcenter top -h localhost

after a few minutes (3-4), sometimes an error occurs (pgcenter continues to work!):

kernel:unregister_netdevice: waiting for lo to become free. Usage count = 1

If it is ok to exit pgcenter (with the q key) the message appears:

panic: runtime error: slice bounds out of range [:-1]

goroutine 49 [running]:
github.com/nsf/termbox-go.Init.func1()
        /home/runner/go/pkg/mod/github.com/nsf/[email protected]/api.go:95 +0x36a
created by github.com/nsf/termbox-go.Init
        /home/runner/go/pkg/mod/github.com/nsf/[email protected]/api.go:84 +0x730


strav66 avatar Mar 09 '21 11:03 strav66

Trying to build the image, need the values of variables from docker-compose:

    build:
      context: ../docker/postgrespro-standard

      dockerfile: Dockerfile.${PG_Version}
      args: 
        - SERVER_VERSION=${PG_Version}
        - SERVER_VERSION_DOT=${PG_Version_dot}
        - KEYS_DOT=${rpm_keys_dot}

No need SERVER_VERSION, but need other values of SERVER_VERSION_DOT, KEYS_DOT and maybe content of ../docker/postgrespro-standard (but not sure).

lesovsky avatar Mar 09 '21 11:03 lesovsky

If you carefully look at the attached archive (docker-compose.yml.tar.gz), you can see the .env file in which the necessary variables are registered

strav66 avatar Mar 09 '21 12:03 strav66

Oh, hidden file ))) yep, found now

lesovsky avatar Mar 09 '21 12:03 lesovsky

Both ways failed due to necessary files are not exist.

  1. using docker-compose build
docker-compose build
ERROR: build path /tmp/docker/postgrespro-standard either does not exist, is not accessible, or is not a valid URL
  1. manual docker build also fails
docker build --build-arg SERVER_VERSION=12 --build-arg SERVER_VERSION_DOT=6.1 --build-arg KEYS_DOT=0.3 -t local/pg1c:dev -f Dockerfile.10 .
... too many lines ...
COPY failed: file not found in build context or excluded by .dockerignore: stat container/docker-entrypoint.sh: file does not exist

Also such files are not found in attached archives. Maybe you just build and publish the image on DockerHub?

lesovsky avatar Mar 09 '21 12:03 lesovsky

Complete set of everything you need for build image docker-compose-build.tar.gz

Unpack it into some folder go to the ERP folder we give the command:

docker-compose build

Profit

strav66 avatar Mar 09 '21 12:03 strav66

Thanks, build successful.

Upd. I've just updated pgcenter download links in Dockerfiles, from 0.6.x to 0.8.0.

lesovsky avatar Mar 09 '21 12:03 lesovsky

Spent a quite lot of time for testing and could not reproduce the panic at quit. Also I have no idea how to catch this using unit-tests.

Would like to clarify, are you sure you build the image with proper version of pgcenter (v0.8.0)? Because I manually changed pgcenter's version in your files before build. Maybe you catch error with old version (the similarly as it was here)?

lesovsky avatar Mar 11 '21 05:03 lesovsky