Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem]: How can I start iobroker-slave-container with existing ioBroker instance? #335

Closed
Martin4us3 opened this issue Apr 17, 2023 · 7 comments
Assignees
Labels
bug This issue is confirmed. work in progress A solution is work in progress.

Comments

@Martin4us3
Copy link

Martin4us3 commented Apr 17, 2023

Description

Hi,
I restored a Docker ioBroker container from backupfile of my RaspPi - works perfect.
After that I switched db to redis and created an additional ioBroker-slave-container.

After restart of the slave container the iob-docker-script tried to rename the ioBroker-slave and crashed.
If I set the env IOB_MULTIHOST=slave, the srcipt try to renew the db-connection and delete all my states.

How can I start the slave-container with my existing instance? ...without any changes from the script.

Image version

buanet/iobroker:latest-v8

Docker logs

--------------------------------------------------------------------------------
-------------------------     2023-04-17 18:20:24      -------------------------
--------------------------------------------------------------------------------
-----                                                                      -----
----- ██╗  ██████╗  ██████╗  ██████╗   ██████╗  ██╗  ██╗ ███████╗ ██████╗  -----
----- ██║ ██╔═══██╗ ██╔══██╗ ██╔══██╗ ██╔═══██╗ ██║ ██╔╝ ██╔════╝ ██╔══██╗ -----
----- ██║ ██║   ██║ ██████╔╝ ██████╔╝ ██║   ██║ █████╔╝  █████╗   ██████╔╝ -----
----- ██║ ██║   ██║ ██╔══██╗ ██╔══██╗ ██║   ██║ ██╔═██╗  ██╔══╝   ██╔══██╗ -----
----- ██║ ╚██████╔╝ ██████╔╝ ██║  ██║ ╚██████╔╝ ██║  ██╗ ███████╗ ██║  ██║ -----
----- ╚═╝  ╚═════╝  ╚═════╝  ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═╝ ╚══════╝ ╚═╝  ╚═╝ -----
-----                                                                      -----
-----              Welcome to your ioBroker Docker container!              -----
-----                    Startupscript is now running!                     -----
-----                          Please be patient!                          -----
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
-----                          System Information                          -----
-----                    arch:                x86_64                       -----
-----                    hostname:            iob_slave                    -----
-----                                                                      -----
-----                          Version Information                         -----
-----                    image:               v8.0.0                       -----
-----                    build:               2023-04-07T23:45:19+00:00    -----
-----                    node:                v18.16.0                     -----
-----                    npm:                 9.5.1                        -----
-----                                                                      -----
-----                        Environment Variables                         -----
-----                    SETGID:              1000                         -----
-----                    SETUID:              1000                         -----
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
-----                   Step 1 of 5: Preparing container                   -----
--------------------------------------------------------------------------------
 
Updating Linux packages on first run... Done.
 
Registering maintenance script as command... Done.
 
--------------------------------------------------------------------------------
-----             Step 2 of 5: Detecting ioBroker installation             -----
--------------------------------------------------------------------------------
 
Existing installation of ioBroker detected in "/opt/iobroker".
 
--------------------------------------------------------------------------------
-----             Step 3 of 5: Checking ioBroker installation              -----
--------------------------------------------------------------------------------
 
(Re)setting permissions (This might take a while! Please be patient!)... Done.
 
Fixing "sudo-bug" by replacing sudo with gosu... Done.
 
Checking Database connection... Done.
 
Hostname in ioBroker does not match the hostname of this container.
Cannot execute changes on running system. Stop iobroker first.
Updating hostname to "iob_slave"... 
@buanet
Copy link
Owner

buanet commented Apr 17, 2023

Full log please!

@Martin4us3
Copy link
Author

Full log please!

The container restart, so the log repeated

@buanet
Copy link
Owner

buanet commented Apr 17, 2023

See header "Environment Variables". Your Multihost variable is not set. Please check your configuration. How do you start your container?

@Martin4us3
Copy link
Author

Martin4us3 commented Apr 17, 2023

See header "Environment Variables". Your Multihost variable is not set. Please check your configuration.

as I wrote ...

If I set IOB_MULTIHOST=slave, I get this ...

Docker logs

