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

Multiple instances of MqDockerUp conflict with each other #261

Open
chriswood1001 opened this issue Mar 14, 2024 · 9 comments
Open

Multiple instances of MqDockerUp conflict with each other #261

chriswood1001 opened this issue Mar 14, 2024 · 9 comments

Comments

@chriswood1001
Copy link

I have several docker instances on different computers, each running MqDockerUp. I'm able to successfully differentiate between the updates by having unique mqtt topics and mqtt clientID's.

However, the home assistant mqtt discovery data conflicts when the same container exists on both docker instances.

My config for docker server one:

main:
  interval: "5m"

mqtt:
  connectionUri: "mqtt://192.168.10.100:1883"
  topic: "mqdockerup/server_one"
  clientId: "mqdockerup_server_one"
  username: "homeassistant"
  password: "password"
  connectTimeout: 60
  protocolVersion: 5

accessTokens:
  dockerhub:
  github:

And, my config for docker server two:

main:
  interval: "5m"

mqtt:
  connectionUri: "mqtt://192.168.10.100:1883"
  topic: "mqdockerup/server_two"
  clientId: "mqdockerup_server_two"
  username: "homeassistant"
  password: "password"
  connectTimeout: 60
  protocolVersion: 5

accessTokens:
  dockerhub:
  github:

Using MQTT Explorer I see the status reported as expected, without conflict.

/mqdockerup/server_one/ <my containers>
/mqdockerup/server_two/ <my containers>

However, the Home Assistant discover data conflicts as both servers try to write to:

/homeassistant/sensor/micrib_mqdockerup_latest/

Is there a way to address this?

@MichelFR
Copy link
Owner

MichelFR commented Mar 14, 2024

Since its not my use case to use MqDockerUp on multiple nodes i cannot assure that everything works fine.

One way to possibly fix this is to use the prefix configuration:

main:
interval: "5m"
prefix: "server_one"

main:
interval: "5m"
prefix: "server_two"

I hope this helps.

@chriswood1001
Copy link
Author

Thanks for the quick reply. Including "prefix:server_one" does append "server_one" to the MQTT path, but unfortunately it doesn't append it to the MQTT value so Home Assistant is still confused.

What works
config.yaml

mqtt:
  topic: "mqdockerup/server_one"

This allows us to have multiple servers with their prefix.

\mqdockerup\server_one\mqdockerup\
\mqdockerup\server_two\mqdockerup\

What partially works
config.yaml

main:
  prefix: "server_one"

This creates the MQTT entry under the correct path, but the data doesn't include this prefix in the object_id and unique_id, so home assistant (incorrectly) treats them as one device.

\homeassistant\sensor\server_one_micrib_mqdockerup_latest

{
	"object_id": "micrib/mqdockerup Container ID",  <-- ideally would have "server_one/" prefix
	"name": "Container ID",
	"unique_id": "micrib/mqdockerup Container ID",   <-- ideally would have "server_one/" prefix
	"state_topic": "mqdockerup/server_one/micrib_mqdockerup", <-- correct
	"device_class": null,
	"value_template": "{{ value_json.dockerId }}",
	"availability": {
		"topic": "mqdockerup/server_one/availability"
	},
	"payload_available": "Online",
	"payload_not_available": "Offline",
	"device": {
		"manufacturer": "MqDockerUp",
		"model": "micrib/mqdockerup:latest",
		"name": "server_one_mqdockerup",   <-- correct
		"sw_version": "1.8.0",
		"sa": "Docker",
		"identifiers": [
			"micrib/mqdockerup_latest"   <-- unsure 
		]
	},
}

I presume that's what's causing home assistant to only see one container despite it existing on two servers.

@atv2016
Copy link

atv2016 commented Apr 6, 2024

@chriswood1001 Were you able to resolve this? Duplicate containers on different hosts keep overwriting each other's entries in home assistant, no matter if I set :

      MAIN_PREFIX: "mqtt_homeassistant"
      MQTT_TOPIC: "mqtt_homeassistant"

@chriswood1001
Copy link
Author

Unfortunately, no.

@atv2016
Copy link

atv2016 commented Apr 7, 2024

@MichelFR It looks like the prefix and topic settings are not working. Even if I enable this on 2 different hosts, the entries overwrite each other. Can this be looked into please?

I know it's not your use case but it might be in the future ;-)

@MichelFR
Copy link
Owner

MichelFR commented Apr 7, 2024

@MichelFR It looks like the prefix and topic settings are not working. Even if I enable this on 2 different hosts, the entries overwrite each other. Can this be looked into please?

I know it's not your use case but it might be in the future ;-)

Yeah I'm sorry I currently had not the time to look into this one. And since it's not one of my use cases I don't see it as critical.
But I can assure you I'm gonna look into this.
It's not that difficult to fix this I guess.

@atv2016
Copy link

atv2016 commented Apr 7, 2024

Many thanks @MichelFR.

In the meantime, I would probably be able to solve my situation by excluding the containers that are overwriting each other. For example, on 2 nodes I have mqdockerup and portioner running, which are overwriting each other. Can I exclude those ?

@boehser-enkel
Copy link

I have also this use case

@lodesmets
Copy link

With setting them both with a different prefix it works. But when updating a container, the other instance always creashes because container not found:
`11.09.2024 13:02:53 [error] Error: (HTTP code 404) no such container - No such container: 252176fb3c8183d1937e2c6d43314a7a49308351fc6ea0f134180694a3f62b43

at /app/node_modules/docker-modem/lib/modem.js:382:17

at getCause (/app/node_modules/docker-modem/lib/modem.js:417:7)

at Modem.buildPayload (/app/node_modules/docker-modem/lib/modem.js:378:5)

at IncomingMessage.<anonymous> (/app/node_modules/docker-modem/lib/modem.js:346:16)

at IncomingMessage.emit (node:events:529:35)

at IncomingMessage.emit (node:domain:489:12)

at endReadableNT (node:internal/streams/readable:1400:12)

at processTicksAndRejections (node:internal/process/task_queues:82:21)`

Setting them with different MQTT_TOPIC sadly doesn't work. Because then if I press update container in home assistant, it doesn't update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants