thingsboard / thingsboard-edge

Apache License 2.0
93 stars 71 forks source link

Database install fails when datbase type env variable present #100

Closed aistisdev closed 5 months ago

aistisdev commented 5 months ago

Describe the bug Database installation script install-tb-edge.sh fails when environment variable DATABASE_TS_TYPE=timescale is present.

Your Server Environment

To Reproduce Steps to reproduce the behavior:

  1. Create docker compose file:
    
    version: '3.8'
    services:
    mytbedge:
    restart: always
    image: "thingsboard/tb-edge:3.6.2EDGE"
    ports:
      - "8085:8080"
    environment:
      SPRING_DATASOURCE_URL: jdbc:postgresql://databaseip:5432/db_name
      DATABASE_TS_TYPE: timescale
      INSTALL_TB_EDGE: "true"
    volumes:
      - tb-edge-data:/data
      - tb-edge-logs:/var/log/tb-edge

volumes: tb-edge-data: name: tb-edge-data tb-edge-logs: name: tb-edge-logs


2. Start the container: `docker-compose up -d`
3. In docker log see error: `Error creating bean with name 'thingsboardInstallService': Unsatisfied dependency expressed through field 'tsDatabaseSchemaService'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'org.thingsboard.server.service.install.TsDatabaseSchemaService' available: expected single matching bean but found 2: sqlTsDatabaseSchemaService,timescaleTsDatabaseSchemaService`

**Expected behavior**
Should either support timescaledb databse setup (hyper tables on ts_kv and ts_kv_latest), or ignore the `DATABASE_TS_TYPE` environment variable.

**Screenshots**
The following annotation is reading the database type variable:
![image](https://github.com/thingsboard/thingsboard-edge/assets/62371501/b7282cae-7d91-41e4-8b66-ea3a2cb1a48e)
![image](https://github.com/thingsboard/thingsboard-edge/assets/62371501/c3fb5cb6-a5bc-4200-bae9-e9cdc4c7a2ca)

**Additional context**
I was migrating my k8s scripts for installing and upgrading the database to my new thingsboard-edge setup. The migrated scripts had a configmap with the DATABASE_TS_TYPE variable set to timescale. I was not aware that thingsboard-edge does not support this option and spent a few hours trying to figure out what is happening when trying to install the database from the thingsboard-edge kubernetes pod. 
Removing the variable DATABASE_TS_TYPE solved the issue.
AndriiLandiak commented 5 months ago

Hi, @aistisdev. Thanks for bringing this issue to our attention. The timescale support will be added and included in the upcoming release.

AndriiLandiak commented 5 months ago

Support timescale database type: https://github.com/thingsboard/thingsboard-edge/commit/db635517b0410b41892eebcd475d2b624187a6cf