--------------------------------------------------------------------------------
-------------------------     2023-04-17 18:29:04      -------------------------
--------------------------------------------------------------------------------
-----                                                                      -----
----- ██╗  ██████╗  ██████╗  ██████╗   ██████╗  ██╗  ██╗ ███████╗ ██████╗  -----
----- ██║ ██╔═══██╗ ██╔══██╗ ██╔══██╗ ██╔═══██╗ ██║ ██╔╝ ██╔════╝ ██╔══██╗ -----
----- ██║ ██║   ██║ ██████╔╝ ██████╔╝ ██║   ██║ █████╔╝  █████╗   ██████╔╝ -----
----- ██║ ██║   ██║ ██╔══██╗ ██╔══██╗ ██║   ██║ ██╔═██╗  ██╔══╝   ██╔══██╗ -----
----- ██║ ╚██████╔╝ ██████╔╝ ██║  ██║ ╚██████╔╝ ██║  ██╗ ███████╗ ██║  ██║ -----
----- ╚═╝  ╚═════╝  ╚═════╝  ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═╝ ╚══════╝ ╚═╝  ╚═╝ -----
-----                                                                      -----
-----              Welcome to your ioBroker Docker container!              -----
-----                    Startupscript is now running!                     -----
-----                          Please be patient!                          -----
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
-----                          System Information                          -----
-----                    arch:                x86_64                       -----
-----                    hostname:            iob_slave                    -----
-----                                                                      -----
-----                          Version Information                         -----
-----                    image:               v8.0.0                       -----
-----                    build:               2023-04-07T23:45:19+00:00    -----
-----                    node:                v18.16.0                     -----
-----                    npm:                 9.5.1                        -----
-----                                                                      -----
-----                        Environment Variables                         -----
-----                    IOB_MULTIHOST:       slave                        -----
-----                    SETGID:              1000                         -----
-----                    SETUID:              1000                         -----
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
-----                   Step 1 of 5: Preparing container                   -----
--------------------------------------------------------------------------------
 
Updating Linux packages on first run... Done.
 
Registering maintenance script as command... Done.
 
--------------------------------------------------------------------------------
-----             Step 2 of 5: Detecting ioBroker installation             -----
--------------------------------------------------------------------------------
 
Existing installation of ioBroker detected in "/opt/iobroker".
 
--------------------------------------------------------------------------------
-----             Step 3 of 5: Checking ioBroker installation              -----
--------------------------------------------------------------------------------
 
(Re)setting permissions (This might take a while! Please be patient!)... Done.
 
Fixing "sudo-bug" by replacing sudo with gosu... Done.
 
IOB_MULTIHOST is available and set to "slave".
Done.
 
 
Something went wrong. Looks like at least one parameter defining the custom db connection was not set properly or is missing.
Please check your configuration and try again.
For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/).
 
This Script will exit now.

if I set IOB_OBJECTSDB_TYPE, ..._HOST, ..._PORT, ... the script overwrite my object db

How do you start your container?

I have stack with three container ...

  • host
  • slave
  • redis
    ...and start the stack with portainer.

redis and host works fine. slave restart again and again.

@buanet
Copy link
Owner

buanet commented Apr 17, 2023

