Browse Source

Merge pull request #14503 from thingsboard/master-rc

rc
pull/14508/head
Viacheslav Klimov 9 months ago
committed by GitHub
parent
commit
0c888037df
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 79
      application/src/main/data/json/edge/instructions/install/centos/instructions.md
  2. 68
      application/src/main/data/json/edge/instructions/install/docker/instructions.md
  3. 60
      application/src/main/data/json/edge/instructions/install/ubuntu/instructions.md
  4. 4
      application/src/main/data/json/edge/instructions/upgrade/centos/instructions.md
  5. 7
      application/src/main/data/json/edge/instructions/upgrade/docker/instructions.md
  6. 5
      application/src/main/data/json/edge/instructions/upgrade/docker/start_service.md
  7. 5
      application/src/main/data/json/edge/instructions/upgrade/docker/upgrade_db.md
  8. 68
      application/src/main/data/json/edge/instructions/upgrade/docker/upgrade_preparing.md
  9. 2
      application/src/main/data/json/edge/instructions/upgrade/start_service.md
  10. 5
      application/src/main/data/json/edge/instructions/upgrade/ubuntu/instructions.md
  11. 6
      application/src/main/data/json/edge/instructions/upgrade/upgrade_preparing.md
  12. 10
      application/src/main/java/org/thingsboard/server/service/edge/instructions/BaseEdgeInstallUpgradeInstructionsService.java
  13. 9
      application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java
  14. 24
      application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java
  15. 2
      application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java
  16. 2
      application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java
  17. 3
      application/src/main/java/org/thingsboard/server/service/subscription/TbAlarmStatusSubCtx.java
  18. 8
      application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java
  19. 24
      application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java
  20. 52
      application/src/test/java/org/thingsboard/server/controller/WebsocketApiTest.java
  21. 15
      common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java
  22. 4
      common/queue/pom.xml
  23. 14
      pom.xml
  24. 4
      rule-engine/rule-engine-components/pom.xml
  25. 18
      ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html
  26. 4
      ui-ngx/src/app/shared/models/edge.models.ts

79
application/src/main/data/json/edge/instructions/install/centos/instructions.md

@ -1,7 +1,7 @@
Here is the list of commands, that can be used to quickly install ThingsBoard Edge on RHEL/CentOS 7/8 and connect to the server. Here is the list of commands that can be used to quickly install ThingsBoard Edge on RHEL/CentOS 7/8 and connect to the server.
#### Prerequisites #### Prerequisites
Before continue to installation execute the following commands in order to install necessary tools: Before continuing to installation, execute the following commands to install the necessary tools:
```bash ```bash
sudo yum install -y nano wget && sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm sudo yum install -y nano wget && sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
@ -9,29 +9,28 @@ sudo yum install -y nano wget && sudo yum install -y https://dl.fedoraproject.or
``` ```
#### Step 1. Install Java 17 (OpenJDK) #### Step 1. Install Java 17 (OpenJDK)
ThingsBoard service is running on Java 17. Follow these instructions to install OpenJDK 17: ThingsBoard service is running on Java 17. To install OpenJDK 17, follow these instructions:
```bash ```bash
sudo dnf install java-17-openjdk sudo dnf install java-17-openjdk
{:copy-code} {:copy-code}
``` ```
Please don't forget to configure your operating system to use OpenJDK 17 by default. Configure your operating system to use OpenJDK 17 by default. You can configure the default version by running the following command:
You can configure which version is the default using the following command:
```bash ```bash
sudo update-alternatives --config java sudo update-alternatives --config java
{:copy-code} {:copy-code}
``` ```
You can check the installation using the following command: To check the installed Java version on your system, use the following command:
```bash ```bash
java -version java -version
{:copy-code} {:copy-code}
``` ```
Expected command output is: The expected result is:
```text ```text
openjdk version "17.x.xx" openjdk version "17.x.xx"
@ -39,14 +38,13 @@ OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (build ...) OpenJDK 64-Bit Server VM (build ...)
``` ```
#### Step 2. Configure ThingsBoard Database #### Step 2. Configure ThingsBoard Edge Database
ThingsBoard Edge supports SQL and hybrid database approaches.
In this guide we will use SQL only.
For hybrid details please follow official installation instructions from the ThingsBoard documentation site.
### PostgresSql ThingsBoard Edge supports **SQL** and **hybrid** database configurations.
ThingsBoard Edge uses PostgreSQL database as a local storage. In this guide, we’ll use an **SQL** database.
To install PostgreSQL, follow the instructions below. For more details about the hybrid setup, please refer to the official installation instructions on the <a href="https://thingsboard.io/docs/user-guide/install/edge/rhel/#step-2-configure-thingsboard-database" target="_blank">ThingsBoard documentation site</a>.
To install the PostgreSQL database, run these commands:
```bash ```bash
# Update your system # Update your system
@ -55,7 +53,8 @@ sudo dnf update
``` ```
Install the repository RPM: Install the repository RPM:
**For CentOS/RHEL 8:**
* **For CentOS/RHEL 8:**
```bash ```bash
# Install the repository RPM (For CentOS/RHEL 8): # Install the repository RPM (For CentOS/RHEL 8):
@ -63,7 +62,7 @@ sudo sudo dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/
{:copy-code} {:copy-code}
``` ```
**For CentOS/RHEL 9:** * **For CentOS/RHEL 9:**
```bash ```bash
# Install the repository RPM (for CentOS 9): # Install the repository RPM (for CentOS 9):
@ -111,22 +110,11 @@ sudo systemctl restart postgresql-16.service && psql -U postgres -d postgres -h
{:copy-code} {:copy-code}
``` ```
#### Step 3. Choose Queue Service #### Step 3. ThingsBoard Edge Service Installation
ThingsBoard Edge supports only Kafka or in-memory queue (since v4.0) for message storage and communication between ThingsBoard services.
How to choose the right queue implementation?
In Memory queue implementation is built-in and default. It is useful for development(PoC) environments and is not suitable for production deployments or any sort of cluster deployments.
Kafka is recommended for production deployments. This queue is used on the most of ThingsBoard production environments now.
In Memory queue is built in and enabled by default. No additional configuration is required.
#### Step 4. ThingsBoard Edge Service Installation
Download installation package: Download installation package:
```bash ```bash
wget wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.rpm wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.rpm
{:copy-code} {:copy-code}
``` ```
@ -137,8 +125,8 @@ sudo rpm -Uvh tb-edge-${TB_EDGE_TAG}.rpm
{:copy-code} {:copy-code}
``` ```
#### Step 5. Configure ThingsBoard Edge #### Step 4. Configure ThingsBoard Edge
To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values: To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values:
```bash ```bash
sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.conf sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.conf
@ -151,7 +139,7 @@ EOL'
{:copy-code} {:copy-code}
``` ```
##### Configure PostgreSQL (Optional) ##### [Optional] Configure PostgreSQL Connection
If you changed PostgreSQL default datasource settings, use the following command: If you changed PostgreSQL default datasource settings, use the following command:
```bash ```bash
@ -163,11 +151,10 @@ EOL'
{:copy-code} {:copy-code}
``` ```
PUT_YOUR_POSTGRESQL_PASSWORD_HERE: Replace with your actual PostgreSQL user password. * **PUT_YOUR_POSTGRESQL_PASSWORD_HERE**: Replace with your actual **PostgreSQL user password**.
##### [Optional] Update bind ports ##### [Optional] Update Bind Ports
If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. If ThingsBoard Edge runs on the same machine as the ThingsBoard Server, you need to update the port configuration to avoid conflicts between the two services.
Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**):
@ -182,28 +169,26 @@ EOL'
{:copy-code} {:copy-code}
``` ```
Make sure that ports above (18080, 11883, 15683) are not used by any other application. Make sure that ports **18080**, **11883**, and **15683–15688** are not being used by any other applications.
#### Step 5. Run Installation Script
#### Step 6. Run installation Script Once ThingsBoard Edge is installed and configured, please execute the following install script:
Once ThingsBoard Edge is installed and configured please execute the following install script:
```bash ```bash
sudo /usr/share/tb-edge/bin/install/install.sh sudo /usr/share/tb-edge/bin/install/install.sh
{:copy-code} {:copy-code}
``` ```
#### Step 7. Restart ThingsBoard Edge Service #### Step 6. Start ThingsBoard Edge Service
```bash ```bash
sudo service tb-edge restart sudo service tb-edge start
{:copy-code} {:copy-code}
``` ```
#### Step 8. Open ThingsBoard Edge UI #### Step 7. Open ThingsBoard Edge UI
Once started, you will be able to open **ThingsBoard Edge UI** using the following link http://localhost:8080.
###### NOTE: Edge HTTP bind port update
If the Edge HTTP bind port was changed to 18080 during Edge installation, access the ThingsBoard Edge instance at http://localhost:18080. Once the Edge service has started, open the Edge web interface at http://localhost:8080, or http://localhost:18080 if you modified the HTTP bind port configuration in the previous step.
Log in using your **tenant credentials** from either your local ThingsBoard Server or the **ThingsBoard Live Demo**.

