metwork-framework/mfserv

Error with mfserv variable environment while updating to v2.2

matthieumarrast opened this issue · 0 comments

Problem

After an update from metwork v2.1 to metwork v2.2, I face an error while starting mfserv:

[root@7bdab52290d6 /]# su - mfserv
Last login: Fri May 24 09:16:16 UTC 2024 on pts/0

           __  __      ___          __        _
          |  \/  |    | \ \        / /       | |
          | \  / | ___| |\ \  /\  / /__  _ __| | __
          | |\/| |/ _ \ __\ \/  \/ / _ \| '__| |/ /
          | |  | |  __/ |_ \  /\  / (_) | |  |   <
          |_|  |_|\___|\__| \/  \/ \___/|_|  |_|\_\

Welcome on 7bdab52290d6 (7bdab52290d6, 172.17.0.2)
(module: MFSERV, version: 2.2.ci962.30f3f79)

 09:36:15 up 1 day, 15:14,  0 users,  load average: 0.65, 0.99, 1.55

[mfserv@7bdab52290d6:~] $ mfserv.start
- Updating internal plugin: welcome...                     [ ERROR ]           
ERROR: BashWrapperException exception with message: bad return code and debug: 
===== BASH COMMAND =======================
_plugins.postinstall welcome 2.2.ci962.30f3f79 1
===== BASH RETURN CODE ===================
1
===== BASH STDOUT ========================
Testing circus conf generation...
Ok
Testing nginx conf generation...
===== BASH STDERR ========================
Traceback (most recent call last):
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/envtpl.py", line 242, in _render
    output = template.render(**variables)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/jinja2/environment.py", line 1304, in render
    self.environment.handle_exception()
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/jinja2/environment.py", line 939, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 81, in top-level template code
jinja2.exceptions.UndefinedError: 'MFSERV_NGINX_PORT_IN_REDIRECT' is undefined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/metwork-mfserv-2.2/bin/__make_nginx_conf", line 95, in <module>
    content = envtpl.render_string(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/envtpl.py", line 176, in render_string
    return _render_string(string, variables, undefined,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/envtpl.py", line 190, in _render_string
    return _render(template_name, loader, variables,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/metwork-mfext-2.2/opt/python3/lib/python3.11/site-packages/envtpl.py", line 244, in _render
    raise Fatal(e)
envtpl.Fatal: 'MFSERV_NGINX_PORT_IN_REDIRECT' is undefined
***********************************
*****     STARTING MFSERV     *****
***********************************
  
- Checking circus conf generation...                       [ OK ]     
- Generating circus.ini                                    [ OK ]     
- Starting circus...                                       [ WARNING ] (already started)
- Waiting for circus daemon...                             [ OK ]  
- Collecting infos about plugins...                        [ OK ]              
- Checking nginx conf generation...                        [ ERROR ]  
=> the plugin foo seems to break nginx conf
   please check your plugin configuration and /home/mfserv/tmp/confdebug.cec7501b61916a417b002c5ca488e32a output
- Starting of conf_monitor                                 [ WARNING ] (already started)  
- Building crontab file...                                 [ OK ]     
- Installing crontab file...                               [ OK ]     
- Wait 2 sec...                                            [ OK ]  
- Checking circus status...                                [ OK ]     
- Checking crontab is not empty...                         [ OK ]     
- Checking nginx...                                        [ OK ]     
- Checking nginx uuid...                                   [ OK ]     
- Checking nginx worker zombies...                         [ OK ]     
- Checking conf_monitor...                                 [ OK ]     
- Checking plugin:autorestart...                           [ OK ]

Analysis

It seems the environment variable MFSERV_NGINX_PORT_IN_REDIRECT is missing while trying to build the nginx configuration file.

I feel that the environment variables for module are cached in /home/mfserv/tmp/ini_to_env_mfserv.cache
and while updating metwork, this file is used, it has not been removed or updated.

If I delete it then reload the environment, problem is solved.