PostHog / posthog

🦔 PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
https://posthog.com
Other
21.23k stars 1.26k forks source link

Issue with PostHog Upgrade Script #20525

Open kkenacton opened 7 months ago

kkenacton commented 7 months ago

We are encountering an issue with the PostHog upgrade script while attempting to update our self-hosted version. The upgrade script we used is:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/upgrade-hobby)"

Error Message:

During the execution of the script, we received the following error message:

Error response from daemon: invalid reference format

Steps to Reproduce:

Expected Behavior:

We expected the upgrade script to execute successfully and update our self-hosted version of PostHog without encountering any errors.

Could you please provide guidance on how we can successfully update our self-hosted version of PostHog? Any assistance or insights you can offer to resolve this issue would be greatly appreciated.

belmirocneto commented 7 months ago

I'm having the same problem. Appears to be something in the docker-compose pull command but don't figure why yet.

kkenacton commented 7 months ago

Hello,

I've managed to resolve the issue. Firstly, in the update script, I commented out the code before "docker-compose pull". Then, in the Docker Compose file, I replaced the image name with "image: posthog/posthog:latest", which was previously set as "image: :latest-release". Finally, I ran the script from "docker-compose pull".

After completing these steps, the script executed without any errors, and PostHog is now up and running with the latest version.

If you have any further questions or encounter any issues, feel free to let me know.

peh commented 7 months ago

@kkenacton solution is working but will break again in the future the issue that your environment does not have all variables set as it should. if you simply run

export REGISTRY_URL=posthog/posthog
export POSTHOG_APP_TAG=latest # probably latest-release is safer here

the script fails at a later stage (missing env variables for DATABASE_URL and name). looking at the deploy-hobby script there is a lot of environment variables set that are never set in the upgrade script.

so either the documentation is missing some crucial information, or the upgrade script is broken completely?

saulonunesdev commented 6 months ago

adding the values to .env worked for me, but then later I got 2 errors

Checking if async migrations are up to date
Traceback (most recent call last):
  File "/python-runtime/django/core/management/__init__.py", line 237, in fetch_command
    app_name = commands[subcommand]
KeyError: 'run_async_migrations'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/python-runtime/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/python-runtime/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/python-runtime/django/core/management/__init__.py", line 244, in fetch_command
    settings.INSTALLED_APPS
  File "/python-runtime/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/python-runtime/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/python-runtime/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/code/posthog/settings/__init__.py", line 25, in <module>
    from posthog.settings.celery import *
  File "/code/posthog/settings/celery.py", line 6, in <module>
    from posthog.settings.data_stores import REDIS_URL
  File "/code/posthog/settings/data_stores.py", line 77, in <module>
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: The environment vars "DATABASE_URL" or "POSTHOG_DB_NAME" are absolutely required to run this software

 â ¿ Container ubuntu-temporal-django-worker-1  Starting                                                                                                                                                      8.5s
 â ¿ Container ubuntu-plugins-1                 Started                                                                                                                                                       6.8s
 â ¿ Container ubuntu-caddy-1                   Started                                                                                                                                                       7.3s
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/compose/temporal-django-worker": stat /compose/temporal-django-worker: no such file or directory: unknown

I even tried the proposed solution here https://github.com/PostHog/posthog/issues/16169#issuecomment-1625351591 but didn't worked. Also adding the values manually for REDIS and DABASE_URL didn't work either.

any help is much appreciated, tx

jormaj commented 1 month ago

Hello,

I've managed to resolve the issue. Firstly, in the update script, I commented out the code before "docker-compose pull". Then, in the Docker Compose file, I replaced the image name with "image: posthog/posthog:latest", which was previously set as "image: :latest-release". Finally, I ran the script from "docker-compose pull".

After completing these steps, the script executed without any errors, and PostHog is now up and running with the latest version.

If you have any further questions or encounter any issues, feel free to let me know.

I tried this and the upgrade seemed to run fine, but then actual startup of the posthog container failed with the following error:

error: column posthog_pluginconfig.deleted does not exist

Not sure if this was specific to my install, but redeployed using the install script after this.. figured that was faster than trying to debug the issue :/