68
application/src/main/data/json/edge/instructions/install/docker/instructions.md

@ -1,34 +1,17 @@
Here is the list of commands, that can be used to quickly install ThingsBoard Edge using docker compose and connect to the server. Here is the list of commands that can be used to quickly install ThingsBoard Edge using docker compose and connect to the server.
#### Prerequisites #### Prerequisites
Install <a href="https://docs.docker.com/engine/install/" target="_blank"> Docker CE</a> and <a href="https://docs.docker.com/compose/install/" target="_blank"> Docker Compose</a>. Install <a href="https://docs.docker.com/engine/install/" target="_blank"> Docker CE</a> and <a href="https://docs.docker.com/compose/install/" target="_blank"> Docker Compose</a>.
#### Step 1. Running ThingsBoard Edge #### Step 1. Create the ThingsBoard Edge Docker Compose file
Here you can find ThingsBoard Edge docker image: ThingsBoard Edge supports both **in-memory** and **Kafka** queues for message storage and communication between ThingsBoard services.
It also supports **SQL** and **hybrid** database configurations.
In this guide, we’ll use the **in-memory** queue and an **SQL** database.
For more details about the hybrid setup, please refer to the official installation instructions on the <a href="https://thingsboard.io/docs/user-guide/install/edge/docker/#step-2-choose-queue-andor-database-services" target="_blank">ThingsBoard documentation site</a>.
<a href="https://hub.docker.com/r/thingsboard/tb-edge" target="_blank"> thingsboard/tb-edge</a> Now, create a Docker Compose file for the ThingsBoard Edge service:
#### Step 2. Choose Queue and/or Database Services
ThingsBoard Edge supports only Kafka or in-memory queue (since v4.0) for message storage and communication between ThingsBoard services.
ThingsBoard Edge supports SQL and hybrid database approaches.
In this guide we will use SQL only.
For hybrid details please follow official installation instructions from the ThingsBoard documentation site.
How to choose the right queue implementation?
In Memory queue implementation is built-in and default. It is useful for development(PoC) environments and is not suitable for production deployments or any sort of cluster deployments.
Kafka is recommended for production deployments. This queue is used on the most of ThingsBoard production environments now.
Hybrid implementation combines PostgreSQL and Cassandra databases with Kafka queue service. It is recommended if you plan to manage 1M+ devices in production or handle high data ingestion rate (more than 5000 msg/sec).
Create a docker compose file for the ThingsBoard Edge service:
##### In Memory
```bash ```bash
nano docker-compose.yml nano docker-compose.yml
@ -38,7 +21,6 @@ nano docker-compose.yml
Add the following lines to the yml file: Add the following lines to the yml file:
```bash ```bash
version: '3.8'
services: services:
mytbedge: mytbedge:
restart: always restart: always
@ -54,6 +36,7 @@ services:
CLOUD_RPC_HOST: ${BASE_URL} CLOUD_RPC_HOST: ${BASE_URL}
CLOUD_RPC_PORT: ${CLOUD_RPC_PORT} CLOUD_RPC_PORT: ${CLOUD_RPC_PORT}
CLOUD_RPC_SSL_ENABLED: ${CLOUD_RPC_SSL_ENABLED} CLOUD_RPC_SSL_ENABLED: ${CLOUD_RPC_SSL_ENABLED}
${EXTRA_HOSTS}
volumes: volumes:
- tb-edge-data:/data - tb-edge-data:/data
- tb-edge-logs:/var/log/tb-edge - tb-edge-logs:/var/log/tb-edge
@ -78,41 +61,28 @@ volumes:
{:copy-code} {:copy-code}
``` ```
##### [Optional] Update bind ports ##### [Optional] Update Bind Ports
If ThingsBoard Edge is set to run on the same machine where the ThingsBoard server is operating, you need to update port configuration to prevent port collision between the ThingsBoard server and ThingsBoard Edge. If ThingsBoard Edge runs on the same machine as the ThingsBoard Server, you need to update the port configuration to avoid conflicts between the two services.
Ensure that the ports 18080, 11883, 15683-15688 are not used by any other application. Make sure that ports **18080**, **11883**, and **15683–15688** are not being used by any other applications.
Then, update the port configuration in the docker-compose.yml file: Then, update the port configuration in the `docker-compose.yml` file accordingly:
```bash
sed -i ‘s/8080:8080/18080:8080/; s/1883:1883/11883:1883/; s/5683-5688:5683-5688\/udp/15683-15688:5683-5688\/udp/’ docker-compose.yml
{:copy-code}
```
#### Start ThingsBoard Edge
Set the terminal in the directory which contains the docker-compose.yml file and execute the following commands to up this docker compose directly:
```bash ```bash
docker compose up -d && docker compose logs -f mytbedge sed -i 's/8080:8080/18080:8080/; s/1883:1883/11883:1883/; s/5683-5688:5683-5688\/udp/15683-15688:5683-5688\/udp/' docker-compose.yml
{:copy-code} {:copy-code}
``` ```
###### NOTE: Docker Compose V2 vs docker-compose (with a hyphen) #### Step 2. Start ThingsBoard Edge
Navigate to the directory containing the `docker-compose.yml` file and run the following command to start the ThingsBoard Edge service:
ThingsBoard supports Docker Compose V2 (Docker Desktop or Compose plugin) starting from **3.4.2** release, because **docker-compose** as standalone setup is no longer supported by Docker.
We **strongly** recommend to update to Docker Compose V2 and use it.
If you still rely on using Docker Compose as docker-compose (with a hyphen), then please execute the following commands to start ThingsBoard Edge:
```bash ```bash
docker-compose up -d docker compose up -d && docker compose logs -f mytbedge
docker-compose logs -f mytbedge {:copy-code}
``` ```
#### Step 3. Open ThingsBoard Edge UI #### Step 3. Open ThingsBoard Edge UI
Once the Edge service is started, open the Edge UI at http://localhost:8080. Once the Edge service has started, open the Edge web interface at http://localhost:8080, or http://localhost:18080 if you modified the HTTP bind port configuration in the previous step.
###### NOTE: Edge HTTP bind port update
If the Edge HTTP bind port was changed to 18080 during Edge installation, access the ThingsBoard Edge instance at http://localhost:18080.
Please use your tenant credentials from local Server instance or ThingsBoard Live Demo to log in to the ThingsBoard Edge. Log in using your **tenant credentials** from either your local ThingsBoard Server or the **ThingsBoard Live Demo**.

