Skip to content

Commit 2e8593b

Browse files
committed
PR feedback, v1
1 parent 1d8abd3 commit 2e8593b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

internal/controller/standalone_pgadmin/pod.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ with open('` + configMountPath + `/` + gunicornConfigFilePath + `') as _f:
435435

436436
configSystem = configSystem + `
437437
LOG_ROTATION_AGE = ` + pgAdminRetentionPeriod + ` # minutes
438-
LOG_ROTATION_SIZE = 5 # MiB
439438
LOG_ROTATION_MAX_LOG_FILES = ` + maxBackupRetentionNumber + `
440439
441440
JSON_LOGGER = True
@@ -447,6 +446,9 @@ FILE_LOG_FORMAT_JSON = {'time': 'created', 'name': 'name', 'level': 'levelname',
447446
// Gunicorn uses the Python logging package, which sets the following attributes:
448447
// https://docs.python.org/3/library/logging.html#logrecord-attributes.
449448
// JsonFormatter is used to format the log: https://pypi.org/project/jsonformatter/
449+
// We override the gunicorn defaults (using `logconfig_dict`) to set our own file handler.
450+
// - https://docs.gunicorn.org/en/stable/settings.html#logconfig-dict
451+
// - https://github.com/benoitc/gunicorn/blob/23.0.0/gunicorn/glogging.py#L47
450452
gunicornConfig = gunicornConfig + `
451453
import collections, copy, gunicorn, gunicorn.glogging
452454
gunicorn.SERVER_SOFTWARE = 'Python'
@@ -481,6 +483,9 @@ logconfig_dict['formatters']['json'] = {
481483
// - https://issue.k8s.io/121294
482484
shell.MakeDirectories(0o775, scriptMountPath, configMountPath),
483485

486+
// Create the logs directory with g+rwx to ensure pgAdmin can write to it as well.
487+
shell.MakeDirectories(0o775, dataMountPath, LogDirectoryAbsolutePath),
488+
484489
// Write the system and server configurations.
485490
`echo "$1" > ` + scriptMountPath + `/config_system.py`,
486491
`echo "$2" > ` + scriptMountPath + `/gunicorn_config.py`,

internal/controller/standalone_pgadmin/pod_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ initContainers:
139139
- --
140140
- |-
141141
mkdir -p '/etc/pgadmin/conf.d' && chmod 0775 '/etc/pgadmin/conf.d'
142+
mkdir -p '/var/lib/pgadmin/logs' && chmod 0775 '/var/lib/pgadmin/logs'
142143
echo "$1" > /etc/pgadmin/config_system.py
143144
echo "$2" > /etc/pgadmin/gunicorn_config.py
144145
- startup
@@ -337,6 +338,7 @@ initContainers:
337338
- --
338339
- |-
339340
mkdir -p '/etc/pgadmin/conf.d' && chmod 0775 '/etc/pgadmin/conf.d'
341+
mkdir -p '/var/lib/pgadmin/logs' && chmod 0775 '/var/lib/pgadmin/logs'
340342
echo "$1" > /etc/pgadmin/config_system.py
341343
echo "$2" > /etc/pgadmin/gunicorn_config.py
342344
- startup
@@ -358,7 +360,6 @@ initContainers:
358360
LOG_FILE = '/var/lib/pgadmin/logs/pgadmin.log'
359361
360362
LOG_ROTATION_AGE = 60 # minutes
361-
LOG_ROTATION_SIZE = 5 # MiB
362363
LOG_ROTATION_MAX_LOG_FILES = 11
363364
364365
JSON_LOGGER = True

0 commit comments

Comments
 (0)