升级3.7之后启动出错,无法通过web访问

说明(发布前可手动删除说明内容):

  • 发布话题前请确认好标题与标签、你已经看过了[JumpServer试运行版规V1];
  • 如有必要请附带以下信息:JumpServer 版本、运行方式(安装包运行 or 源码运行 )、浏览器版本、更多描述或截图信息。

急问!! 从3.6.4版升级到3.7版之后无法正常使用,看上去是数据表结构没有修改成功,请问应该如何修复?

** docker 容器状态 **

76ab7b783ffe   jumpserver/core:v3.7.0     "./entrypoint.sh sta…"   30 minutes ago   Up 29 minutes (healthy)            8080/tcp                                                                                                               jms_celery
a625227eb1c9   jumpserver/web:v3.7.0      "/docker-entrypoint.…"   30 minutes ago   Up 29 minutes (healthy)            0.0.0.0:80->80/tcp, :::80->80/tcp                                                                                      jms_web
4eec96152922   jumpserver/lion:v3.7.0     "./entrypoint.sh"        30 minutes ago   Up 30 minutes (unhealthy)          4822/tcp, 8081/tcp                                                                                                     jms_lion
25465e6fd8eb   jumpserver/chen:v3.7.0     "./entrypoint.sh"        30 minutes ago   Up 15 seconds (health: starting)   8082/tcp                                                                                                               jms_chen
1c49dd92ba4b   jumpserver/core:v3.7.0     "./entrypoint.sh sta…"   30 minutes ago   Up 3 seconds (health: starting)    8080/tcp                                                                                                               jms_core
6e0204d97af0   jumpserver/magnus:v3.7.0   "./entrypoint.sh"        30 minutes ago   Up 43 seconds (unhealthy)          0.0.0.0:33061-33062->33061-33062/tcp, :::33061-33062->33061-33062/tcp, 0.0.0.0:63790->63790/tcp, :::63790->63790/tcp   jms_magnus
14afd2c0a42c   jumpserver/kael:v3.7.0     "./entrypoint.sh"        30 minutes ago   Up 29 minutes (unhealthy)          8083/tcp                                                                                                               jms_kael
85c9076182c6   jumpserver/koko:v3.7.0     "./entrypoint.sh"        30 minutes ago   Up 30 minutes (unhealthy)          0.0.0.0:2222->2222/tcp, :::2222->2222/tcp, 5000/tcp                                                                    jms_koko
2c642cde95c2   jumpserver/redis:6.2       "docker-entrypoint.s…"   13 days ago      Up 39 minutes (healthy)            6379/tcp                                                                                                               jms_redis
ca2c700df518   jumpserver/mariadb:10.6    "docker-entrypoint.s…"   13 days ago      Up 37 minutes (healthy)            3306/tcp                                                                                                               jms_mysql

** Web 前端报错 **

<html> <head><title>502 Bad Gateway</title></head> <body> <center><h1>502 Bad Gateway</h1></center> <hr><center>nginx</center> </body> </html> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

** core 错误日志 **

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
MySQLdb.OperationalError: (1050, "Table 'authentication_passkey' already exists")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/jumpserver/jms", line 88, in perform_db_migrate
    management.call_command('migrate')
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 198, in call_command
    return command.execute(*args, **defaults)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 96, in wrapped
    res = handle_func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/commands/migrate.py", line 349, in handle
    post_migrate_state = executor.migrate(
                         ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
            ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/migration.py", line 130, in apply
    operation.database_forwards(
  File "/usr/local/lib/python3.11/site-packages/django/db/migrations/operations/models.py", line 96, in database_forwards
    schema_editor.create_model(model)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 447, in create_model
    self.execute(sql, params or None)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/base/schema.py", line 199, in execute
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute
    return self.cursor.execute(sql)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/mysql/base.py", line 75, in execute
    return self.cursor.execute(query, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 179, in execute
    res = self._query(mogrified_query)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/cursors.py", line 330, in _query
    db.query(q)
  File "/usr/local/lib/python3.11/site-packages/MySQLdb/connections.py", line 255, in query
    _mysql.connection.query(self, query)
django.db.utils.OperationalError: (1050, "Table 'authentication_passkey' already exists")
ALLOWED_HOSTS: 
  - jms.cx-online.net
  - core:8080
  - 127.0.0.1
  - 127.0.0.1:8080
  - 127.0.0.1:80
  - localhost:8080
  - localhost:80
  - core:8080
  - core:80
ALLOWED_HOSTS: 
  - jms.cx-online.net
  - core:8080
  - 127.0.0.1
  - 127.0.0.1:8080
  - 127.0.0.1:80
  - localhost:8080
  - localhost:80
  - core:8080
  - core:80
2023-09-27 09:43:51 Check database connection: 0
2023-09-27 09:43:51 
def sync_secret_to_vault():
    return 1

System check identified no issues (0 silenced).
2023-09-27 09:43:52 Database connect success
2023-09-27 09:43:52 Collect static files
2023-09-27 09:43:52 Collect static files done
2023-09-27 09:43:52 Check database structure change ...
2023-09-27 09:43:52 Migrate model change to database ...
Operations to perform:
  Apply all migrations: accounts, acls, admin, applications, assets, audits, auth, authentication, captcha, common, contenttypes, django_cas_ng, django_celery_beat, notifications, ops, orgs, perms, rbac, sessions, settings, terminal, tickets, users
Running migrations:
  Applying authentication.0022_passkey...2023-09-27 09:43:53 Perform migrate failed, exit

先回滚到3.6吧,3.7目前还有一些问题的

请问怎么回滚?直接运行3.6的在线升级包吗?

1.确认当前数据库的字符集和校对集,然后删库
2.新建一个jumpserver库,然后把之前升级的时候,自动备份的sql文件导入
3.启动3.6版本服务

好的,谢谢你啦!看来要等下一个版本再升级了。
之前我都是等大版本迭代了两个小版本再升级的,这次急着升级是被sftp修改文件内容会自动新建一个新文件的问题搞烦了 :joy:
建议大家在升级前做好备份准备,最好做快照,省事