60
application/src/main/data/json/edge/instructions/install/ubuntu/instructions.md

@ -1,4 +1,4 @@
Here is the list of commands, that can be used to quickly install ThingsBoard Edge on Ubuntu Server and connect to the server. Here is the list of commands that can be used to quickly install ThingsBoard Edge on Ubuntu Server and connect to the server.
#### Step 1. Install Java 17 (OpenJDK) #### Step 1. Install Java 17 (OpenJDK)
ThingsBoard service is running on Java 17. To install OpenJDK 17, follow these instructions: ThingsBoard service is running on Java 17. To install OpenJDK 17, follow these instructions:
@ -25,19 +25,16 @@ java -version
The expected result is: The expected result is:
```text ```text
openjdk version "17.x.xx" openjdk version "17.x.xx"
OpenJDK Runtime Environment (...) OpenJDK Runtime Environment (...)
OpenJDK 64-Bit Server VM (...) OpenJDK 64-Bit Server VM (build ...)
``` ```
#### Step 2. Configure ThingsBoard Edge Database #### Step 2. Configure ThingsBoard Edge Database
ThingsBoard Edge supports SQL and hybrid database approaches. ThingsBoard Edge supports **SQL** and **hybrid** database configurations.
In this guide we will use SQL only. In this guide, we’ll use an **SQL** database.
For hybrid details please follow official installation instructions from the ThingsBoard documentation site. For more details about the hybrid setup, please refer to the official installation instructions on the <a href="https://thingsboard.io/docs/user-guide/install/edge/deb-installation/#step-2-configure-the-thingsboard-edge-database" target="_blank">ThingsBoard documentation site</a>.
### Configure PostgreSQL
ThingsBoard Edge uses PostgreSQL database as a local storage.
To install the PostgreSQL database, run these commands: To install the PostgreSQL database, run these commands:
@ -71,18 +68,8 @@ echo "CREATE DATABASE tb_edge;" | psql -U postgres -d postgres -h 127.0.0.1 -W
{:copy-code} {:copy-code}
``` ```
#### Step 3. Choose Queue Service #### Step 3. ThingsBoard Edge Service Installation
Download the installation package:
ThingsBoard Edge supports only Kafka or in-memory queue (since v4.0) for message storage and communication between ThingsBoard services. Choose the appropriate queue implementation based on your specific business needs:
In Memory: The built-in and default queue implementation. It is useful for development or proof-of-concept (PoC) environments, but is not recommended for production or any type of clustered deployments due to limited scalability.
Kafka: Recommended for production deployments. This queue is used in the most of ThingsBoard production environments now.
In Memory queue is built in and enabled by default. No additional configuration is required.
#### Step 4. ThingsBoard Edge Service Installation
Download installation package:
```bash ```bash
wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.deb wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.deb
@ -96,8 +83,8 @@ sudo dpkg -i tb-edge-${TB_EDGE_TAG}.deb
{:copy-code} {:copy-code}
``` ```
#### Step 5. Configure ThingsBoard Edge #### Step 4. Configure ThingsBoard Edge
To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values: To configure ThingsBoard Edge, you can use the following command to automatically update the configuration file with specific values:
```bash ```bash
sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.conf sudo sh -c 'cat <<EOL >> /etc/tb-edge/conf/tb-edge.conf
@ -110,7 +97,7 @@ EOL'
{:copy-code} {:copy-code}
``` ```
##### [Optional] Configure PostgreSQL ##### [Optional] Configure PostgreSQL Connection
If you changed PostgreSQL default datasource settings, use the following command: If you changed PostgreSQL default datasource settings, use the following command:
```bash ```bash
@ -122,10 +109,10 @@ EOL'
{:copy-code} {:copy-code}
``` ```
PUT_YOUR_POSTGRESQL_PASSWORD_HERE: Replace with your actual PostgreSQL user password. * **PUT_YOUR_POSTGRESQL_PASSWORD_HERE**: Replace with your actual **PostgreSQL user password**.
##### [Optional] Update bind ports ##### [Optional] Update Bind Ports
If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. If ThingsBoard Edge runs on the same machine as the ThingsBoard Server, you need to update the port configuration to avoid conflicts between the two services.
Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**):
@ -140,29 +127,26 @@ EOL'
{:copy-code} {:copy-code}
``` ```
Make sure that ports above (18080, 11883, 15683) are not used by any other application. Make sure that ports **18080**, **11883**, and **15683–15688** are not being used by any other applications.
#### Step 6. Run installation Script #### Step 5. Run Installation Script
Once ThingsBoard Edge is installed and configured please execute the following install script: Once ThingsBoard Edge is installed and configured, please execute the following installation script:
```bash ```bash
sudo /usr/share/tb-edge/bin/install/install.sh sudo /usr/share/tb-edge/bin/install/install.sh
{:copy-code} {:copy-code}
``` ```
#### Step 7. Restart ThingsBoard Edge Service #### Step 6. Start ThingsBoard Edge Service
```bash ```bash
sudo service tb-edge restart sudo service tb-edge start
{:copy-code} {:copy-code}
``` ```
#### Step 8. Open ThingsBoard Edge UI #### Step 7. Open ThingsBoard Edge UI
Once started, you will be able to open **ThingsBoard Edge UI** using the following link http://localhost:8080.
###### NOTE: Edge HTTP bind port update
Use next **ThingsBoard Edge UI** link **http://localhost:18080** if you updated HTTP 8080 bind port to **18080**. Once the Edge service has started, open the Edge web interface at http://localhost:8080, or http://localhost:18080 if you modified the HTTP bind port configuration in the previous step.
Log in using your **tenant credentials** from either your local ThingsBoard Server or the **ThingsBoard Live Demo**.

4
application/src/main/data/json/edge/instructions/upgrade/centos/instructions.md

@ -1,15 +1,15 @@
#### Upgrading to ${TB_EDGE_VERSION}EDGE #### Upgrading to ${TB_EDGE_VERSION}EDGE
**ThingsBoard Edge package download:** ThingsBoard Edge package download:
```bash ```bash
wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.rpm wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.rpm
{:copy-code} {:copy-code}
``` ```
##### ThingsBoard Edge service upgrade
Install package: Install package:
```bash ```bash
sudo rpm -Uvh tb-edge-${TB_EDGE_TAG}.rpm sudo rpm -Uvh tb-edge-${TB_EDGE_TAG}.rpm
{:copy-code} {:copy-code}
``` ```
${UPGRADE_DB} ${UPGRADE_DB}

