langfuse / langfuse-k8s

Community-maintained Kubernetes config and Helm chart for Langfuse
https://langfuse.com
MIT License
44 stars 24 forks source link

Deploy self-hosted using docker or k8s fails #11

Closed Kompita closed 3 months ago

Kompita commented 3 months ago

Description

I have tried deploying self-hosted Langfuse both in kubernetes distri using helm chart and also with docker following the example in the doc (https://langfuse.com/docs/deployment/self-host#deploying-the-application) In both cases I get the same issue (see below) The documentation says the following: During the container startup, all database migrations will be applied automatically. I I don't really understand what this means

Error Prisma schema loaded from packages/shared/prisma/schema.prisma Datasource "db": PostgreSQL database "postgres", schema "public" at "XX.XX.XX.XX:5432"

204 migrations found in prisma/migrations

Applying database migrations failed. This is mostly caused by the database being unavailable. Exiting...

Versions

marcklingen commented 3 months ago

If you encounter the same error with both deployment options, the issue is most likely related to your database being inaccessible to the container running Langfuse. Could you please verify that you have properly configured access to the Azure Postgres Flexible Server (not an Azure expert, e.g. by allowlisting ports/ips/VPCs)?

Kompita commented 3 months ago

Thanks for your response. Yes, I can connect successfully through pgadmin and psql commnad from my local.

marcklingen commented 3 months ago

Can you connect from within the deployed docker container or the VM that you used to run the docker compose config? As this has never been an issue before, I'm just trying to help pinpoint the issue here.

Kompita commented 3 months ago

Using the helm chart, I have been able to see the startup of the container and the connection to the database. I'm going to try to reproduce it to send you the traces.

Thanks

Kompita commented 3 months ago

Add the values.yaml:

replicaCount: 1 image: repository: ghcr.io/langfuse/langfuse pullPolicy: Always langfuse: nodeEnv: production nextauth: url: http://localhost:3000 secret: changeme salt: changeme telemetryEnabled: True nextPublicSignUpDisabled: False enableExperimentalFeatures: False service: type: ClusterIP port: 3000 ingress: enabled: false autoscaling: enabled: false postgresql: auth: username: postgres password: xxxxxx database: db deploy: false
host: xx.xxx.xxx.xxx shadowDatabaseUrl: postgresql://postgres:xxxx@xx.xxx.xxx.xxx:5432 directUrl: postgresql://postgres:xxxx@xx.xxx.xxx.xxx543

The pod log begins with:

Prisma schema loaded from packages/shared/prisma/schema.prisma Datasource "db": PostgreSQL database "postgres", schema "public" at "XX.XXX.XXX:5432"

204 migrations found in prisma/migrations

Applying migration 20230518191501_init Applying migration 20230518193415_add_observaionts_and_traces Applying migration 20230518193521_changes Applying migration 20230522092340_add_metrics_and_observation_types Applying migration 20230522094431_endtime_optional Applying migration 20230522131516_default_timestamp Applying migration 20230523082455_rename_metrics_to_gradings Applying migration 20230523084523_rename_to_score Applying migration 20230529140133_user_add_pw ...

and finally:

Prisma schema loaded from packages/shared/prisma/schema.prisma Datasource "db": PostgreSQL database "postgres", schema "public" at "XX.XXX.XXX:5432"

204 migrations found in prisma/migrations

Error: P3009

migrate found failed migrations in the target database, new migrations will not be applied. Read more about how to resolve migration issues in a production database: https://pris.ly/d/migrate-resolve The 20231104005403_fkey_indicies migration started at 2024-06-11 10:37:53.515941 UTC failed

Applying database migrations failed. This is mostly caused by the database being unavailable. Exiting...

Kompita commented 3 months ago

Hi, I have successfully deployed the server using docker. The DATABASE_URL environment variable was incorrect. The database name was missing. I'm going to focus now on the Helm chart. Thanks

marcklingen commented 3 months ago

ok good to know, thanks for mentioning this! closing for now, let me know if you run into other issues