Skip to content

Draft: New/multiple tango dbs

Michał Gandor requested to merge new/multiple-tango-dbs into develop

Description

Partial support for multiple tangoDBs on early stage!

image image image multidb

I'm storing a tangodb info in device path, most of the widgets work - I do not want to put more efford on that if it goes wrong direction.

  • After digging for couple of days, I'm considering if it will not be able to glue tangodb on the level of DeviceConsumer and always send the full paths (it may solve issue with command widget not working now). The drawback it that showing the names would require some work (eg. list of devices on sidebar)
  • would it be better to have a separate field storing tangoDb only along with device name? It will require much more work in my opinion.
  • while changing the tangodb page refreshes to load devices. Is that a problem?
  • tangodbs are hardcoded in config.json file
  • on the left sidebar name of device is display along with tangodb name

To run the MR and test, you need to have more tangodbs running; below I send an example configuration I'm using:

setupProxy:

const proxy = require("http-proxy-middleware");
const config = require("./config.json");

const proxies = {
  "/testdb/socket": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
    ws: true,
  },
  "/testdb/db": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/testdb1/socket": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
    ws: true,
  },
  "/testdb1/db": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/testdb2/socket": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/testdb2/db": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/auth": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/dashboards": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/logs": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
  "/elasticsearch/_search": {
    target: "http://localhost:22484",
    secure: false,
    changeOrigin: true,
  },
};
module.exports = function(app) {
  Object.entries(proxies).forEach(([endpoint, setting]) => {
    app.use(proxy(endpoint, setting));
  });
};

docker-compose:

version: "3"

volumes:
  mongodb: {}

services:
  database:
    image: tangocs/mysql:latest
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=1
  control-system:
    image: tangocs/tango-cs:latest
    environment:
      - ORB_PORT=10000
      - TANGO_HOST=127.0.0.1:10000
      - MYSQL_HOST=database:3306
      - MYSQL_USER=tango
      - MYSQL_PASSWORD=tango
      - MYSQL_DATABASE=tango
  tango-test:
    build: tango-test
    environment:
      - TANGO_HOST=control-system:10000
      - WAIT_HOSTS=control-system:10000
    depends_on:
      - control-system
  tangogql:
    build: tangogql
    restart: always
    depends_on:
      - database
      - control-system
    environment:
      - TANGO_HOST=control-system:10000
    volumes:
      - ./config.json:/tangogql/config.json:ro
    labels:
      - "traefik.frontend.rule=Host:localhost; PathPrefix: /testdb/db, /testdb/socket, /testdb/graphiql; ReplacePathRegex: ^/testdb/((?:db|socket|graphiql.*?)/?)/?$$ /$$1"
      - "traefik.port=5004"
  database1:
    image: tangocs/mysql:latest
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=1
      - MYSQL_TCP_PORT=3307
  control-system1:
    image: tangocs/tango-cs:latest
    environment:
      - ORB_PORT=10001
      - TANGO_HOST=127.0.0.1:10001
      - MYSQL_HOST=database1:3307
      - MYSQL_USER=tango
      - MYSQL_PASSWORD=tango
      - MYSQL_DATABASE=tango
  tango-test1:
    build: tango-test
    environment:
      - TANGO_HOST=control-system1:10001
      - WAIT_HOSTS=control-system1:10001
    depends_on:
      - control-system1
  tangogql1:
    build: tangogql
    restart: always
    depends_on:
      - database1
      - control-system1
    environment:
      - TANGO_HOST=control-system1:10001
    volumes:
      - ./config.json:/tangogql/config.json:ro
    labels:
      - "traefik.frontend.rule=Host:localhost; PathPrefix: /testdb1/db, /testdb1/socket, /testdb1/graphiql; ReplacePathRegex: ^/testdb1/((?:db|socket|graphiql.*?)/?)/?$$ /$$1"
      - "traefik.port=5004"
  database2:
    image: tangocs/mysql:latest
    environment:
      - MYSQL_ALLOW_EMPTY_PASSWORD=1
      - MYSQL_TCP_PORT=3308
  control-system2:
    image: tangocs/tango-cs:latest
    environment:
      - ORB_PORT=10002
      - TANGO_HOST=127.0.0.1:10002
      - MYSQL_HOST=database2:3308
      - MYSQL_USER=tango
      - MYSQL_PASSWORD=tango
      - MYSQL_DATABASE=tango
  tango-test2:
    build: tango-test
    environment:
      - TANGO_HOST=control-system2:10002
      - WAIT_HOSTS=control-system2:10002
    depends_on:
      - control-system2
  tangogql2:
    build: tangogql
    restart: always
    depends_on:
      - database2
      - control-system2
    environment:
      - TANGO_HOST=control-system2:10002
    volumes:
      - ./config.json:/tangogql/config.json:ro
    labels:
      - "traefik.frontend.rule=Host:localhost; PathPrefix: /testdb2/db, /testdb2/socket, /testdb2/graphiql; ReplacePathRegex: ^/testdb2/((?:db|socket|graphiql.*?)/?)/?$$ /$$1"
  auth:
    build: taranta-auth
    environment:
      - SECRET=s3cr3t
    volumes:
      - ./users.json:/var/users.json:ro
    labels:
      - "traefik.frontend.rule=Host:localhost; PathPrefixStrip: /auth"
      - "traefik.port=8080"
  dashboards:
    build: taranta-dashboard
    environment:
      - MONGO_HOST=mongodb://mongodb/dashboards
      - SECRET=s3cr3t
    depends_on:
      - mongodb
    labels:
      - "traefik.frontend.rule=Host:localhost; PathPrefix: /dashboards"
      - "traefik.port=3012"
  mongodb:
    image: mongo:3.6-stretch
    volumes:
      - mongodb:/data/db
  traefik:
    image: traefik:1.7-alpine
    command: --docker
    ports:
      - 22484:80
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Motivation

Background on use case, changes needed

Fixes:

  • Items added

Changes:

  • changes made

Tests included/Docs Updated?

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)
  • Docs updated?
  • New packages used/requires npm install?
  • Toggle added for new features?
Edited by Michał Gandor

Merge request reports