7
application/src/main/data/json/edge/instructions/upgrade/docker/instructions.md

@ -1,10 +1,3 @@
#### Upgrading to ${TB_EDGE_VERSION} #### Upgrading to ${TB_EDGE_VERSION}
Execute the following command to pull **${TB_EDGE_VERSION}** image:
```bash
docker pull thingsboard/tb-edge:${TB_EDGE_VERSION}
{:copy-code}
```
${UPGRADE_DB} ${UPGRADE_DB}

5
application/src/main/data/json/edge/instructions/upgrade/docker/start_service.md

@ -1,11 +1,10 @@
Modify ‘main’ docker compose (`docker-compose.yml`) file for ThingsBoard Edge and update version of the image: Modify ‘main’ docker compose (`docker-compose.yml`) a file for ThingsBoard Edge and update a version of the image:
```bash ```bash
nano docker-compose.yml nano docker-compose.yml
{:copy-code} {:copy-code}
``` ```
```text ```text
version: '3.8'
services: services:
mytbedge: mytbedge:
restart: always restart: always
@ -13,7 +12,7 @@ services:
... ...
``` ```
Make sure your image is the set to **tb-edge-${TB_EDGE_VERSION}**. Make sure your image is set to **tb-edge:${TB_EDGE_VERSION}**.
Execute the following commands to up this docker compose directly: Execute the following commands to up this docker compose directly:
```bash ```bash

5
application/src/main/data/json/edge/instructions/upgrade/docker/upgrade_db.md

@ -1,4 +1,4 @@
Create docker compose file for ThingsBoard Edge upgrade process: Create a docker compose file for ThingsBoard Edge upgrade process:
```bash ```bash
> docker-compose-upgrade.yml && nano docker-compose-upgrade.yml > docker-compose-upgrade.yml && nano docker-compose-upgrade.yml
@ -8,7 +8,6 @@ Create docker compose file for ThingsBoard Edge upgrade process:
Add the following lines to the yml file: Add the following lines to the yml file:
```bash ```bash
version: '3.8'
services: services:
mytbedge: mytbedge:
restart: on-failure restart: on-failure
@ -40,7 +39,7 @@ volumes:
{:copy-code} {:copy-code}
``` ```
Execute the following command to start upgrade process: Execute the following command to start an upgrade process:
```bash ```bash
docker compose -f docker-compose-upgrade.yml up --abort-on-container-exit docker compose -f docker-compose-upgrade.yml up --abort-on-container-exit

68
application/src/main/data/json/edge/instructions/upgrade/docker/upgrade_preparing.md

@ -1,6 +1,6 @@
Here is the list of commands, that can be used to quickly upgrade ThingsBoard Edge on Docker (Linux or MacOS). Here is the list of commands that can be used to quickly upgrade ThingsBoard Edge on Docker (Linux or macOS).
#### Prepare for upgrading ThingsBoard Edge #### Prepare for Upgrading ThingsBoard Edge
Set the terminal in the directory which contains the `docker-compose.yml` file and execute the following command Set the terminal in the directory which contains the `docker-compose.yml` file and execute the following command
to stop and remove currently running TB Edge container: to stop and remove currently running TB Edge container:
@ -10,70 +10,6 @@ docker compose rm mytbedge
{:copy-code} {:copy-code}
``` ```
**OPTIONAL:** If you still rely on Docker Compose as docker-compose (with a hyphen) here is the list of the above commands:
```text
docker-compose stop
docker-compose rm mytbedge
```
##### Migrating Data from Docker Bind Mount Folders to Docker Volumes
Starting with the **3.6.2** release, the ThingsBoard team has transitioned from using Docker bind mount folders to Docker volumes.
This change aims to enhance security and efficiency in storing data for Docker containers and to mitigate permission issues across various environments.
To migrate from Docker bind mounts to Docker volumes, please execute the following commands:
```bash
docker run --rm -v tb-edge-data:/volume -v ~/.mytb-edge-data:/backup busybox sh -c "cp -a /backup/. /volume"
docker run --rm -v tb-edge-logs:/volume -v ~/.mytb-edge-logs:/backup busybox sh -c "cp -a /backup/. /volume"
docker run --rm -v tb-edge-postgres-data:/volume -v ~/.mytb-edge-data/db:/backup busybox sh -c "cp -a /backup/. /volume"
{:copy-code}
```
After completing the data migration to the newly created Docker volumes, you'll need to update the volume mounts in your Docker Compose configuration.
Modify the `docker-compose.yml` file for ThingsBoard Edge to update the volume settings.
Update volume mounts. Locate the following snippet:
```text
volumes:
- ~/.mytb-edge-data:/data
- ~/.mytb-edge-logs:/var/log/tb-edge
...
```
And replace it with:
```text
volumes:
- tb-edge-data:/data
- tb-edge-logs:/var/log/tb-edge
...
```
Apply a similar update for the PostgreSQL service. Find the section:
```text
volumes:
- ~/.mytb-edge-data/db:/var/lib/postgresql/data
...
```
And replace it with:
```text
volumes:
- tb-edge-postgres-data:/var/lib/postgresql/data
...
```
Finally, please add next volumes section at the end of the file:
```text
...
volumes:
tb-edge-data:
name: tb-edge-data
tb-edge-logs:
name: tb-edge-logs
tb-edge-postgres-data:
name: tb-edge-postgres-data
```
##### Backup Database ##### Backup Database
Make a copy of the database volume before upgrading: Make a copy of the database volume before upgrading:

2
application/src/main/data/json/edge/instructions/upgrade/start_service.md

@ -1,4 +1,4 @@
Start the service #### Start the Service
```bash ```bash
sudo systemctl tb-edge start sudo systemctl tb-edge start

5
application/src/main/data/json/edge/instructions/upgrade/ubuntu/instructions.md

@ -1,15 +1,14 @@
#### Upgrading to ${TB_EDGE_VERSION}EDGE #### Upgrading to ${TB_EDGE_VERSION}EDGE
**ThingsBoard Edge package download:** ThingsBoard Edge package download:
```bash ```bash
wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.deb wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_TAG}/tb-edge-${TB_EDGE_TAG}.deb
{:copy-code} {:copy-code}
``` ```
##### ThingsBoard Edge service upgrade
Install package: Install package:
```bash ```bash
sudo dpkg -i tb-edge-${TB_EDGE_TAG}.deb sudo dpkg -i tb-edge-${TB_EDGE_TAG}.deb
{:copy-code} {:copy-code}
``` ```
${UPGRADE_DB} ${UPGRADE_DB}

6
application/src/main/data/json/edge/instructions/upgrade/upgrade_preparing.md

@ -1,6 +1,6 @@
Here is the list of commands, that can be used to quickly upgrade ThingsBoard Edge on ${OS} Here is the list of commands that can be used to quickly upgrade ThingsBoard Edge on ${OS}
#### Prepare for upgrading ThingsBoard Edge #### Prepare for Upgrading ThingsBoard Edge
Stop ThingsBoard Edge service: Stop ThingsBoard Edge service:
@ -33,4 +33,4 @@ sudo -Hiu postgres pg_dump tb_edge > tb_edge.sql.bak
{:copy-code} {:copy-code}
``` ```
Check backup file created successfully. Check the backup file created successfully.

10
application/src/main/java/org/thingsboard/server/service/edge/instructions/BaseEdgeInstallUpgradeInstructionsService.java

