Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent Internal Server Error after fresh Digital Ocean droplet deployment v 0.16.8 #8754

Open
1 of 7 tasks
levins-law opened this issue Dec 23, 2024 · 8 comments
Open
1 of 7 tasks
Labels
question This is a question setup Relates to the InvenTree setup / installation process

Comments

@levins-law
Copy link

levins-law commented Dec 23, 2024

Important

This was resolved thanks to feedback herein. These were the steps I took to fix it for me.

  1. Ran the inventree command on SSH terminal
  2. Looked at the Usage list and noticed there's one called inventree config:set VAR=VALUE
  3. Ran the command inventree config:set INVENTREE_SITE_URL=http://162.243.234.188 (replace the URL with your own URL, unclear if this actually fixed the problem, or if the other steps below were the blockers)
  4. Still unable to access the web login
  5. Went to the very last line of [Breaking] Samesite Cookie Fix #8269 opening post and saw

Users in this predicament should change the value of INVENTREE_COOKIE_SAMESITE from None to False to disable the checks.

  1. Went back to SSH console and tried command inventree config:set INVENTREE_COOKIE_SAMESITE=False
  2. Ran command inventree restart
  3. Still unable to access the website
  4. Ran command inventree run invoke update (I may have dealt with the missing invoke package earlier but you may get a prompt to just do that if you haven't already- and thanks to StormTrooper for the extra step.
  5. Ran command inventree restart
  6. Powered down the DO droplet, then on again.
  7. Was able to access the web login page 👍

Deployment Method

  • Installer
  • Docker Development
  • Docker Production
  • Bare metal Development
  • Bare metal Production
  • Digital Ocean image
  • Other (please provide a link Steps to Reproduce

Describe the problem*

I have tried several iterations of deploying a fresh DO droplet. Each time I am now prompted with the following error when I try to access Inventree:

Image

Image

Steps to Reproduce

  1. Click on the Deploy to Digital Icon logo.
  2. Click on the Create Inventree Droplet icon.
  3. Create a Basic type droplet, CPU type Regular
  4. Create Droplet
  5. Go to project, click on Get Started

Image

  1. Click on Quick Access to Inventree
    Image

  2. The usual login prompt is missing, goes straight to server error page

Image

Relevant log output

Details

root@inventree0168onubuntu2004-s-1vcpu-1gb-nyc2-01:~# inventree logs
==> /var/log/inventree/setup_2024-11-14_22_22_39.log <==
==> /var/log/inventree/setup_2024-12-23_22_37_42.log <==
# POI01| Importing functions
# POI01| Functions imported
# POI03| Setting base environment variables
# POI03| Using existing config file: /etc/inventree/config.yaml
# POI03| Installing requirements
# POI03| Installed requirements
# POI03| Collected environment variables:
# POI03|    INVENTREE_MEDIA_ROOT=/opt/inventree/data/media
# POI03|    INVENTREE_STATIC_ROOT=/opt/inventree/data/static
# POI03|    INVENTREE_BACKUP_DIR=/opt/inventree/data/backup
# POI03|    INVENTREE_PLUGINS_ENABLED=true
# POI03|    INVENTREE_PLUGIN_FILE=/etc/inventree/plugins.txt
# POI03|    INVENTREE_SECRET_KEY_FILE=/etc/inventree/secret_key.txt
# POI03|    INVENTREE_DB_ENGINE=postgresql
# POI03|    INVENTREE_DB_NAME=inventree
# POI03|    INVENTREE_DB_USER=inventree
# POI03|    INVENTREE_DB_HOST=localhost
# POI03|    INVENTREE_DB_PORT=5432
# POI04| Running in docker: no
# POI05| Using init command: systemctl
# POI06| Getting the IP address of the server via web service
# POI06| IP address is 162.243.234.188
# POI07| Python environment already present
# POI07| Found earlier used version: /opt/inventree/env/bin/python
# POI07| Using python command: /opt/inventree/env/bin/python
# POI08| Checking if update checks are needed
# POI08| Running upgrade
# POI08| Old version is: 0.16.8-1730959683.f23d4053.focal | 16 - updating to 0.17.0-1734433548.156c3cc9.focal | 16
# POI09| Setting up python environment
Requirement already satisfied: invoke in ./env/lib/python3.9/site-packages (2.2.0)
Requirement already satisfied: wheel in ./env/lib/python3.9/site-packages (0.45.0)
# POI09| Loading extra packages from INSTALLER_EXTRA
# POI09| Installing extra pip packages
Requirement already satisfied: psycopg2-binary in ./env/lib/python3.9/site-packages (2.9.10)
# POI09| Stopping nginx
# POI09| Stopped nginx
# POI09| Setting up nginx to /etc/nginx/sites-enabled/inventree.conf
# POI09| Starting nginx
# POI09| Started nginx
# POI09| (Re)creating init scripts
Nothing to do.
Nothing to do.
# POI09| Enabling InvenTree on boot
# POI09| Enabled InvenTree on boot
# POI10| Admin data already exists - skipping
# POI11| Stopping InvenTree
# POI11| Stopped InvenTree
# POI12| Updating InvenTree
Requirement already satisfied: uv in ./env/lib/python3.9/site-packages (0.5.2)
Requirement already satisfied: wheel in ./env/lib/python3.9/site-packages (0.45.0)
Using Python 3.9.5 environment at: env
Resolved 144 packages in 1.19s
Prepared 77 packages in 6.80s
Uninstalled 68 packages in 312ms
Installed 77 packages in 293ms
 - async-timeout==4.0.3
 + async-timeout==5.0.1
 - attrs==23.2.0
 + attrs==24.2.0
 - babel==2.15.0
 + babel==2.16.0
 - bleach==6.1.0
 + bleach==6.2.0
 - cffi==1.16.0
 + cffi==1.17.1
 - cryptography==42.0.8
 + cryptography==43.0.3
 - deprecated==1.2.14
 + deprecated==1.2.15
 - diff-match-patch==20230430
 + diff-match-patch==20241021
 - dj-rest-auth==6.0.0
 + dj-rest-auth==7.0.0
 - django==4.2.15
 + django==4.2.17
 - django-allauth==0.63.3
 + django-allauth==65.2.0
 - django-cleanup==8.1.0
 + django-cleanup==9.0.0
 - django-cors-headers==4.4.0
 + django-cors-headers==4.6.0
 - django-dbbackup==4.1.0
 + django-dbbackup==4.2.1
 - django-filter==24.2
 + django-filter==24.3
 + django-ipware==7.0.1
 - django-otp==1.5.0
 + django-otp==1.5.4
 - django-q2==1.6.2
 + django-q2==1.7.4
 + django-structlog==8.1.0
 - django-taggit==5.0.1
 + django-taggit==6.1.0
 - dulwich==0.22.1
 + dulwich==0.22.6
 - et-xmlfile==1.1.0
 + et-xmlfile==2.0.0
 + flexcache==0.3
 + flexparser==0.4
 - fonttools==4.53.0
 + fonttools==4.55.0
 - googleapis-common-protos==1.63.2
 + googleapis-common-protos==1.66.0
 - grpcio==1.64.1
 + grpcio==1.68.0
 - gunicorn==22.0.0
 + gunicorn==23.0.0
 - icalendar==5.0.13
 + icalendar==6.1.0
 - importlib-metadata==7.1.0
 + importlib-metadata==8.5.0
 - isodate==0.6.1
 + isodate==0.7.2
 - jsonschema==4.22.0
 + jsonschema==4.23.0
 - jsonschema-specifications==2023.12.1
 + jsonschema-specifications==2024.10.1
 - lxml==5.2.2
 + lxml==5.3.0
 - markdown==3.6
 + markdown==3.7
 - markupsafe==2.1.5
 + markupsafe==3.0.2
 - openpyxl==3.1.4
 + openpyxl==3.1.5
 - opentelemetry-api==1.25.0
 + opentelemetry-api==1.28.2
 - opentelemetry-exporter-otlp==1.25.0
 + opentelemetry-exporter-otlp==1.28.2
 - opentelemetry-exporter-otlp-proto-common==1.25.0
 + opentelemetry-exporter-otlp-proto-common==1.28.2
 - opentelemetry-exporter-otlp-proto-grpc==1.25.0
 + opentelemetry-exporter-otlp-proto-grpc==1.28.2
 - opentelemetry-exporter-otlp-proto-http==1.25.0
 + opentelemetry-exporter-otlp-proto-http==1.28.2
 - opentelemetry-instrumentation==0.46b0
 + opentelemetry-instrumentation==0.49b2
 - opentelemetry-instrumentation-django==0.46b0
 + opentelemetry-instrumentation-django==0.49b2
 - opentelemetry-instrumentation-redis==0.46b0
 + opentelemetry-instrumentation-redis==0.49b2
 - opentelemetry-instrumentation-requests==0.46b0
 + opentelemetry-instrumentation-requests==0.49b2
 - opentelemetry-instrumentation-wsgi==0.46b0
 + opentelemetry-instrumentation-wsgi==0.49b2
 - opentelemetry-proto==1.25.0
 + opentelemetry-proto==1.28.2
 - opentelemetry-sdk==1.25.0
 + opentelemetry-sdk==1.28.2
 - opentelemetry-semantic-conventions==0.46b0
 + opentelemetry-semantic-conventions==0.49b2
 - opentelemetry-util-http==0.46b0
 + opentelemetry-util-http==0.49b2
 - packaging==24.1
 + packaging==24.2
 - pillow==10.3.0
 + pillow==11.0.0
 - pint==0.21
 + pint==0.24.4
 - pip-licenses==4.4.0
 + pip-licenses==5.0.0
 + platformdirs==4.3.6
 - prettytable==3.10.0
 + prettytable==3.12.0
 - protobuf==4.25.3
 + protobuf==5.28.3
 - pyjwt==2.8.0
 + pyjwt==2.10.1
 - pyphen==0.15.0
 + pyphen==0.17.0
 + python-ipware==3.0.0
 - pytz==2024.1
 + pytz==2024.2
 - qrcode==7.4.2
 + qrcode==8.0
 - rapidfuzz==3.9.3
 + rapidfuzz==3.10.1
 - redis==5.0.7
 + redis==5.2.0
 - rpds-py==0.18.1
 + rpds-py==0.21.0
 - sentry-sdk==2.8.0
 + sentry-sdk==2.19.0
 - sqlparse==0.5.0
 + sqlparse==0.5.2
 + structlog==24.4.0
 - tinycss2==1.2.1
 + tinycss2==1.4.0
 + tomli==2.1.0
 + tzdata==2024.2
 - weasyprint==61.2
 + weasyprint==62.3
 - whitenoise==6.7.0
 + whitenoise==6.8.2
 - wrapt==1.16.0
 + wrapt==1.17.0
 - zipp==3.19.2
 + zipp==3.21.0
 - zopfli==0.2.3
 + zopfli==0.2.3.post1
warning: Requirements file `/etc/inventree/plugins.txt` does not contain any dependencies
Using Python 3.9.5 environment at: env
Audited in 6ms
2024-12-23 22:38:35,268 ERROR {'event': 'No CSRF_TRUSTED_ORIGINS specified. Please provide a list of trusted origins, or specify INVENTREE_SITE_URL', 'timestamp': '2024-12-23T22:38:35.268220Z', 'logger': 'inventree', 'level': 'error'}
# POI12| u | Updating InvenTree installation...
# POI12| u | Installing required python packages from '/opt/inventree/src/backend/requirements.txt'
# POI12| u | Collecting uv
# POI12| u |   Downloading uv-0.5.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.0 MB)
# POI12| u | Collecting setuptools
# POI12| u |   Downloading setuptools-75.6.0-py3-none-any.whl (1.2 MB)
# POI12| u | Installing collected packages: uv, setuptools
# POI12| u |   Attempting uninstall: uv
# POI12| u |     Found existing installation: uv 0.5.2
# POI12| u |     Uninstalling uv-0.5.2:
# POI12| u |       Successfully uninstalled uv-0.5.2
# POI12| u |   Attempting uninstall: setuptools
# POI12| u |     Found existing installation: setuptools 72.1.0
# POI12| u |     Uninstalling setuptools-72.1.0:
# POI12| u |       Successfully uninstalled setuptools-72.1.0
# POI12| u | Successfully installed setuptools-75.6.0 uv-0.5.11
# POI12| u | Installing plugin packages from '/etc/inventree/plugins.txt'
# POI12| u | Requirement already satisfied: uv in ./env/lib/python3.9/site-packages (0.5.11)
# POI12| u | Python version 3.9.5 - /opt/inventree/env/bin/python3
# POI12| u | ERROR: InvenTree command failed: 'python3 manage.py collectplugins'
# POI12| u | - Refer to the error messages in the log above for more information
# POI12| Set permissions for data dir and media: /opt/inventree/data
# POI14| Site URL already set - skipping
# POI15| Starting InvenTree
# POI15| Started InvenTree
# POI16| Printing Final message
####################################################################################
This InvenTree install uses nginx, the settings for the webserver can be found in
/etc/nginx/sites-enabled/inventree.conf
Try opening InvenTree with either
http://localhost/ or http://162.243.234.188/

Admin user data:
   Email: 
   Username: 
   Password: 
####################################################################################
# POI17| Running postinstall script - done - Mon Dec 23 22:38:35 UTC 2024
No journal files were found.
Failed to add filter for units: No data available

@levins-law levins-law added question This is a question setup Relates to the InvenTree setup / installation process triage:not-checked Item was not checked by the core team labels Dec 23, 2024
@SchrodingersGat
Copy link
Member

@SchrodingersGat SchrodingersGat removed the triage:not-checked Item was not checked by the core team label Dec 23, 2024
@levins-law
Copy link
Author

@SchrodingersGat thank you for looking at this. This was not necessary the first time I deployed the droplet months ago. I am further confused because the URL and credentials are already provided in the message of the day when I open the SSH terminal.

Please understand that I have no experience with Linux and I can barely manage interacting with the console. I do my best to follow instructions and steps others have shared, but I don't really know what I am doing. Maybe Inventree just isn't for me.

I tried executing root@inventree0168onubuntu2004-s-1vcpu-1gb-nyc2-01:~# inventree config:set INVENTREE_SITE_URL=http://162.243.234.188 but I am still getting the internal server error.

Thanks again for your assistance.

@SchrodingersGat
Copy link
Member

This was not necessary the first time I deployed the droplet months ago.

As you can see in our 0.17.0 release notes under "breaking changes" (and also on the release blog) there is a change to the underlying django code which requires an adjustment to your setup.

Read the "Samesite Cookie Fix" section - and this PR for further information

@StormTrooper
Copy link

Had the same issue after upgrading a test server to 0.17.0.

Had to change the session cookie as per the above comment and reboot and then also had to rerun the update
inventree run invoke update

@levins-law
Copy link
Author

Thank you @StormTrooper, your steps enabled me to access the web login and use Inventree.

@SchrodingersGat thank you as well for your direction. May I constructively suggest that the actual steps needed could be more prominently highlighted in the documentation? I realize you are all volunteers and fielding this many support questions requires concise responses. We are lucky to have you investing in a passion project. For the sake of growing the community to users who are not devs or database experts consider that this experience was not the most welcoming for me.

I will post the steps to resolve explicitly in the initial post for the benefit of other future idiots (which will be me again I'm sure).

Thanks again for everything.

@SchrodingersGat
Copy link
Member

@levins-law absolutely. I can add it to the FAQ section, as this is a problem which seems to be impacting a few people. Anywhere in the install docs in particular that you think it should go?

@levins-law levins-law changed the title Persistent Internal Server Error after fresh Digital Ocean droplet deployment Persistent Internal Server Error after fresh Digital Ocean droplet deployment v 0.16.8 Dec 26, 2024
@levins-law
Copy link
Author

@SchrodingersGat if you want the perspective of a Digital Ocean user who is able to access the SSH terminal (which I was even thought I hit roadblocks after the build) then I would say you want it where mjmair's MoD appears on login.

A snippet from the message of the day:

On the server:

If one follows that link they end up here on the Bare Metal section of the install guide.

I think a section right near the Permission Denied Error heading would be appropriate in an [!IMPORTANT] box would help catch the attention of a droplet user.

IDK if this is solely a release-dependent thing that will become irrelevant on your next release, but it's a required setup step going forward I would think it's not release-dependent and needs to be listed as a required step.

More importantly, droplet users will tend to be lower skill (like me). I get the sense there's no impetus to document the DO droplet deployment by itself, but I would challenge that assumption. Perhaps on the website front end (screenshot below) it would be worth mentioning there are like three extra commands you will need to know.

I got into this predicament because I followed the documentation about updating Inventree which broke the hell out of my instance. To quote mjmair

please do not upgrade to a version that I have not supported

The documentation linked in the MoD is the installer heading, which is full of all sorts of things that perhaps one should not do. This is worth mentioning.

I really appreciate the call for feedback and hope it helps others.

Image

@SchrodingersGat
Copy link
Member

SchrodingersGat commented Dec 27, 2024

I have made some updates to the install / setup docs here: #8777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is a question setup Relates to the InvenTree setup / installation process
Projects
None yet
Development

No branches or pull requests

3 participants