Icinga / docker-icingaweb2

GNU General Public License v2.0
16 stars 11 forks source link

Database check in entrypoint fails without explanation #12

Closed hemebond closed 4 years ago

hemebond commented 4 years ago

Trying to get Icingaweb Docker, Icinga Docker, and PostgreSQL Docker running together. Icinga master and PostgreSQL are talking to each other just fine; icingaweb is not.

The entrypoint for the icingaweb container fails when checking the database resources but doesn't tell me what's wrong:

$ docker run --rm -p 8080:8080 --network icinga --name icingaweb --hostname icingaweb --mount type=bind,source="$(pwd)",target=/data icinga/icingaweb2:master
[Tue Jul 14 13:11:36.071662818 2020] [docker_entrypoint:info] [pid 1] DOCKERE: Initializing /data as we're the init process
[Tue Jul 14 13:11:36.071774584 2020] [docker_entrypoint:debug] [pid 1] DOCKERE: Creating "/data/etc/icingaweb2/enabledModules"
[Tue Jul 14 13:11:36.071786961 2020] [docker_entrypoint:debug] [pid 1] DOCKERE: Translating env vars to .ini config
[Tue Jul 14 13:11:36.071792507 2020] [docker_entrypoint:info] [pid 1] DOCKERE: Checking database resources used as backends
[Tue Jul 14 13:11:36.120847076 2020] [docker_entrypoint:debug] [pid 1] DOCKERE: Checking database resource "icingaweb_db"
[Tue Jul 14 13:11:36.173114171 2020] [docker_entrypoint:crit] [pid 1] DOCKERE: exit status 1

Note the configuration files already exist, configured initially via the environment variables.

Al2Klimov commented 4 years ago

I'm afraid that's an upstream problem.

Al2Klimov commented 4 years ago

CC @nilmerg

hemebond commented 4 years ago

Are you able to tell me what commands the entrypoint is trying to run through icingacli?

I wonder if maybe the icingacli executable is not working as intended:

root@icingaweb:/# icingacli setup token create
ERROR: There is no such module or command: 'setup'

USAGE: icingacli [module] <command> [action] [options]

Available commands:

  help            Help for modules, commands and actions
  module          List and handle modules
  version         Shows version of Icinga Web 2, loaded modules and PHP
  web             

Available modules:

  icingadb
  ipl

Global options:

  --log [t]       Log to <t>, either stderr, file or syslog (default: stderr)
  --log-path <f>  Which file to log into in case of --log file
  --verbose       Be verbose
  --debug         Show debug output
  --help          Show help
  --benchmark     Show benchmark summary
  --watch [s]     Refresh output every <s> seconds (default: 5)
  --version       Shows version of Icinga Web 2, loaded modules and PHP

Show help on a specific command : icingacli help <command>
Show help on a specific module  : icingacli help <module>

root@icingaweb:/# icingacli --version
Icinga Web 2  2.8.1     
Git Commit    8ce90b38fc2af6208e2c1bcfa7bf0d384c7aa1ce 
PHP Version   7.3.14-1~deb10u1 
MODULE    VERSION   
icingadb  1.0.0-rc1 
ipl       v0.5.0    
Al2Klimov commented 4 years ago

It's calling these Icinga CLI actions.

Al2Klimov commented 4 years ago

In your case it's this one.

hemebond commented 4 years ago

Thank you for pointing to the function. Is it just checking for the existence of the icingaweb_group table? I've checked database connectivity from the container and it's fine. The database and tables are already there.

edit Okay, I got it going. I found the issue with my resource.ini by going around the entrypoint:

docker run -it --entrypoint bash --rm -p 8080:8080 --network icinga --name icingaweb --hostname icingaweb --mount type=bind,source="$(pwd)",target=/data icinga/icingaweb2:master

www-data@icingaweb:/$ bash -c ". /etc/apache2/envvars; exec apache2 -DFOREGROUND"

This can be closed if you have no need for it (since it's an upstream issue hiding the output).

Al2Klimov commented 4 years ago
  1. Try to run it interactively while overriding the entrypoint and the command: -it --entrypoint bash bash
  2. In that shell:
    1. ln -vs /entrypoint-db-init /data/etc/icingaweb2/enabledModules/dockerentrypoint
    2. icingacli mod en setup
    3. icingacli dockerentrypoint db initialized --resource=icingaweb_db
    4. rm /data/etc/icingaweb2/enabledModules/dockerentrypoint
    5. icingacli mod dis setup
Al2Klimov commented 4 years ago

the issue with my resource.ini

Which issue?

hemebond commented 4 years ago

I had an incorrect database type. Should have been pgsql. Once I could see the Apache output I could see it complaining about it.