@ -18,7 +18,6 @@ package org.thingsboard.server.service.edge.instructions;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.thingsboard.server.service.install.InstallScripts; import org.thingsboard.server.service.install.InstallScripts;
import java.io.IOException; import java.io.IOException;
@ -26,6 +25,8 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import static org.thingsboard.edge.rpc.EdgeGrpcClient.getNewestEdgeVersion;
@Slf4j @Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public abstract class BaseEdgeInstallUpgradeInstructionsService { public abstract class BaseEdgeInstallUpgradeInstructionsService {
@ -35,9 +36,12 @@ public abstract class BaseEdgeInstallUpgradeInstructionsService {
private final InstallScripts installScripts; private final InstallScripts installScripts;
@Value("${app.version:unknown}")
@Setter @Setter
protected String appVersion; protected String platformEdgeVersion = convertEdgeVersionToDocsFormat(getNewestEdgeVersion().name());
protected String convertEdgeVersionToDocsFormat(String edgeVersion) {
return edgeVersion.replace("_", ".").substring(2);
}
protected String readFile(Path file) { protected String readFile(Path file) {
try { try {

9
application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallInstructionsService.java

@ -65,9 +65,7 @@ public class DefaultEdgeInstallInstructionsService extends BaseEdgeInstallUpgrad
dockerInstallInstructions = dockerInstallInstructions.replace("${EXTRA_HOSTS}", ""); dockerInstallInstructions = dockerInstallInstructions.replace("${EXTRA_HOSTS}", "");
dockerInstallInstructions = dockerInstallInstructions.replace("${BASE_URL}", baseUrl); dockerInstallInstructions = dockerInstallInstructions.replace("${BASE_URL}", baseUrl);
} }
String edgeVersion = appVersion + "EDGE"; dockerInstallInstructions = dockerInstallInstructions.replace("${TB_EDGE_VERSION}", platformEdgeVersion + "EDGE");
edgeVersion = edgeVersion.replace("-SNAPSHOT", "");
dockerInstallInstructions = dockerInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion);
dockerInstallInstructions = replacePlaceholders(dockerInstallInstructions, edge); dockerInstallInstructions = replacePlaceholders(dockerInstallInstructions, edge);
return new EdgeInstructions(dockerInstallInstructions); return new EdgeInstructions(dockerInstallInstructions);
} }
@ -76,9 +74,8 @@ public class DefaultEdgeInstallInstructionsService extends BaseEdgeInstallUpgrad
String ubuntuInstallInstructions = readFile(resolveFile(os, "instructions.md")); String ubuntuInstallInstructions = readFile(resolveFile(os, "instructions.md"));
ubuntuInstallInstructions = replacePlaceholders(ubuntuInstallInstructions, edge); ubuntuInstallInstructions = replacePlaceholders(ubuntuInstallInstructions, edge);
ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${BASE_URL}", request.getServerName()); ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${BASE_URL}", request.getServerName());
String edgeVersion = appVersion.replace("-SNAPSHOT", ""); ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_VERSION}", platformEdgeVersion);
ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_TAG}", getTagVersion(platformEdgeVersion));
ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_TAG}", getTagVersion(edgeVersion));
return new EdgeInstructions(ubuntuInstallInstructions); return new EdgeInstructions(ubuntuInstallInstructions);
} }

24
application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeUpgradeInstructionsService.java

