linuxserver / docker-netbox

GNU General Public License v3.0
79 stars 17 forks source link

Migrate from 3.1.11 to 3.2 #33

Closed focheur91300 closed 2 years ago

focheur91300 commented 2 years ago

linuxserver.io


Expected Behavior

auto migrate from 3.1.11 to 3.2

Current Behavior

Migrate raise error

Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, wireless
Running migrations:
Traceback (most recent call last):
  File "/app/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 290, in handle
    post_migrate_state = executor.migrate(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 131, in migrate
    state = self._migrate_all_forwards(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
    state = self.apply_migration(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/lib/python3.9/site-packages/django/db/migrations/migration.py", line 131, in apply
    operation.database_forwards(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/app/netbox/netbox/dcim/migrations/0145_site_remove_dep0.recated_fields.py", line 24, in check_legacy_data
    raise DataError(
django.db.utils.DataError: Unable to proceed with deleting contact fields from Site model: Found 1 sites with legacy contact data. Please ensure all legacy site contact data has been migrated to contact objects before proceeding. Or, set the NETBOX_DELETE_LEGACY_DATA environment variable to bypass this safeguard and delete all legacy site contact data.
  Applying dcim.0145_site_remove_deprecated_fields...[cont-init.d] 50-config: exited 0.

Steps to Reproduce

  1. docker run netbox 3.1.11
  2. only change lscr.io/linuxserver/netbox:3.1.11 to lscr.io/linuxserver/netbox:3.2.0

Environment

OS: debian 11.3 CPU architecture: x86_64 How docker service was installed: user docker compose file

Command used to create docker container (run/create/compose/screenshot)

Docker logs

root@srv-docker:~# docker logs netbox
[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-envfile: executing...
[cont-init.d] 01-envfile: exited 0.
[cont-init.d] 01-migrations: executing...
[migrations] started
[migrations] no migrations found
[cont-init.d] 01-migrations: exited 0.
[cont-init.d] 02-tamper-check: executing...
[cont-init.d] 02-tamper-check: exited 0.
[cont-init.d] 10-adduser: executing...

-------------------------------------
          _         ()
         | |  ___   _    __
         | | / __| | |  /  \
         | | \__ \ | | | () |
         |_| |___/ |_|  \__/

Brought to you by linuxserver.io
-------------------------------------

To support LSIO projects visit:
https://www.linuxserver.io/donate/
-------------------------------------
GID/UID
-------------------------------------

User uid:    1000
User gid:    1000
-------------------------------------

[cont-init.d] 10-adduser: exited 0.
[cont-init.d] 50-config: executing...
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, django_rq, extras, ipam, sessions, social_django, taggit, tenancy, users, virtualization, wireless
Running migrations:
Traceback (most recent call last):
  File "/app/netbox/netbox/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python3.9/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 414, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 460, in execute
    output = self.handle(*args, **options)
  File "/usr/lib/python3.9/site-packages/django/core/management/base.py", line 98, in wrapped
    res = handle_func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/django/core/management/commands/migrate.py", line 290, in handle
    post_migrate_state = executor.migrate(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 131, in migrate
    state = self._migrate_all_forwards(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 163, in _migrate_all_forwards
    state = self.apply_migration(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/executor.py", line 248, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/lib/python3.9/site-packages/django/db/migrations/migration.py", line 131, in apply
    operation.database_forwards(
  File "/usr/lib/python3.9/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/app/netbox/netbox/dcim/migrations/0145_site_remove_deprecated_fields.py", line 24, in check_legacy_data
    raise DataError(
django.db.utils.DataError: Unable to proceed with deleting contact fields from Site model: Found 1 sites with legacy contact data. Please ensure all legacy site contact data has been migrated to contact objects before proceeding. Or, set the NETBOX_DELETE_LEGACY_DATA environment variable to bypass this safeguard and delete all legacy site contact data.
  Applying dcim.0145_site_remove_deprecated_fields...[cont-init.d] 50-config: exited 0.
[cont-init.d] 90-custom-folders: executing...
[cont-init.d] 90-custom-folders: exited 0.
[cont-init.d] 99-custom-files: executing...
[custom-init] no custom files found exiting...
[cont-init.d] 99-custom-files: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[uWSGI] getting INI configuration from uwsgi.ini
[uwsgi-static] added mapping for /static => static
*** Starting uWSGI 2.0.19.1 (64bit) on [Thu Apr  7 22:09:28 2022] ***
compiled with version: 10.3.1 20210921 on 05 April 2021 18:18:03
os: Linux-5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17)
nodename: netbox
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 8
current working directory: /app/netbox/netbox
detected binary path: /usr/sbin/uwsgi
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
building mime-types dictionary from file /etc/mime.types...1311 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :8000 fd 3
Python version: 3.9.7 (default, Nov 24 2021, 21:15:59)  [GCC 10.3.1 20211027]
Python main interpreter initialized at 0x7fbbe51c7bf0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145840 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
running "exec:/usr/bin/python3 ./manage.py collectstatic --noinput" (pre app)...

239 static files copied to '/app/netbox/netbox/static'.
running "exec:/usr/bin/python3 ./manage.py remove_stale_contenttypes --no-input" (pre app)...
running "exec:/usr/bin/python3 ./manage.py clearsessions" (pre app)...
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x7fbbe51c7bf0 pid: 315 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 315)
spawned uWSGI worker 1 (pid: 333, cores: 1)
[uwsgi-daemons] spawning "/usr/bin/python3 ./manage.py rqworker" (uid: 1000 gid: 1000)
[pid: 333|app: 0|req: 1/1] 10.0.3.120 () {64 vars in 1299 bytes} [Thu Apr  7 20:09:41 2022] GET / => generated 2343 bytes in 1768 msecs (HTTP/1.0 500) 7 headers in 255 bytes (1 switches on core 0)
github-actions[bot] commented 2 years ago

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

carroarmato0 commented 2 years ago

I had a similar issue and managed to fix it by starting the container with -e NETBOX_DELETE_LEGACY_DATA=true. Probably a good idea to take a backup of the database before doing so.

focheur91300 commented 2 years ago

Thank you it worked.