I've tested this and found an issue which may cause the described behaviour. So since v8 setting up a new slave (empty directory) causes an "iobroker setup first" call as the script is thinking it is a fresh iobroker instance.
I build a hotfix which makes sure this will not be called mehr IOB_MULTIHOST=slave.
I`ll test this and, if successful, release v8.0.1 Hotfix Release.

Regards,
André

@buanet buanet self-assigned this Apr 17, 2023
@buanet buanet added bug This issue is confirmed. work in progress A solution is work in progress. labels Apr 17, 2023
@buanet
Copy link
Owner

buanet commented Apr 18, 2023

I just released the v8.0.1 hotfix.

My tests were successful.
Make sure you use a valid configuration with all needed environment variables. Here the example from my test environment.

version: "3"
services:
  ####### iobroker #######
  iobroker:
    container_name: iobrokertest
    image: buanet/iobroker:latest
    hostname: iobrokertest
    restart: always
    networks:
      macvlan:
        ipv4_address: 192.168.11.41
      bridge:
    environment:
      - PACKAGES=nano
      - IOB_MULTIHOST=master
      - IOB_STATESDB_HOST=redis
      - IOB_STATESDB_PORT=6379
      - IOB_STATESDB_TYPE=redis
      - IOB_OBJECTSDB_HOST=redis
      - IOB_OBJECTSDB_PORT=6379
      - IOB_OBJECTSDB_TYPE=redis
      - DEBUG=true
    volumes:
      - /volume1/docker/iobrokertest_335_data:/opt/iobroker
    depends_on:
      - redis
  ####### iobroker-slave #######
  iobroker-slave:
    container_name: iobrokertest-slave
    image: buanet/iobroker:latest
    hostname: iobrokertest-slave
    restart: always
    networks:
      macvlan:
        ipv4_address: 192.168.11.42
      bridge:
    environment:
      - PACKAGES=nano
      - IOB_MULTIHOST=slave
      - IOB_STATESDB_HOST=redis
      - IOB_STATESDB_PORT=6379
      - IOB_STATESDB_TYPE=redis
      - IOB_OBJECTSDB_HOST=redis
      - IOB_OBJECTSDB_PORT=6379
      - IOB_OBJECTSDB_TYPE=redis
      - DEBUG=true
    volumes:
      - /volume1/docker/iobrokertest-slave_335_data:/opt/iobroker
    depends_on:
      - redis
      - iobroker
  ####### redis #######
  redis:
    container_name: redis
    image: redis:latest
    hostname: redis
    restart: always
    networks:
      bridge:
#    ports:
#      - "6379:6379"
    volumes:
      - /volume1/docker/redis_335_data:/data

####### Netzwerke #######
networks:
  macvlan:
    driver: macvlan
    driver_opts:
      parent: eth0
    ipam:
      config:
        - subnet: 192.168.11.0/24
          gateway: 192.168.11.1
          ip_range: 192.168.11.40/29
          aux_addresses:
            net-address: 192.168.11.40
  bridge:
    driver: bridge
    ipam:
      config:
        - subnet: 172.18.0.0/16
          gateway: 172.18.0.1
          ip_range: 172.18.0.1/24

Slave log should look like this:

--------------------------------------------------------------------------------
-------------------------     2023-04-18 07:37:02      -------------------------
--------------------------------------------------------------------------------
-----                                                                      -----
----- ██╗  ██████╗  ██████╗  ██████╗   ██████╗  ██╗  ██╗ ███████╗ ██████╗  -----
----- ██║ ██╔═══██╗ ██╔══██╗ ██╔══██╗ ██╔═══██╗ ██║ ██╔╝ ██╔════╝ ██╔══██╗ -----
----- ██║ ██║   ██║ ██████╔╝ ██████╔╝ ██║   ██║ █████╔╝  █████╗   ██████╔╝ -----
----- ██║ ██║   ██║ ██╔══██╗ ██╔══██╗ ██║   ██║ ██╔═██╗  ██╔══╝   ██╔══██╗ -----
----- ██║ ╚██████╔╝ ██████╔╝ ██║  ██║ ╚██████╔╝ ██║  ██╗ ███████╗ ██║  ██║ -----
----- ╚═╝  ╚═════╝  ╚═════╝  ╚═╝  ╚═╝  ╚═════╝  ╚═╝  ╚═╝ ╚══════╝ ╚═╝  ╚═╝ -----
-----                                                                      -----
-----              Welcome to your ioBroker Docker container!              -----
-----                    Startupscript is now running!                     -----
-----                          Please be patient!                          -----
--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------
-----                          System Information                          -----
-----                    arch:                x86_64                       -----
-----                    hostname:            iobrokertest-slave           -----
-----                                                                      -----
-----                          Version Information                         -----
-----                    image:               v8.0.1                       -----
-----                    build:               2023-04-17T18:54:13+00:00    -----
-----                    node:                v18.16.0                     -----
-----                    npm:                 9.5.1                        -----
-----                                                                      -----
-----                        Environment Variables                         -----
-----                    DEBUG:               true                         -----
-----                    IOB_MULTIHOST:       slave                        -----
-----                    IOB_OBJECTSDB_TYPE:  redis                        -----
-----                    IOB_OBJECTSDB_HOST:  redis                        -----
-----                    IOB_OBJECTSDB_PORT:  6379                         -----
-----                    IOB_STATESDB_TYPE:   redis                        -----
-----                    IOB_STATESDB_HOST:   redis                        -----
-----                    IOB_STATESDB_PORT:   6379                         -----
-----                    PACKAGES:            nano                         -----
-----                    SETGID:              1000                         -----
-----                    SETUID:              1000                         -----
--------------------------------------------------------------------------------
 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!                            DEBUG LOG ACTIVE                            !!!!
!!!!               Environment variable DEBUG is set to true.               !!!!
!!!! This will extend the logging output and may slow down container start. !!!!
!!!!          Please make sure to deactivate if no longer needed.           !!!!
!!!!     For more information see ioBroker Docker image documentation:      !!!!
!!!!           https://docs.buanet.de/iobroker-docker-image/docs/           !!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
--------------------------------------------------------------------------------
-----                   Step 1 of 5: Preparing container                   -----
--------------------------------------------------------------------------------
 
Updating Linux packages on first run... Done.
 
PACKAGES is set. Installing the following additional Linux packages: nano unzip iputils-ping
 
nano is not installed. Installing... Done.
Registering maintenance script as command... Done.
 
--------------------------------------------------------------------------------
-----             Step 2 of 5: Detecting ioBroker installation             -----
--------------------------------------------------------------------------------
 
There is no data detected in /opt/iobroker.
Restoring initial ioBroker installation... Done.
 
--------------------------------------------------------------------------------
-----             Step 3 of 5: Checking ioBroker installation              -----
--------------------------------------------------------------------------------
 
(Re)setting permissions (This might take a while! Please be patient!)... Done.
 
Fixing "sudo-bug" by replacing sudo with gosu... Done.
 
IOB_MULTIHOST is available and set to "slave".
Done.
 
Configuring objects db connection...
IOB_OBJECTSDB_TYPE is available but value is different from detected ioBroker installation.
Setting type of objects db to "redis"... Done.
IOB_OBJECTSDB_HOST is available but value is different from detected ioBroker installation.
Setting host of objects db to "redis"... Done.
IOB_OBJECTSDB_PORT is available but value is different from detected ioBroker installation.
Setting port of objects db to "6379"... Done.
Done.
 
Configuring states db connection...
IOB_STATESDB_TYPE is available but value is different from detected ioBroker installation.
Setting type of states db to "redis"... Done.
IOB_STATESDB_HOST is available but value is different from detected ioBroker installation.
Setting host of states db to "redis"... Done.
IOB_STATESDB_PORT is available but value is different from detected ioBroker installation.
Setting port of states db to "6379"... Done.
Done.
 
Checking Database connection... Done.
 
IOB_MULTIHOST is set to "slave". Hostname check will be skipped.
 
--------------------------------------------------------------------------------
-----                Step 4 of 5: Applying special settings                -----
--------------------------------------------------------------------------------
 
Some adapters have special requirements/ settings which can be activated by the use of environment variables.
For more information see ioBroker Docker Image Docs (https://docs.buanet.de/iobroker-docker-image/docs/).
 
 
--------------------------------------------------------------------------------
-----                    Step 5 of 5: ioBroker startup                     -----
--------------------------------------------------------------------------------
 
Starting ioBroker... 
 
##### #### ### ## # iobroker.js-controller log output # ## ### #### #####
================================== > LOG REDIRECT system.adapter.admin.0 => true [starting]
host.iobrokertest-slave check instance "system.adapter.admin.0" for host "iobrokertest"
host.iobrokertest-slave check instance "system.adapter.web.0" for host "iobrokertest"
host.iobrokertest-slave check instance "system.adapter.backitup.0" for host "iobrokertest"
host.iobrokertest-slave check instance "system.adapter.discovery.0" for host "iobrokertest"

Please test and give feedback.
Thank you.

Regards,
André

@Martin4us3
Copy link
Author

Hi André,
thank you very much.

I just tested the fix and everything works great.

Thank you for the quick support.

Best Regards
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is confirmed. work in progress A solution is work in progress.
Projects
None yet
Development

No branches or pull requests

2 participants