metwork-framework / mfbase

metwork/mfbase module
http://metwork-framework.org
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

cannot install a plugin automatically with the provisionning feature #290

Closed matthieumarrast closed 7 months ago

matthieumarrast commented 7 months ago

Problem

Start container metwork/mfbaseplugins-rocky9-image:release_2.2

Put a plugin plugin file in the provsionning feature /etc/metwork.config.d/mfbase/plugins/

Start mfbase.

Check plugin is installed:

plugins.list
╔Installed plugins (1)══════╦═════════╦══════════╦════════════════════════════════════════════════════╗
║ Name                      ║ Version ║ Release  ║ Home                                               ║
╠═══════════════════════════╬═════════╬══════════╬════════════════════════════════════════════════════╣
║ foo                       ║ 2.0.0   ║ beta.1.1 ║ /home/mfbase/var/plugins/foo║
╚═══════════════════════════╩═════════╩══════════╩════════════════════════════════════════════════════╝

Try to connect to plugin's database:

[mfbase@61c73774c9f0:~] $ psql -U plugin_foo -h localhost -p 7432
Password for user plugin_foo: 
psql: error: connection to server at "localhost" (127.0.0.1), port 7432 failed: FATAL:  password authentication failed for user "plugin_foo"

-> the error happen during the batch_psql command, when the password is updated in https://github.com/metwork-framework/mfbase/blob/master/adm/_create_plugin_database.sh => why "metwork" database does not exist whereas it is created in mfbase.init !!??

Solution

To Be Determined

Action

Add an Unitary Test.

matthieumarrast commented 7 months ago

I tried to launch the command manually and it works:

[mfbase@4985b50695d2:~] $ psql -U plugin_foo -h /home/mfbase/var -p 7432 -f /tmp/alter_user.872 -v "ON_ERROR_STOP=1" metwork
ALTER ROLE
matthieumarrast commented 7 months ago

Same problem with container metwork/mfbaseplugins-centos8-buildimage:release_2.2

thebaptiste commented 7 months ago

I don't reproduce with metwork/mfbaseplugins-centos8-buildimage:release_2.2 with a plugin produced inside the container with bootstrap_plugin.py, make release and copy of the plugin on /etc/metwork.config.d/mfbase/plugins/

matthieumarrast commented 7 months ago

I don't reproduce with metwork/mfbaseplugins-centos8-buildimage:release_2.2 with a plugin produced inside the container with bootstrap_plugin.py, make release and copy of the plugin on /etc/metwork.config.d/mfbase/plugins/

Try with below commands:

docker run -it metwork/mfbaseplugins-centos8-buildimage:release_2.2 bash
su  - mfbase
bootstrap_plugin.py create foo
cd foo/
make release
exit
mv /home/mfbase/foo/foo-0.0.1-1.metwork.mfbase.plugin /etc/metwork.config.d/mfbase/plugins/
service metwork start mfbase
su  - mfbase
plugins.list
psql -U plugin_foo -p 7432 -h localhost
matthieumarrast commented 7 months ago

Analysis

During mfbase initialization, a - (pre)Starting mfbase services... is done with command mfbase.start NOINIT During this start the plugin is installed whereas the metwork database is created afterward.

If we look in the mfbase.start script we notice that when NOINIT is provided the plugins must not be installed. It has been forgotten for mfbase.

Solution

Update mfbase.start to not install plugins when NOINIT is provided:

if test ${RES} -eq 0 && test "${NOINIT}" = "0"; then
    _install_or_update_configured_plugins.py
fi