Page 1 of 2

[RESOLVED] Update to Discovery: Error logging into the console

Published: August 11, 2022 - 10:18
by jlatieule
Hello,


I've made four attempts, each with the same result. Every time, I'm forced to restore the server to the previous snapshot.
I'm trying to update from the latest Community version to Discovery 2.2.

Everything seems to work correctly, but after the update, it's no longer possible to authenticate on the console with the "admin" account.
I've tried several combinations:
- Post-configuration: Password update or No update (to keep the old one)
- Console update: with complete uninstallation or everything automated by the Windows installer.

WAPT is installed on Debian 10.

How can I regain control of the console?

Sincerely

Re: Update to Discovery: Error logging into the console

Published: August 11, 2022 - 2:23 PM
by jlatieule
I just tried importing the PostgreSQL database from the old server I'm trying to upgrade with a fresh installation.

Simply by loading the database with the same version of WAPT, it's no longer possible to connect to the new installation.

The problem likely lies there.

Re: Update to Discovery: Error logging into the console

Published: August 12, 2022 - 4:00 PM
by sfonteneau
Can you provide the version number of the database available on the web interface?

You can try a:

Code: Select all

sudo -u wapt /opt/wapt/waptpython.sh

Code: Select all

from waptserver.config import load_config
from waptserver.model import *
conf = waptserver.config.load_config('/opt/wapt/conf/waptserver.ini')
load_db_config(conf)
create_default_users(conf)
quit()
This allows you to recreate the admin account with the ACLs if it is not an admin account

Re: Update to Discovery: Error logging into the console

Published: August 12, 2022 - 4:36 PM
by jlatieule
Hi Simon, glad to see you here after all these years in ICT ;-)

Here is the requested feedback:
Base status: OK (2.2.5.2)

And after running the Python code, I get this error message:

Code: Select all

administrateur@serv-wapt:~$ sudo -u wapt /opt/wapt/waptpython.sh
[sudo] password for administrateur: 
Python 3.8.13 (default, May 23 2022, 11:25:12) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from waptserver.config import load_config
>>> from waptserver.model import *
>>> conf = waptserver.config.load_config('/opt/wapt/conf/waptserver.ini')
>>> load_db_config(conf)
<playhouse.pool.PooledPostgresqlExtDatabase object at 0x7f7bb20678e0>
>>> create_default_users(conf)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/wapt/waptserver/model.py", line 1246, in create_default_users
    if created or not admin_acls.acls.get('admin'):
AttributeError: 'NoneType' object has no attribute 'get'
>>> quit()
So I'm still having this authentication problem on the console ;-/

Re: Update to Discovery: Error logging into the console

Published: August 17, 2022 - 10:15
by sfonteneau
jlatieule wrote: August 12, 2022 - 4:36 PM Hi Simon, glad to see you here after all these years of ICT ;-)
Still here ;)

Okay, the database is stuck at 2.2.5.2

The problem therefore lies between the switch from 2.2.5.2 to 2.2.6.0

In the latest version of wapt, the base is 2.2.6.1


The code is ugly here because on line 3083 of model.py we have:

Code: Select all

    
    finally:
        pass
 
So we're unlikely to see the mistake...

You can replace the code in model.py on line 3083 with:

Code: Select all

    except:
        import traceback
        print(traceback.format_exc())

    finally:
        pass



then you can try a:

Code: Select all

sudo -u wapt /opt/wapt/waptpython.sh

Code: Select all

from waptserver.config import load_config
from waptserver.model import *
conf = waptserver.config.load_config('/opt/wapt/conf/waptserver.ini')
load_db_config(conf)
upgrade_db_structure(conf)
At least we'll see something

Also, what version of PostgreSQL do you have installed?

Re: Update to Discovery: Error logging into the console

Published: August 17, 2022 - 12:42
by jlatieule
Indeed, we can see more information.

Regarding the PostgreSQL version:
postgres (PostgreSQL) 11.17 (Debian 11.17-0+deb10u1)
and the return of the upgrade:

Code: Select all

>>> from waptserver.config import load_config
>>> from waptserver.model import *
>>> conf = waptserver.config.load_config('/opt/wapt/conf/waptserver.ini')
>>> load_db_config(conf)
<playhouse.pool.PooledPostgresqlExtDatabase object at 0x7fc32e401940>
>>> upgrade_db_structure(conf)
Traceback (most recent call last):
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3144, in execute_sql
    cursor.execute(sql, params or ())
psycopg2.errors.UndefinedFunction: function is_valid_jsonb(jsonb) does not exist
LINE 1: ...set value = to_jsonb(value::text)::text where not is_valid_j...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/wapt/waptserver/model.py", line 2987, in upgrade_db_structure
    wapt_db.execute_sql("""update hostauditdata set value = to_jsonb(value::text)::text where not is_valid_jsonb(value) and not is_valid_jsonb(replace(value,'''','"'));""")
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3151, in execute_sql
    self.commit()
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 2917, in __exit__
    reraise(new_type, new_type(exc_value, *exc_args), traceback)
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 190, in reraise
    raise value.with_traceback(tb)
  File "/opt/wapt/lib/python3.8/site-packages/peewee.py", line 3144, in execute_sql
    cursor.execute(sql, params or ())
peewee.ProgrammingError: function is_valid_jsonb(jsonb) does not exist
LINE 1: ...set value = to_jsonb(value::text)::text where not is_valid_j...
                                                             ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Re: Update to Discovery: Error logging into the console

Published: August 17, 2022 - 3:36 PM
by sfonteneau
Okay, we've identified the problem.

I'll see about pushing a nightly build today.

Re: Update to Discovery: Error logging into the console

Published: August 17, 2022 - 3:44 PM
by jlatieule
Cool, I managed to report a bug

. Do I need to restore version 1.8.2 and redo the update, or will it be a command I need to run?

Re: Update to Discovery: Error logging into the console

Published: August 18, 2022 - 6:01 PM
by sfonteneau
Normally, just an upgrade will suffice; the database will migrate correctly with the new code.

Could you try this one?

https://wapt.tranquil.it/wapt/nightly/w ... 5-3fd94bd1

Simon

Re: [SOLVED] Update to Discovery: Error logging into the console

Published: August 22, 2022 - 5:16 PM
by jlatieule
Thanks Simon,


I searched for the Debian repository address from https://wapt.tranquil.it/Debian/ but I'm completely out of touch on this subject.

How can I install the nightly build you suggested?