postgresql-container icon indicating copy to clipboard operation
postgresql-container copied to clipboard

Allow logging to /dev/stderr

Open hhorak opened this issue 5 years ago • 12 comments

For easier debugging, it should be pretty easy to switch daemon to log into the /dev/stderr. This adds such a feature by setting POSTGRESQL_LOG_DESTINATION environment variable to /dev/stderr.

This should address #353.

hhorak avatar Mar 23 '20 08:03 hhorak

[test]

phracek avatar Mar 26 '20 08:03 phracek

centos7 failure will be fixed by https://github.com/sclorg/postgresql-container/pull/368

pkubatrh avatar Mar 26 '20 09:03 pkubatrh

@hhorak rhel8 test is failing by

+ echo 'psql -U nonexistent'
++ get_cid pg-test-logging
++ local id=pg-test-logging
++ shift
+++ cat /tmp/tmp.nwSOqgiZvspostgresql_test_cidfiles/pg-test-logging
++ echo b9893aa670ad049bae5a6db4fa5f6a2116c7fb9b38d5b79e75c4111f2e5f06b6
+ docker exec -i b9893aa670ad049bae5a6db4fa5f6a2116c7fb9b38d5b79e75c4111f2e5f06b6 bash
+ sleep 1
+ grep -q 'FATAL:  role "nonexistent" does not exist'
++ get_cid pg-test-logging
++ local id=pg-test-logging
++ shift
+++ cat /tmp/tmp.nwSOqgiZvspostgresql_test_cidfiles/pg-test-logging
++ echo b9893aa670ad049bae5a6db4fa5f6a2116c7fb9b38d5b79e75c4111f2e5f06b6
+ docker logs b9893aa670ad049bae5a6db4fa5f6a2116c7fb9b38d5b79e75c4111f2e5f06b6
ERROR: the container log does not include expected error message
+ echo 'ERROR: the container log does not include expected error message'

Unfortunately, I am not able to reproduce it locally :( Locally all tests are passing. I will try it once more.

phracek avatar Mar 26 '20 10:03 phracek

[test]

phracek avatar Apr 21 '20 12:04 phracek

[test]

phracek avatar Apr 22 '20 08:04 phracek

Needs a rebase now that #368 is merged

pkubatrh avatar May 04 '20 10:05 pkubatrh

Rebased [test-openshift]

pkubatrh avatar Jun 17 '20 12:06 pkubatrh

[test]

phracek avatar Jun 17 '20 13:06 phracek

A friendly ping - will this be eventually applied? It would definitely help us.

fridex avatar Mar 11 '21 21:03 fridex

A friendly ping - will this be eventually applied? It would definitely help us.

That's great feedback, thanks, we'll try to finish it.

hhorak avatar Mar 12 '21 13:03 hhorak

Let's try to run all tests once more.

[test-all]

phracek avatar Nov 30 '21 08:11 phracek

[test-all]

phracek avatar May 09 '22 13:05 phracek

Lets try to revisit and make sure this gets merged.

pkubatrh avatar Feb 22 '23 09:02 pkubatrh

[test]

fila43 avatar Mar 01 '23 08:03 fila43

Rebased.

hhorak avatar Mar 01 '23 08:03 hhorak

[test]

hhorak avatar Mar 01 '23 08:03 hhorak

Test for this had some issues, so let's try again after improving it a bit. [test]

hhorak avatar Mar 01 '23 09:03 hhorak

[test]

hhorak avatar Mar 01 '23 09:03 hhorak

RHEL8 tests are failing for this reason:

-----------------------------------------------
Running test run_logging_test (starting at 2023-03-01 06:04:51-05:00) ... 
-----------------------------------------------
640a6a2bef4835f14cf7403051c5a2d4e544647f643926977ac84fb9806f6889
Created container 640a6a2bef4835f14cf7403051c5a2d4e544647f643926977ac84fb9806f6889
Error: non zero exit code: 2: OCI runtime error
Error: non zero exit code: 2: OCI runtime error
Error: read unixpacket @->/var/run/libpod/socket/d0e9d591a8da0bcdbc8d9657fb9b3fdb958f81162accc0d33637c7ffe2de3973/attach: read: connection reset by peer
ERROR: the container log does not include expected error message
Test for image 'rhel8/postgresql-13:1' FAILED (exit code: 1)

[snipped]
 [PASSED] for 'postgresql-container_tests' run_pgaudit_test (00:00:05)
 [FAILED] for 'postgresql-container_tests' run_logging_test (00:00:05)

What about adding more logs for debugging issues?

phracek avatar Mar 01 '23 14:03 phracek

[test]

fila43 avatar Mar 09 '23 13:03 fila43

@hhorak Please have a look at RHEL8 tests. They are failing on:

 [FAILED] for 'postgresql-container_tests' run_logging_test (00:00:05). 

May be more logs for traces would be fine.

phracek avatar Mar 22 '23 12:03 phracek

@phracek I see [FAILED] for 'postgresql-container_tests' run_master_restart_test (00:01:14)

fila43 avatar Mar 22 '23 12:03 fila43

The investigation in https://github.com/sclorg/postgresql-container/pull/503 leads me to the conclusion. Added functionality works as expected, and it's proven by passing all tests except RHEL8. Logging to stderr also should work in the case of RHEL8. Unfortunately, RHEL8 uses podman version 1.6.4. This version raises error Error: non zero exit code: 2: OCI runtime error for the docker exec command used in the test case.

fila43 avatar Mar 27 '23 07:03 fila43

The investigation in #503 leads me to the conclusion. Added functionality works as expected, and it's proven by passing all tests except RHEL8. Logging to stderr also should work in the case of RHEL8. Unfortunately, RHEL8 uses podman version 1.6.4. This version raises error Error: non zero exit code: 2: OCI runtime error for the docker exec command used in the test case.

Do you think it could be a bug in podman? Or some needed functionality is not implemented in this version of podman?

zmiklank avatar Mar 27 '23 07:03 zmiklank

@fila43 I see the docker exec exit code should not matter, as the line ends with || : -- can you explain why it might make the difference?

hhorak avatar Mar 27 '23 07:03 hhorak

[test]

zmiklank avatar Mar 27 '23 10:03 zmiklank

[test]

fila43 avatar Mar 27 '23 20:03 fila43

It seems that master_restart_test randomly fails. Since it isn't related to this PR, could we merge it @hhorak @zmiklank? I would prefer to fix the failing test in a separate PR later. Because it happens only occasionally and only within GitHub CI, it makes investigating the problem tricky.

fila43 avatar Mar 28 '23 09:03 fila43

It seems that master_restart_test randomly fails. Since it isn't related to this PR, could we merge it @hhorak @zmiklank? I would prefer to fix the failing test in a separate PR later. Because it happens only occasionally and only within GitHub CI, it makes investigating the problem tricky.

I agree to fix the test which is not connected to this PR separately. However I can not give lgtm to this PR now, as I did not review it yet.

zmiklank avatar Mar 28 '23 10:03 zmiklank

From my point of view, the PR is LGTM. There is only one unrelated problem with random failures. But I am ok to wait for your review. Thanks

fila43 avatar Mar 28 '23 10:03 fila43