@ -52,12 +52,11 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
@Override @Override
public EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod) { public EdgeInstructions getUpgradeInstructions(String edgeVersion, String upgradeMethod) {
String tbVersion = appVersion.replace("-SNAPSHOT", "");
String currentEdgeVersion = convertEdgeVersionToDocsFormat(edgeVersion); String currentEdgeVersion = convertEdgeVersionToDocsFormat(edgeVersion);
return switch (upgradeMethod.toLowerCase()) { return switch (upgradeMethod.toLowerCase()) {
case "docker" -> getDockerUpgradeInstructions(tbVersion, currentEdgeVersion); case "docker" -> getDockerUpgradeInstructions(this.platformEdgeVersion, currentEdgeVersion);
case "ubuntu", "centos" -> case "ubuntu", "centos" ->
getLinuxUpgradeInstructions(tbVersion, currentEdgeVersion, upgradeMethod.toLowerCase()); getLinuxUpgradeInstructions(this.platformEdgeVersion, currentEdgeVersion, upgradeMethod.toLowerCase());
default -> throw new IllegalArgumentException("Unsupported upgrade method for Edge: " + upgradeMethod); default -> throw new IllegalArgumentException("Unsupported upgrade method for Edge: " + upgradeMethod);
}; };
} }
@ -74,8 +73,7 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
Optional<AttributeKvEntry> attributeKvEntryOpt = attributesService.find(tenantId, edgeId, AttributeScope.SERVER_SCOPE, DataConstants.EDGE_VERSION_ATTR_KEY).get(); Optional<AttributeKvEntry> attributeKvEntryOpt = attributesService.find(tenantId, edgeId, AttributeScope.SERVER_SCOPE, DataConstants.EDGE_VERSION_ATTR_KEY).get();
if (attributeKvEntryOpt.isPresent()) { if (attributeKvEntryOpt.isPresent()) {
String edgeVersionFormatted = convertEdgeVersionToDocsFormat(attributeKvEntryOpt.get().getValueAsString()); String edgeVersionFormatted = convertEdgeVersionToDocsFormat(attributeKvEntryOpt.get().getValueAsString());
String appVersionFormatted = appVersion.replace("-SNAPSHOT", ""); return isVersionGreaterOrEqualsThan(edgeVersionFormatted, "3.6.0") && !isVersionGreaterOrEqualsThan(edgeVersionFormatted, platformEdgeVersion);
return isVersionGreaterOrEqualsThan(edgeVersionFormatted, "3.6.0") && !isVersionGreaterOrEqualsThan(edgeVersionFormatted, appVersionFormatted);
} }
return false; return false;
} }
@ -98,13 +96,13 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
return true; return true;
} }
private EdgeInstructions getDockerUpgradeInstructions(String tbVersion, String currentEdgeVersion) { private EdgeInstructions getDockerUpgradeInstructions(String platformEdgeVersion, String currentEdgeVersion) {
EdgeUpgradeInfo edgeUpgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion); EdgeUpgradeInfo edgeUpgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion);
if (edgeUpgradeInfo == null || edgeUpgradeInfo.getNextEdgeVersion() == null || tbVersion.equals(currentEdgeVersion)) { if (edgeUpgradeInfo == null || edgeUpgradeInfo.getNextEdgeVersion() == null || platformEdgeVersion.equals(currentEdgeVersion)) {
return new EdgeInstructions("Edge upgrade instruction for " + currentEdgeVersion + "EDGE is not available."); return new EdgeInstructions("Edge upgrade instruction for " + currentEdgeVersion + "EDGE is not available.");
} }
StringBuilder result = new StringBuilder(readFile(resolveFile("docker", "upgrade_preparing.md"))); StringBuilder result = new StringBuilder(readFile(resolveFile("docker", "upgrade_preparing.md")));
while (edgeUpgradeInfo.getNextEdgeVersion() != null && !tbVersion.equals(currentEdgeVersion)) { while (edgeUpgradeInfo.getNextEdgeVersion() != null && !platformEdgeVersion.equals(currentEdgeVersion)) {
String edgeVersion = edgeUpgradeInfo.getNextEdgeVersion(); String edgeVersion = edgeUpgradeInfo.getNextEdgeVersion();
String dockerUpgradeInstructions = readFile(resolveFile("docker", "instructions.md")); String dockerUpgradeInstructions = readFile(resolveFile("docker", "instructions.md"));
if (edgeUpgradeInfo.isRequiresUpdateDb()) { if (edgeUpgradeInfo.isRequiresUpdateDb()) {
@ -125,15 +123,15 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
return new EdgeInstructions(result.toString()); return new EdgeInstructions(result.toString());
} }
private EdgeInstructions getLinuxUpgradeInstructions(String tbVersion, String currentEdgeVersion, String os) { private EdgeInstructions getLinuxUpgradeInstructions(String platformEdgeVersion, String currentEdgeVersion, String os) {
EdgeUpgradeInfo edgeUpgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion); EdgeUpgradeInfo edgeUpgradeInfo = upgradeVersionHashMap.get(currentEdgeVersion);
if (edgeUpgradeInfo == null || edgeUpgradeInfo.getNextEdgeVersion() == null || tbVersion.equals(currentEdgeVersion)) { if (edgeUpgradeInfo == null || edgeUpgradeInfo.getNextEdgeVersion() == null || platformEdgeVersion.equals(currentEdgeVersion)) {
return new EdgeInstructions("Edge upgrade instruction for " + currentEdgeVersion + "EDGE is not available."); return new EdgeInstructions("Edge upgrade instruction for " + currentEdgeVersion + "EDGE is not available.");
} }
String upgrade_preparing = readFile(resolveFile("upgrade_preparing.md")); String upgrade_preparing = readFile(resolveFile("upgrade_preparing.md"));
upgrade_preparing = upgrade_preparing.replace("${OS}", os.equals("centos") ? "RHEL/CentOS 7/8" : "Ubuntu"); upgrade_preparing = upgrade_preparing.replace("${OS}", os.equals("centos") ? "RHEL/CentOS 7/8" : "Ubuntu");
StringBuilder result = new StringBuilder(upgrade_preparing); StringBuilder result = new StringBuilder(upgrade_preparing);
while (edgeUpgradeInfo.getNextEdgeVersion() != null && !tbVersion.equals(currentEdgeVersion)) { while (edgeUpgradeInfo.getNextEdgeVersion() != null && !platformEdgeVersion.equals(currentEdgeVersion)) {
String edgeVersion = edgeUpgradeInfo.getNextEdgeVersion(); String edgeVersion = edgeUpgradeInfo.getNextEdgeVersion();
String linuxUpgradeInstructions = readFile(resolveFile(os, "instructions.md")); String linuxUpgradeInstructions = readFile(resolveFile(os, "instructions.md"));
if (edgeUpgradeInfo.isRequiresUpdateDb()) { if (edgeUpgradeInfo.isRequiresUpdateDb()) {
@ -155,10 +153,6 @@ public class DefaultEdgeUpgradeInstructionsService extends BaseEdgeInstallUpgrad
return new EdgeInstructions(result.toString()); return new EdgeInstructions(result.toString());
} }
private String convertEdgeVersionToDocsFormat(String edgeVersion) {
return edgeVersion.replace("_", ".").substring(2);
}
@Override @Override
protected String getBaseDirName() { protected String getBaseDirName() {
return UPGRADE_DIR; return UPGRADE_DIR;

2
application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeInstallInstructionsService.java

@ -23,6 +23,6 @@ public interface EdgeInstallInstructionsService {
EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request); EdgeInstructions getInstallInstructions(Edge edge, String installationMethod, HttpServletRequest request);
void setAppVersion(String version); void setPlatformEdgeVersion(String version);
} }

2
application/src/main/java/org/thingsboard/server/service/edge/instructions/EdgeUpgradeInstructionsService.java

@ -28,7 +28,7 @@ public interface EdgeUpgradeInstructionsService {
void updateInstructionMap(Map<String, EdgeUpgradeInfo> upgradeVersions); void updateInstructionMap(Map<String, EdgeUpgradeInfo> upgradeVersions);
void setAppVersion(String version); void setPlatformEdgeVersion(String version);
boolean isUpgradeAvailable(TenantId tenantId, EdgeId edgeId) throws Exception; boolean isUpgradeAvailable(TenantId tenantId, EdgeId edgeId) throws Exception;

3
application/src/main/java/org/thingsboard/server/service/subscription/TbAlarmStatusSubCtx.java

@ -95,6 +95,9 @@ public class TbAlarmStatusSubCtx extends TbAbstractSubCtx {
private void handleAlarmStatusSubscriptionUpdate(TbSubscription<AlarmSubscriptionUpdate> sub, AlarmSubscriptionUpdate subscriptionUpdate) { private void handleAlarmStatusSubscriptionUpdate(TbSubscription<AlarmSubscriptionUpdate> sub, AlarmSubscriptionUpdate subscriptionUpdate) {
try { try {
AlarmInfo alarm = subscriptionUpdate.getAlarm(); AlarmInfo alarm = subscriptionUpdate.getAlarm();
if (!alarm.getOriginator().equals(subscription.getEntityId())) {
return;
}
Set<UUID> alarmsIds = subscription.getAlarmIds(); Set<UUID> alarmsIds = subscription.getAlarmIds();
if (alarmsIds.contains(alarm.getId().getId())) { if (alarmsIds.contains(alarm.getId().getId())) {
if (!subscription.matches(alarm) || subscriptionUpdate.isAlarmDeleted()) { if (!subscription.matches(alarm) || subscriptionUpdate.isAlarmDeleted()) {

8
application/src/main/java/org/thingsboard/server/service/update/DefaultUpdateService.java

@ -150,10 +150,10 @@ public class DefaultUpdateService implements UpdateService {
.build()); .build());
} }
ObjectNode edgeRequest = JacksonUtil.newObjectNode().put(VERSION_PARAM, version); ObjectNode edgeRequest = JacksonUtil.newObjectNode().put(VERSION_PARAM, version);
String edgeInstallVersion = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/installMapping", new HttpEntity<>(edgeRequest.toString(), headers), String.class); String edgePlatformVersion = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/installMapping", new HttpEntity<>(edgeRequest.toString(), headers), String.class);
if (edgeInstallVersion != null) { if (edgePlatformVersion != null) {
edgeInstallInstructionsService.setAppVersion(edgeInstallVersion); edgeInstallInstructionsService.setPlatformEdgeVersion(edgePlatformVersion);
edgeUpgradeInstructionsService.setAppVersion(edgeInstallVersion); edgeUpgradeInstructionsService.setPlatformEdgeVersion(edgePlatformVersion);
} }
EdgeUpgradeMessage edgeUpgradeMessage = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/upgradeMapping", new HttpEntity<>(edgeRequest.toString(), headers), EdgeUpgradeMessage.class); EdgeUpgradeMessage edgeUpgradeMessage = restClient.postForObject(UPDATE_SERVER_BASE_URL + "/api/v1/edge/upgradeMapping", new HttpEntity<>(edgeRequest.toString(), headers), EdgeUpgradeMessage.class);
if (edgeUpgradeMessage != null) { if (edgeUpgradeMessage != null) {

24
application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java

@ -1278,7 +1278,7 @@ public class EdgeControllerTest extends AbstractControllerTest {
@Test @Test
public void testGetEdgeUpgradeInstructions() throws Exception { public void testGetEdgeUpgradeInstructions() throws Exception {
// UpdateInfo config is updating from Thingsboard Update server // UpdateInfo config is updating from the Thingsboard Update server
HashMap<String, EdgeUpgradeInfo> upgradeInfoHashMap = new HashMap<>(); HashMap<String, EdgeUpgradeInfo> upgradeInfoHashMap = new HashMap<>();
upgradeInfoHashMap.put("3.6.0", new EdgeUpgradeInfo(true, "3.6.1")); upgradeInfoHashMap.put("3.6.0", new EdgeUpgradeInfo(true, "3.6.1"));
upgradeInfoHashMap.put("3.6.1", new EdgeUpgradeInfo(true, "3.6.2")); upgradeInfoHashMap.put("3.6.1", new EdgeUpgradeInfo(true, "3.6.2"));
@ -1301,35 +1301,31 @@ public class EdgeControllerTest extends AbstractControllerTest {
// Test 3.5.0 Edge - upgrade not available // Test 3.5.0 Edge - upgrade not available
String body = "{\"edgeVersion\": \"V_3_5_0\"}"; String body = "{\"edgeVersion\": \"V_3_5_0\"}";
doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk()); doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk());
edgeUpgradeInstructionsService.setAppVersion("3.6.0"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.0");
Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.2");
Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2.7"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.2.7");
Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
// Test 3.6.0 Edge - upgrade available // Test 3.6.0 Edge - upgrade available
body = "{\"edgeVersion\": \"V_3_6_0\"}"; body = "{\"edgeVersion\": \"V_3_6_0\"}";
doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk()); doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk());
edgeUpgradeInstructionsService.setAppVersion("3.6.0"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.0");
Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.1.5"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.1.5");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.1.6-SNAPSHOT"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.2");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
// Test 3.6.1 Edge - upgrade available // Test 3.6.1 Edge - upgrade available
body = "{\"edgeVersion\": \"V_3_6_1\"}"; body = "{\"edgeVersion\": \"V_3_6_1\"}";
doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk()); doPostAsync("/api/plugins/telemetry/EDGE/" + savedEdge.getId().getId() + "/attributes/SERVER_SCOPE", body, String.class, status().isOk());
edgeUpgradeInstructionsService.setAppVersion("3.6.1"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.1");
Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertFalse(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.2");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2-SNAPSHOT");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
edgeUpgradeInstructionsService.setAppVersion("3.6.2.6"); edgeUpgradeInstructionsService.setPlatformEdgeVersion("3.6.2.6");
Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId())); Assert.assertTrue(edgeUpgradeInstructionsService.isUpgradeAvailable(savedEdge.getTenantId(), savedEdge.getId()));
} }

52
application/src/test/java/org/thingsboard/server/controller/WebsocketApiTest.java

@ -34,6 +34,7 @@ import org.thingsboard.rule.engine.api.TimeseriesSaveRequest;
import org.thingsboard.server.common.data.Device; import org.thingsboard.server.common.data.Device;
import org.thingsboard.server.common.data.alarm.Alarm; import org.thingsboard.server.common.data.alarm.Alarm;
import org.thingsboard.server.common.data.alarm.AlarmSeverity; import org.thingsboard.server.common.data.alarm.AlarmSeverity;
import org.thingsboard.server.common.data.asset.Asset;
import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.kv.AttributeKvEntry; import org.thingsboard.server.common.data.kv.AttributeKvEntry;
@ -58,6 +59,7 @@ import org.thingsboard.server.common.data.query.KeyFilter;
import org.thingsboard.server.common.data.query.NumericFilterPredicate; import org.thingsboard.server.common.data.query.NumericFilterPredicate;
import org.thingsboard.server.common.data.query.SingleEntityFilter; import org.thingsboard.server.common.data.query.SingleEntityFilter;
import org.thingsboard.server.common.data.query.TsValue; import org.thingsboard.server.common.data.query.TsValue;
import org.thingsboard.server.common.data.relation.EntityRelation;
import org.thingsboard.server.dao.service.DaoSqlTest; import org.thingsboard.server.dao.service.DaoSqlTest;
import org.thingsboard.server.service.subscription.SubscriptionErrorCode; import org.thingsboard.server.service.subscription.SubscriptionErrorCode;
import org.thingsboard.server.service.subscription.TbAttributeSubscriptionScope; import org.thingsboard.server.service.subscription.TbAttributeSubscriptionScope;
@ -478,6 +480,56 @@ public class WebsocketApiTest extends AbstractControllerTest {
Assert.assertFalse(alarmStatusUpdate5.isActive()); Assert.assertFalse(alarmStatusUpdate5.isActive());
} }
@Test
public void testAlarmStatusWsCmdForPropagatedAlarms() throws Exception {
loginTenantAdmin();
Device device = new Device();
device.setName("Test device");
device.setLabel("Label");
device.setType("default");
device = doPost("/api/device", device, Device.class);
Asset asset = new Asset();
asset.setName("My asset");
asset.setType("default");
asset = doPost("/api/asset", asset, Asset.class);
EntityRelation entityRelation = new EntityRelation(asset.getId(), device.getId(), "CONTAINS");
doPost("/api/relation", entityRelation);
AlarmStatusCmd cmd = new AlarmStatusCmd(1, asset.getId(), null, List.of(AlarmSeverity.CRITICAL));
getWsClient().send(cmd);
AlarmStatusUpdate update = JacksonUtil.fromString(getWsClient().waitForReply(), AlarmStatusUpdate.class);
Assert.assertEquals(1, update.getCmdId());
Assert.assertFalse(update.isActive());
//create alarm
getWsClient().registerWaitForUpdate();
Alarm alarm = Alarm.builder()
.originator(device.getId())
.severity(AlarmSeverity.CRITICAL)
.type("test_type")
.propagate(true)
.build();
alarm = doPost("/api/alarm", alarm, Alarm.class);
Assert.assertNotNull(alarm);
// check no update for asset
String msg = getWsClient().waitForUpdate(TimeUnit.SECONDS.toMillis(1));
Assert.assertNull(msg);
// check device
AlarmStatusCmd deviceCmd = new AlarmStatusCmd(2, device.getId(), null, List.of(AlarmSeverity.CRITICAL));
getWsClient().send(deviceCmd);
AlarmStatusUpdate deviceUpdate = JacksonUtil.fromString(getWsClient().waitForReply(), AlarmStatusUpdate.class);
Assert.assertEquals(2, deviceUpdate.getCmdId());
Assert.assertTrue(deviceUpdate.isActive());
}
@Test @Test
public void testAlarmStatusWsCmdWithMaxAlarmsCacheSize() throws Exception { public void testAlarmStatusWsCmdWithMaxAlarmsCacheSize() throws Exception {
loginTenantAdmin(); loginTenantAdmin();

15
common/edge-api/src/main/java/org/thingsboard/edge/rpc/EdgeGrpcClient.java

@ -136,12 +136,25 @@ public class EdgeGrpcClient implements EdgeRpcClient {
.setConnectRequestMsg(ConnectRequestMsg.newBuilder() .setConnectRequestMsg(ConnectRequestMsg.newBuilder()
.setEdgeRoutingKey(edgeKey) .setEdgeRoutingKey(edgeKey)
.setEdgeSecret(edgeSecret) .setEdgeSecret(edgeSecret)
.setEdgeVersion(EdgeVersion.V_4_3_0) .setEdgeVersion(getNewestEdgeVersion())
.setMaxInboundMessageSize(maxInboundMessageSize) .setMaxInboundMessageSize(maxInboundMessageSize)
.build()) .build())
.build()); .build());
} }
public static EdgeVersion getNewestEdgeVersion() {
EdgeVersion newest = null;
for (EdgeVersion v : EdgeVersion.values()) {
if (v == EdgeVersion.V_LATEST || v == EdgeVersion.UNRECOGNIZED) {
continue;
}
if (newest == null || v.getNumber() > newest.getNumber()) {
newest = v;
}
}
return newest;
}
private StreamObserver<ResponseMsg> initOutputStream(String edgeKey, private StreamObserver<ResponseMsg> initOutputStream(String edgeKey,
Consumer<UplinkResponseMsg> onUplinkResponse, Consumer<UplinkResponseMsg> onUplinkResponse,
Consumer<EdgeConfiguration> onEdgeUpdate, Consumer<EdgeConfiguration> onEdgeUpdate,

4
common/queue/pom.xml

@ -68,6 +68,10 @@
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.google.cloud</groupId> <groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId> <artifactId>google-cloud-pubsub</artifactId>

14
pom.xml

@ -63,7 +63,7 @@
<curator.version>5.6.0</curator.version> <curator.version>5.6.0</curator.version>
<zookeeper.version>3.9.3</zookeeper.version> <zookeeper.version>3.9.3</zookeeper.version>
<protobuf.version>3.25.5</protobuf.version> <!-- A Major v4 does not support by the pubsub yet--> <protobuf.version>3.25.5</protobuf.version> <!-- A Major v4 does not support by the pubsub yet-->
<grpc.version>1.68.1</grpc.version> <grpc.version>1.76.0</grpc.version>
<tbel.version>1.2.8</tbel.version> <tbel.version>1.2.8</tbel.version>
<lombok.version>1.18.38</lombok.version> <lombok.version>1.18.38</lombok.version>
<paho.client.version>1.2.5</paho.client.version> <paho.client.version>1.2.5</paho.client.version>
@ -86,6 +86,7 @@
org.apache.kafka.common.network.NetworkReceive class in the application module. It addresses the issue https://issues.apache.org/jira/browse/KAFKA-4090. org.apache.kafka.common.network.NetworkReceive class in the application module. It addresses the issue https://issues.apache.org/jira/browse/KAFKA-4090.
Here is the source to track https://github.com/apache/kafka/tree/trunk/clients/src/main/java/org/apache/kafka/common/network --> Here is the source to track https://github.com/apache/kafka/tree/trunk/clients/src/main/java/org/apache/kafka/common/network -->
<kafka.version>3.9.1</kafka.version> <kafka.version>3.9.1</kafka.version>
<lz4.version>1.8.1</lz4.version> <!-- to fix CVE-2025-12183 introduced through kafka-clients 3.9.1 TODO: remove when kafka-clients is bumped -->
<bucket4j.version>8.10.1</bucket4j.version> <bucket4j.version>8.10.1</bucket4j.version>
<antlr.version>3.5.3</antlr.version> <antlr.version>3.5.3</antlr.version>
<snakeyaml.version>2.2</snakeyaml.version> <snakeyaml.version>2.2</snakeyaml.version>
@ -1153,6 +1154,17 @@
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
<version>${kafka.version}</version> <version>${kafka.version}</version>
<exclusions>
<exclusion>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
<version>${lz4.version}</version> <!-- to fix CVE introduced through kafka-clients 3.9.1 -->
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.springtestdbunit</groupId> <groupId>com.github.springtestdbunit</groupId>

4
rule-engine/rule-engine-components/pom.xml

@ -96,6 +96,10 @@
<groupId>org.apache.kafka</groupId> <groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId> <artifactId>kafka-clients</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.lz4</groupId>
<artifactId>lz4-java</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sns</artifactId> <artifactId>aws-java-sdk-sns</artifactId>

18
ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.html

@ -30,39 +30,39 @@
<mat-tab-group [(selectedIndex)]="tabIndex" (selectedTabChange)="selectedTabChange(tabIndex)"> <mat-tab-group [(selectedIndex)]="tabIndex" (selectedTabChange)="selectedTabChange(tabIndex)">
<mat-tab> <mat-tab>
<ng-template mat-tab-label> <ng-template mat-tab-label>
<mat-icon class="tabs-icon" svgIcon="mdi:ubuntu"></mat-icon> <mat-icon class="tabs-icon" svgIcon="docker"></mat-icon>
Ubuntu Docker
</ng-template> </ng-template>
<ng-template matTabContent> <ng-template matTabContent>
<div class="tb-form-panel no-padding no-border"> <div class="tb-form-panel no-padding no-border">
<div class="tb-form-panel no-padding stroked"> <div class="tb-form-panel no-padding stroked">
<tb-markdown [data]='contentData.ubuntu'></tb-markdown> <tb-markdown [data]='contentData.docker'></tb-markdown>
</div> </div>
</div> </div>
</ng-template> </ng-template>
</mat-tab> </mat-tab>
<mat-tab> <mat-tab>
<ng-template mat-tab-label> <ng-template mat-tab-label>
<mat-icon class="tabs-icon" svgIcon="mdi:centos"></mat-icon> <mat-icon class="tabs-icon" svgIcon="mdi:ubuntu"></mat-icon>
CentOS/RHEL Ubuntu
</ng-template> </ng-template>
<ng-template matTabContent> <ng-template matTabContent>
<div class="tb-form-panel no-padding no-border"> <div class="tb-form-panel no-padding no-border">
<div class="tb-form-panel no-padding stroked"> <div class="tb-form-panel no-padding stroked">
<tb-markdown [data]='contentData.centos'></tb-markdown> <tb-markdown [data]='contentData.ubuntu'></tb-markdown>
</div> </div>
</div> </div>
</ng-template> </ng-template>
</mat-tab> </mat-tab>
<mat-tab> <mat-tab>
<ng-template mat-tab-label> <ng-template mat-tab-label>
<mat-icon class="tabs-icon" svgIcon="docker"></mat-icon> <mat-icon class="tabs-icon" svgIcon="mdi:centos"></mat-icon>
Docker CentOS/RHEL
</ng-template> </ng-template>
<ng-template matTabContent> <ng-template matTabContent>
<div class="tb-form-panel no-padding no-border"> <div class="tb-form-panel no-padding no-border">
<div class="tb-form-panel no-padding stroked"> <div class="tb-form-panel no-padding stroked">
<tb-markdown [data]='contentData.docker'></tb-markdown> <tb-markdown [data]='contentData.centos'></tb-markdown>
</div> </div>
</div> </div>
</ng-template> </ng-template>

4
ui-ngx/src/app/shared/models/edge.models.ts

@ -184,9 +184,9 @@ export interface EdgeInstructions {
} }
export enum EdgeInstructionsMethod { export enum EdgeInstructionsMethod {
docker,
ubuntu, ubuntu,
centos, centos
docker
} }
export const edgeVersionAttributeKey = 'edgeVersion'; export const edgeVersionAttributeKey = 'edgeVersion';

Loading…
Cancel
Save