GithubHelp home page GithubHelp logo

Comments (15)

fritterhoff avatar fritterhoff commented on July 20, 2024

Mhm. Ok seems like you were not running the latest privacyIDEA version 3.9.2? Did you run the schema migration ever before?

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

Mhm. Ok seems like you were not running the latest privacyIDEA version 3.9.2? Did you run the schema migration ever before?

No, this is not true. I had privacyIDEA==3.9.2. Once, but there were the mysqlclient package missing. But this shouldn't be a problem.

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

This are the logs for the first run:

(venv) edumfa@netz-mfa-db01:~$ edumfa-schema-upgrade eduMFA/migrations/
Can not import grpc modules.

               _       __  __ ______      
              | |     |  \/  |  ____/\    
       ___  __| |_   _| \  / | |__ /  \   
      / _ \/ _` | | | | |\/| |  __/ /\ \  
     |  __/ (_| | |_| | |  | | | / ____ \ 
      \___|\__,_|\__,_|_|  |_|_|/_/    \_          v1.4.0
        
Traceback (most recent call last):
  File "/opt/edumfa/venv/bin/edumfa-manage", line 1718, in <module>
    manager.run()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 417, in run
    result = self.handle(argv[0], argv[1:])
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 386, in handle
    res = handle(*args, **config)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/commands.py", line 216, in __call__
    return self.run(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 96, in wrapped
    f(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 371, in current
    command.current(config, verbose=verbose)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/command.py", line 625, in current
    script.run_env()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/edumfa/eduMFA/migrations/env.py", line 110, in <module>
    run_migrations_online()
  File "/opt/edumfa/eduMFA/migrations/env.py", line 86, in run_migrations_online
    engine = engine_from_config(
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 739, in engine_from_config
    return create_engine(url, **options)
  File "<string>", line 2, in create_engine
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 150, in dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
++ Stamping DB to 4f32a4e1bf33
Can not import grpc modules.

               _       __  __ ______      
              | |     |  \/  |  ____/\    
       ___  __| |_   _| \  / | |__ /  \   
      / _ \/ _` | | | | |\/| |  __/ /\ \  
     |  __/ (_| | |_| | |  | | | / ____ \ 
      \___|\__,_|\__,_|_|  |_|_|/_/    \_          v1.4.0
        
Traceback (most recent call last):
  File "/opt/edumfa/venv/bin/edumfa-manage", line 1718, in <module>
    manager.run()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 417, in run
    result = self.handle(argv[0], argv[1:])
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 386, in handle
    res = handle(*args, **config)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/commands.py", line 216, in __call__
    return self.run(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 96, in wrapped
    f(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 389, in stamp
    command.stamp(config, revision, sql=sql, tag=tag)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/command.py", line 690, in stamp
    script.run_env()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/edumfa/eduMFA/migrations/env.py", line 110, in <module>
    run_migrations_online()
  File "/opt/edumfa/eduMFA/migrations/env.py", line 86, in run_migrations_online
    engine = engine_from_config(
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 739, in engine_from_config
    return create_engine(url, **options)
  File "<string>", line 2, in create_engine
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 150, in dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'
++ Upgrading DB schema.
Can not import grpc modules.

               _       __  __ ______      
              | |     |  \/  |  ____/\    
       ___  __| |_   _| \  / | |__ /  \   
      / _ \/ _` | | | | |\/| |  __/ /\ \  
     |  __/ (_| | |_| | |  | | | / ____ \ 
      \___|\__,_|\__,_|_|  |_|_|/_/    \_          v1.4.0
        
Running online
Traceback (most recent call last):
  File "/opt/edumfa/venv/bin/edumfa-manage", line 1718, in <module>
    manager.run()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 417, in run
    result = self.handle(argv[0], argv[1:])
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/__init__.py", line 386, in handle
    res = handle(*args, **config)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_script/commands.py", line 216, in __call__
    return self.run(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 96, in wrapped
    f(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/flask_migrate/__init__.py", line 271, in upgrade
    command.upgrade(config, revision, sql=sql, tag=tag)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/command.py", line 403, in upgrade
    script.run_env()
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/script/base.py", line 583, in run_env
    util.load_python_file(self.dir, "env.py")
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 95, in load_python_file
    module = load_module_py(module_id, path)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/alembic/util/pyfiles.py", line 113, in load_module_py
    spec.loader.exec_module(module)  # type: ignore
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/edumfa/eduMFA/migrations/env.py", line 110, in <module>
    run_migrations_online()
  File "/opt/edumfa/eduMFA/migrations/env.py", line 86, in run_migrations_online
    engine = engine_from_config(
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 739, in engine_from_config
    return create_engine(url, **options)
  File "<string>", line 2, in create_engine
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/util/deprecations.py", line 375, in warned
    return fn(*args, **kwargs)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/engine/create.py", line 544, in create_engine
    dbapi = dialect_cls.dbapi(**dbapi_args)
  File "/opt/edumfa/venv/lib/python3.10/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 150, in dbapi
    return __import__("MySQLdb")
ModuleNotFoundError: No module named 'MySQLdb'

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

ModuleNotFoundError: No module named 'MySQLdb' is normally caused by a broken connection string. Are you using mysql+pymysql?

Would you mind to run a edumfa-manage db current -d edumfa/migrations? I'm wondering why the script tries to execute outdated migrations.

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

Yes, I fixed this already. See Issue #40.

If I run edumfa-manage db current -d edumfa/migrations is all fine:

Can not import grpc modules.

               _       __  __ ______      
              | |     |  \/  |  ____/\    
       ___  __| |_   _| \  / | |__ /  \   
      / _ \/ _` | | | | |\/| |  __/ /\ \  
     |  __/ (_| | |_| | |  | | | / ____ \ 
      \___|\__,_|\__,_|_|  |_|_|/_/    \_          v1.4.0
        

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

Mhm actually the output should tell you something else.
e.g.

edumfa@mfa01-dev:~$ edumfa-manage db current -d src/edumfa/migrations/
Can not import grpc modules.

          _       __  __ ______
         | |     |  \/  |  ____/\
  ___  __| |_   _| \  / | |__ /  \
 / _ \/ _` | | | | |\/| |  __/ /\ \
|  __/ (_| | |_| | |  | | | / ____ \
 \___|\__,_|\__,_|_|  |_|_|/_/    \_          v1.4.0

Running online
4a0aec37e7cf

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

No, the last two lines are missing :/

I tried the migration with my second node and get the error again with the missing edumfanode :(

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

There are a migration error pinode and edumfanode, if I rename the column to edumfanode, run the migration, rename back to pinode, run migration, and rename back, it works then. I think the order is broken.

But I don't have time today the go through all alembic scripts.

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

First of all thanks a lot for the bug report. Seems like the logging of the migrate scripts is broken ... :/

As a first quick workaround you could change the logging locally in the migrate package so it simply writes to console. Depending on your installation you should find a /usr/local/lib/python3.10/site-packages/flask_migrate/init.py (or maybe in your venv)

That should contain:

@wraps(f)
    def wrapped(*args, **kwargs):
        try:
            f(*args, **kwargs)
        except (CommandError, RuntimeError) as exc:
            log.error('Error: ' + str(exc))
            sys.exit(1)
    return wrapped

Would be great if you temporary replace the log.error with a print and try the edumfa-manage db current -d edumfa/migrations again.

I also will check why the logging does not print anything at all ...

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

Ok... so the logging configuration is broken - sorry for that.

You must change the alembic.ini to

[alembic]
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s

# set to 'true' to run the environment during
# the 'revision' command, regardless of autogenerate
# revision_environment = false


[loggers]
keys = root,sqlalchemy,alembic,flask_migrate

[handlers]
keys = console

[formatters]
keys = generic

[logger_root]
level = WARN
handlers = console
qualname =

[logger_flask_migrate]
handlers=console
qualname=flask_migrate
level=INFO


[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine

[logger_alembic]
level = INFO
handlers =
qualname = alembic

[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic

[formatter_generic]
format = %(levelname)-5.5s [%(name)s] %(message)s
datefmt = %H:%M:%S

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

The default alembic.ini gets changed with #41

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

Hi! Do you need further assistance?

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

Any update on this issue?

from edumfa.

ikreb7 avatar ikreb7 commented on July 20, 2024

Hey,

sorry I was ill. I updated to v2.0.1 and this helps. Thank you for your support!

from edumfa.

fritterhoff avatar fritterhoff commented on July 20, 2024

Great thanks for the feedback!

from edumfa.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.