Canner / WrenAI

🚀 An open-source SQL AI (Text-to-SQL) Agent that empowers data, product teams to chat with their data. 🤘
https://getwren.ai/oss
GNU Affero General Public License v3.0
2.06k stars 216 forks source link

Try to run on kubernetes Bootstrap not working #768

Open didlawowo opened 1 month ago

didlawowo commented 1 month ago

Describe the bug i trying to run wren ai on kubernetes using my own helm chart and get error with bootstrap on engine deployment. i have based my helm chart on analysis of your kustomize.

init config.properties
/app/init.sh: line 21: can't create "/app/data"/config.properties: nonexistent directory
grep: "/app/data"/config.properties: No such file or directory
wren.experimental-enable-dynamic-fields is not set, set it to true
/app/init.sh: line 29: can't create "/app/data"/config.properties: nonexistent directory
create mdl folder
mkdir: can't create directory '"/app/data"/mdl': No such file or directory
init mdl/sample.json
/app/init.sh: line 41: can't create "/app/data"/mdl/sample.json: nonexistent directory
init accounts file
/app/init.sh: line 49: can't create "/app/data"/accounts: nonexistent directory
Stream closed EOF for wren/wren-engine-678cf74cf9-8pdwf (bootstrap)

To Reproduce

just install init container

    initContainers:
    - name: bootstrap
      image: ghcr.io/canner/wren-bootstrap:0.1.4
      env:
      - name: DATA_PATH
        valueFrom:
          configMapKeyRef:
            name: wren
            key: WREN_ENGINE_DATA_PATH
      - name: PG_PASSWORD
        valueFrom:
          secretKeyRef:
            name: wren-postgresql
            key: postgres-password
      - name: PG_USERNAME
        valueFrom:
          secretKeyRef:
            name: wren
            key: PG_USERNAME
      volumeMounts:
      - name: wren-data
        mountPath: /app/data
      command: ["/bin/sh", "/app/init.sh"]

Expected behavior mount working and create file

Additional context

i can provide my helm chart on discord.

wwwy3y3 commented 1 month ago

@didlawowo

As I checked the logs you provided, it's strange the path consists of quotes: "/app/data"/accounts.

Could you confirm the env value you set is correct?

didlawowo commented 1 month ago

i think i have found it's a problem with the configmap , i 'm going to check :)

didlawowo commented 1 month ago

i have another with the UI

Using SQLite
Batch 1 run: 15 migrations
  ▲ Next.js 13.5.6
  - Local:        http://localhost:3000
  - Network:      http://0.0.0.0:3000

 ✓ Ready in 2.2s
[2024-10-19T18:57:07.913] [INFO] TELEMETRY - Telemetry not enabled.
using pg
[2024-10-19T18:57:08.328] [INFO] AskingService - Background tracker started
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432
}
Error: connect ECONNREFUSED 127.0.0.1:5432
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1278:16) {
  errno: -111,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 5432
}
Stream closed EOF for wren/wren-frontend-56f45d479b-kdrv2 (frontend)
wwwy3y3 commented 1 month ago

Connection issue with postgres. Don't forget to set PG_URL in wren-ui

didlawowo commented 1 month ago

thx now next problem

Batch 1 run: 15 migrations
  ▲ Next.js 13.5.6
  - Local:        http://localhost:3000
  - Network:      http://0.0.0.0:3000

 ✓ Ready in 2.2s
[2024-10-21T06:12:58.207] [INFO] TELEMETRY - Telemetry not enabled.
using pg
[2024-10-21T06:12:58.707] [INFO] AskingService - Background tracker started
error: select * from "thread_response" - relation "thread_response" does not exist
    at Parser.parseErrorMessage (/app/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/app/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/app/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/app/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (node:events:513:28)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Socket.Readable.push (node:internal/streams/readable:228:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 114,
  severity: 'ERROR',
  code: '42P01',
  detail: undefined,
  hint: undefined,
  position: '15',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_relation.c',
  line: '1449',
  routine: 'parserOpenTable'
}

the database admin_ui is empty. where is the job who init it ?

onlyjackfrost commented 1 month ago

Batch 1 run: 15 migrations Did the migration succeed? We run migrations before starting server. https://github.com/Canner/WrenAI/blob/0cf9f70fcf163562209f2251052ba93b06921347/wren-ui/Dockerfile#L61

didlawowo commented 1 month ago

Batch 1 run: 15 migrations Did the migration succeed? We run migrations before starting server.

https://github.com/Canner/WrenAI/blob/0cf9f70fcf163562209f2251052ba93b06921347/wren-ui/Dockerfile#L61

the migration seems working if your look at the log

Using SQLite
Batch 1 run: 15 migrations
  ▲ Next.js 13.5.6
  - Local:        http://localhost:3000
  - Network:      http://0.0.0.0:3000

 ✓ Ready in 2.4s
wwwy3y3 commented 1 month ago

@didlawowo the logs (Using SQLite) show that it's connecting to SQLite, not Postgres.

Could you show us the logs of wren-ui after you setup PG_URL ?

Also, make sure that the postgres user has enough permission to do the database migration.

didlawowo commented 1 month ago

on my side, i don't have config for sqlite,

inside the container:

/app # env | grep sql PG_URL=postgres://wren:postgres@wren-postgresql:5432/admin_ui /app # env | grep lite

didlawowo commented 1 month ago

if you set DB_TYPE=pg (insteand of WREN_UI_DB_TYPE) it's work but then i have a probleme when i try to create connection to database in ui (if connection fail i have another message)

Unexpected token o in JSON at position 1

didlawowo commented 4 weeks ago

@wwwy3y3

wwwy3y3 commented 4 weeks ago

@didlawowo could you share your logs to us ?

didlawowo commented 4 weeks ago
image
didlawowo commented 4 weeks ago

and nothing in the logs @wwwy3y3

wwwy3y3 commented 4 weeks ago

could you get logs from wren-engine & wren-ibis-server as well ?

I think there might be some issues on the network connection between services. That's why we saw response not in JSON format.

Could you also make sure the network connection from ui to engine & ibis work ? Please double-check on the following env: WREN_ENGINE_ENDPOINT , WREN_ENGINE_PORT, IBIS_SERVER_ENDPOINT. Make sure IBIS_SERVER_ENDPOINT is sth like http://wren-ibis-server:8000. It should point to the ibis service