ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
268 stars 34 forks source link

Sensor disappearing when updating container using Portainer #46

Closed tarikdenboer closed 1 month ago

tarikdenboer commented 3 years ago

I sometimes use Portianer (CE) to update my docker containers though the 'Recreate' option. When doing so the Docker Monitor sensors associated with the updated container in HA seem to disappear, no entities are can be found.

After restarting HA the sensors come back and everything works fine again.

Running Docker and HA on Synology. The Docker Monitor version I have installed is 1.5.

When updating in another way, through DSM for example, it works fine.

I there something of a time out that removes the entities?

ualex73 commented 3 years ago

Do you have some more logging when this happens? I myself don't use portainer (but I will have a look too)

networkpotato commented 3 years ago

Same problem here.

mrask90 commented 3 years ago

Noticed the same issue here.

rotem925 commented 3 years ago

The same issue. It is not related to Portainer, when you re-create the container I can see this happen. re-create can happen when you update a container image.

IDmedia commented 3 years ago

I can confirm this issue. Happens when I recreate any container

ualex73 commented 3 years ago

Can you enable debug logging and share the logfile when you get this error? I tried to reproduce it on my system (i5), but I don't get any error.

tarikdenboer commented 3 years ago

@ualex73 I finally found some time to pull some lines from the log file when it happens. In this example I was updating (recreating) the Mosquitto container through Portainer. I have all the most recent versions (HA and Monitor Docker)

2021-04-28 10:20:27 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.monitor_docker 2021-04-28 10:20:27 INFO (MainThread) [homeassistant.components.switch] Setting up switch.monitor_docker 2021-04-28 10:20:27 DEBUG (MainThread) [custom_components.monitor_docker.sensor] Setting up sensor(s) 2021-04-28 10:20:27 DEBUG (MainThread) [custom_components.monitor_docker.sensor] mosquitto: Adding component Sensor(s) 2021-04-28 10:20:27 INFO (MainThread) [custom_components.monitor_docker.sensor] mosquitto: Initializing sensor with parameter: State 2021-04-28 10:20:27 INFO (MainThread) [custom_components.monitor_docker.sensor] mosquitto: Initializing sensor with parameter: Image 2021-04-28 10:20:27 INFO (MainThread) [custom_components.monitor_docker.sensor] mosquitto: Initializing sensor with parameter: Status 2021-04-28 10:20:27 INFO (MainThread) [custom_components.monitor_docker.sensor] mosquitto: Initializing sensor with parameter: Memory 2021-04-28 10:20:27 DEBUG (MainThread) [custom_components.monitor_docker.switch] Setting up switch(es) 2021-04-28 10:20:27 DEBUG (MainThread) [custom_components.monitor_docker.switch] mosquitto: Adding component Switch 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=monitor_docker, service=restart> 2021-04-28 10:20:27 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.dockernas_mosquitto_state 2021-04-28 10:20:27 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.dockernas_mosquitto_image 2021-04-28 10:20:27 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.dockernas_mosquitto_status 2021-04-28 10:20:27 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.dockernas_mosquitto_memory 2021-04-28 10:20:27 ERROR (MainThread) [homeassistant.components.switch] Entity id already exists - ignoring: switch.dockernas_mosquitto 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 28, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "monitor_docker", "service": "restart"}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.782349+00:00", "context": {"id": "7d5b72620c821111b3649e8433e3a293", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 40, "type": "event", "event": {"event_type": "service_registered", "data": {"domain": "monitor_docker", "service": "restart"}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.782349+00:00", "context": {"id": "7d5b72620c821111b3649e8433e3a293", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/gotify/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/diun/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/chronograf/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/bitwarden-server/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/bruceforce-bw_backup/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/grafana/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/watchtower/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/influxdb/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/nodered/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/homeassistant/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/esphome/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/Socat/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/portainer2-ce/json 2021-04-28 10:20:27 DEBUG (Thread-3) [custom_components.monitor_docker.helpers] mosquitto-old: Event destroy container 2021-04-28 10:20:27 DEBUG (Thread-3) [custom_components.monitor_docker.helpers] mosquitto-old: Stopping Container Monitor 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.helpers] mosquitto-old: Cancelling task for container info/stats 2021-04-28 10:20:27 DEBUG (Thread-3) [custom_components.monitor_docker.helpers] mosquitto-old: Removing entities from container 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.switch] mosquitto: Removing switch entity 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.sensor] mosquitto: Removing sensor entity: state 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.sensor] mosquitto: Removing sensor entity: image 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.sensor] mosquitto: Removing sensor entity: status 2021-04-28 10:20:27 INFO (Thread-3) [custom_components.monitor_docker.sensor] mosquitto: Removing sensor entity: memory 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/mosquitto/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/telegraf/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.1.5:2376/containers/vscode/json 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.dockernas_mosquitto, old_state=<state switch.dockernas_mosquitto=on; friendly_name=mosquitto, icon=mdi:docker @ 2021-04-28T09:40:20.142391+02:00>, new_state=None> 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.dockernas_mosquitto_state, old_state=<state sensor.dockernas_mosquitto_state=running; friendly_name=mosquitto State, icon=mdi:checkbox-marked-circle-outline @ 2021-04-28T09:40:31.386536+02:00>, new_state=None> 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.dockernas_mosquitto_image, old_state=<state sensor.dockernas_mosquitto_image=eclipse-mosquitto; friendly_name=mosquitto Image, icon=mdi:information-outline @ 2021-04-28T09:40:31.395092+02:00>, new_state=None> 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.dockernas_mosquitto_status, old_state=<state sensor.dockernas_mosquitto_status=Up 1 month; friendly_name=mosquitto Status, icon=mdi:checkbox-marked-circle-outline @ 2021-04-28T09:40:31.408057+02:00>, new_state=None> 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.dockernas_mosquitto_memory, old_state=<state sensor.dockernas_mosquitto_memory=0.18; unit_of_measurement=MB, friendly_name=mosquitto Memory, icon=mdi:memory @ 2021-04-28T09:40:31.418117+02:00>, new_state=None> 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 25, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "switch.dockernas_mosquitto", "old_state": {"entity_id": "switch.dockernas_mosquitto", "state": "on", "attributes": {"friendly_name": "mosquitto", "icon": "mdi:docker"}, "last_changed": "2021-04-28T07:40:20.142391+00:00", "last_updated": "2021-04-28T07:40:20.142391+00:00", "context": {"id": "374b8f75bb3456b44c60021d52519edc", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.919502+00:00", "context": {"id": "c406d4a8c283b84566d7496ceee65f07", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 25, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_state", "old_state": {"entity_id": "sensor.dockernas_mosquitto_state", "state": "running", "attributes": {"friendly_name": "mosquitto State", "icon": "mdi:checkbox-marked-circle-outline"}, "last_changed": "2021-04-28T07:40:31.386536+00:00", "last_updated": "2021-04-28T07:40:31.386536+00:00", "context": {"id": "6dd92c1431d15d1c6d4d8df80aa1b68c", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920114+00:00", "context": {"id": "fc29361c2b8d64f67a56464482bb7d8d", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 25, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_image", "old_state": {"entity_id": "sensor.dockernas_mosquitto_image", "state": "eclipse-mosquitto", "attributes": {"friendly_name": "mosquitto Image", "icon": "mdi:information-outline"}, "last_changed": "2021-04-28T07:40:31.395092+00:00", "last_updated": "2021-04-28T07:40:31.395092+00:00", "context": {"id": "1c97a679c9842e4810a01566a1e4de59", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920458+00:00", "context": {"id": "10faffb617e7d25b65ccc9fd021808ed", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 25, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_status", "old_state": {"entity_id": "sensor.dockernas_mosquitto_status", "state": "Up 1 month", "attributes": {"friendly_name": "mosquitto Status", "icon": "mdi:checkbox-marked-circle-outline"}, "last_changed": "2021-04-28T07:40:31.408057+00:00", "last_updated": "2021-04-28T07:40:31.408057+00:00", "context": {"id": "20df4611282f6f4071a54df3c93242b8", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920751+00:00", "context": {"id": "854b9ca635d3876da3498b47538e78b8", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085868734496] Sending {"id": 25, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_memory", "old_state": {"entity_id": "sensor.dockernas_mosquitto_memory", "state": "0.18", "attributes": {"unit_of_measurement": "MB", "friendly_name": "mosquitto Memory", "icon": "mdi:memory"}, "last_changed": "2021-04-28T07:40:31.418117+00:00", "last_updated": "2021-04-28T07:40:31.418117+00:00", "context": {"id": "cfbd61e8cf5ee979b13d135349c63482", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.921077+00:00", "context": {"id": "de0f0aff3ab659f8bf4322773fc04bb7", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 37, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "switch.dockernas_mosquitto", "old_state": {"entity_id": "switch.dockernas_mosquitto", "state": "on", "attributes": {"friendly_name": "mosquitto", "icon": "mdi:docker"}, "last_changed": "2021-04-28T07:40:20.142391+00:00", "last_updated": "2021-04-28T07:40:20.142391+00:00", "context": {"id": "374b8f75bb3456b44c60021d52519edc", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.919502+00:00", "context": {"id": "c406d4a8c283b84566d7496ceee65f07", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 37, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_state", "old_state": {"entity_id": "sensor.dockernas_mosquitto_state", "state": "running", "attributes": {"friendly_name": "mosquitto State", "icon": "mdi:checkbox-marked-circle-outline"}, "last_changed": "2021-04-28T07:40:31.386536+00:00", "last_updated": "2021-04-28T07:40:31.386536+00:00", "context": {"id": "6dd92c1431d15d1c6d4d8df80aa1b68c", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920114+00:00", "context": {"id": "fc29361c2b8d64f67a56464482bb7d8d", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 37, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_image", "old_state": {"entity_id": "sensor.dockernas_mosquitto_image", "state": "eclipse-mosquitto", "attributes": {"friendly_name": "mosquitto Image", "icon": "mdi:information-outline"}, "last_changed": "2021-04-28T07:40:31.395092+00:00", "last_updated": "2021-04-28T07:40:31.395092+00:00", "context": {"id": "1c97a679c9842e4810a01566a1e4de59", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920458+00:00", "context": {"id": "10faffb617e7d25b65ccc9fd021808ed", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 37, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_status", "old_state": {"entity_id": "sensor.dockernas_mosquitto_status", "state": "Up 1 month", "attributes": {"friendly_name": "mosquitto Status", "icon": "mdi:checkbox-marked-circle-outline"}, "last_changed": "2021-04-28T07:40:31.408057+00:00", "last_updated": "2021-04-28T07:40:31.408057+00:00", "context": {"id": "20df4611282f6f4071a54df3c93242b8", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.920751+00:00", "context": {"id": "854b9ca635d3876da3498b47538e78b8", "parent_id": null, "user_id": null}}} 2021-04-28 10:20:27 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140085844330336] Sending {"id": 37, "type": "event", "event": {"event_type": "state_changed", "data": {"entity_id": "sensor.dockernas_mosquitto_memory", "old_state": {"entity_id": "sensor.dockernas_mosquitto_memory", "state": "0.18", "attributes": {"unit_of_measurement": "MB", "friendly_name": "mosquitto Memory", "icon": "mdi:memory"}, "last_changed": "2021-04-28T07:40:31.418117+00:00", "last_updated": "2021-04-28T07:40:31.418117+00:00", "context": {"id": "cfbd61e8cf5ee979b13d135349c63482", "parent_id": null, "user_id": null}}, "new_state": null}, "origin": "LOCAL", "time_fired": "2021-04-28T08:20:27.921077+00:00", "context": {"id": "de0f0aff3ab659f8bf4322773fc04bb7", "parent_id": null, "user_id": null}}}

ualex73 commented 3 years ago

@tarikdenboer thanks, i can see you have: 2021-04-28 10:20:27 DEBUG (Thread-3) [custom_components.monitor_docker.helpers] mosquitto-old: Event destroy container

But i don't see a logging like: name: Event create container

In the logging, this "explains" why we this specific behavior.

Can you redo it, and before you do it, start the following command to capture create/destroy/rename: docker events --filter 'event=create' --filter 'event=destroy' --filter 'event=rename'

andreasbrett commented 3 years ago

Can also confirm that this happens to me when I update a container with the latest image. My containers are setup via docker-compose. If I run my usual update routine, sensors for the updated containers go missing.

my update routine: docker-compose pull CONTAINERNAME docker-compose up -d

ualex73 commented 3 years ago

@andreasbrett I cannot reproduce it here (I use exactly the same commands), can you collect the docker events? Then hopefully we can see what happens.

andreasbrett commented 3 years ago

@andreasbrett I cannot reproduce it here (I use exactly the same commands), can you collect the docker events? Then hopefully we can see what happens.

Unfortunately I wasn't able to reproduce it right now. I had one container that was still unavailable after an update last time. As there was no update on Docker Hub I just mimicked that by adding a new environment variable in my docker-compose file for that container and ran docker-compose up -d. The container became available again in HA. So it seems this does not always happen or at least not under ALL circumstances when the container is recreated. Here the docker events output:

2021-05-04T12:59:36.938405367+02:00 container rename c6afe21778560c071c642876180b9d974dc8ad7bbd482ba1937fab15b8a2e470 (com.docker.compose.config-hash=af4dd0889c97eb893c5f6badd80bc32dfc476999dc6bb24db2e28e7a0de988cd, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=signal-rest-api, com.docker.compose.version=1.27.4, diun.enable=true, image=bbernhard/signal-cli-rest-api:latest, name=c6afe2177856_signal-rest-api, oldName=/signal-rest-api) 2021-05-04T12:59:37.154650689+02:00 container create 40f4e20a116406e8dbaf1eb18abc959018e43e4548baae87c0234d4b9413ae61 (com.docker.compose.config-hash=15eeb45e6353dcaffdad53cfb78664669b48915225740536d42c801e43d252f5, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=signal-rest-api, com.docker.compose.version=1.27.4, diun.enable=true, image=bbernhard/signal-cli-rest-api:latest, name=signal-rest-api) 2021-05-04T12:59:39.049892290+02:00 container destroy c6afe21778560c071c642876180b9d974dc8ad7bbd482ba1937fab15b8a2e470 (com.docker.compose.config-hash=af4dd0889c97eb893c5f6badd80bc32dfc476999dc6bb24db2e28e7a0de988cd, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=signal-rest-api, com.docker.compose.version=1.27.4, diun.enable=true, image=bbernhard/signal-cli-rest-api:latest, name=c6afe2177856_signal-rest-api)

andreasbrett commented 3 years ago

@ualex73 Good news. Thanks to UniFi I got the chance to update my unifi container and it successfully reproduced the issue. Before the update I had a sensor for that container, after the update the sensor went missing. Here's the docker events output.

2021-05-04T17:12:00.769389785+02:00 container rename fcbf7e3197c3b5f48c66075545b9b07e6454610e7607ea2c7a24ca4e76a02f52 (build_version=Linuxserver.io version:- 6.1.71-ls106 Build-date:- 2021-04-27T04:11:26+00:00, com.docker.compose.config-hash=72fc2b2d71f7385dbf0ad6dc637368c7e33dc23650d2369cdebf648c2ef79e0f, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=unifi, com.docker.compose.version=1.27.4, diun.enable=true, image=linuxserver/unifi-controller, maintainer=aptalca, name=fcbf7e3197c3_unifi, oldName=/unifi, org.opencontainers.image.authors=linuxserver.io, org.opencontainers.image.created=2021-04-27T04:11:26+00:00, org.opencontainers.image.description=The [Unifi-controller](https://www.ubnt.com/enterprise/#unifi) Controller software is a powerful, enterprise wireless software engine ideal for high-density client deployments requiring low latency and high uptime performance. , org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-unifi-controller, org.opencontainers.image.licenses=GPL-3.0-only, org.opencontainers.image.ref.name=b6c75286df1d84bd97fb1cc5136eb2e8fb047c84, org.opencontainers.image.revision=b6c75286df1d84bd97fb1cc5136eb2e8fb047c84, org.opencontainers.image.source=https://github.com/linuxserver/docker-unifi-controller, org.opencontainers.image.title=Unifi-controller, org.opencontainers.image.url=https://github.com/linuxserver/docker-unifi-controller/packages, org.opencontainers.image.vendor=linuxserver.io, org.opencontainers.image.version=6.1.71-ls106) 2021-05-04T17:12:01.007548914+02:00 container create 747f604bcccf2611d6bc0b9dd67ae742cdbe6bebe7d02c04dcdbc724b31cb292 (build_version=Linuxserver.io version:- 6.1.71-ls107 Build-date:- 2021-05-04T12:20:48+01:00, com.docker.compose.config-hash=6ae92d341ee17cf96d3d16fa33c7b89524a94e0964fbae5e095863979ede81c7, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=unifi, com.docker.compose.version=1.27.4, diun.enable=true, image=linuxserver/unifi-controller, maintainer=aptalca, name=unifi, org.opencontainers.image.authors=linuxserver.io, org.opencontainers.image.created=2021-05-04T12:20:48+01:00, org.opencontainers.image.description=The [Unifi-controller](https://www.ubnt.com/enterprise/#unifi) Controller software is a powerful, enterprise wireless software engine ideal for high-density client deployments requiring low latency and high uptime performance. , org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-unifi-controller, org.opencontainers.image.licenses=GPL-3.0-only, org.opencontainers.image.ref.name=da84fa09f03270b75e8d0289bfe77e04fe5bd62e, org.opencontainers.image.revision=da84fa09f03270b75e8d0289bfe77e04fe5bd62e, org.opencontainers.image.source=https://github.com/linuxserver/docker-unifi-controller, org.opencontainers.image.title=Unifi-controller, org.opencontainers.image.url=https://github.com/linuxserver/docker-unifi-controller/packages, org.opencontainers.image.vendor=linuxserver.io, org.opencontainers.image.version=6.1.71-ls107) 2021-05-04T17:12:05.945884809+02:00 container destroy fcbf7e3197c3b5f48c66075545b9b07e6454610e7607ea2c7a24ca4e76a02f52 (build_version=Linuxserver.io version:- 6.1.71-ls106 Build-date:- 2021-04-27T04:11:26+00:00, com.docker.compose.config-hash=72fc2b2d71f7385dbf0ad6dc637368c7e33dc23650d2369cdebf648c2ef79e0f, com.docker.compose.container-number=1, com.docker.compose.oneoff=False, com.docker.compose.project=docker, com.docker.compose.project.config_files=docker-compose.yml, com.docker.compose.project.working_dir=/root/docker, com.docker.compose.service=unifi, com.docker.compose.version=1.27.4, diun.enable=true, image=linuxserver/unifi-controller, maintainer=aptalca, name=fcbf7e3197c3_unifi, org.opencontainers.image.authors=linuxserver.io, org.opencontainers.image.created=2021-04-27T04:11:26+00:00, org.opencontainers.image.description=The [Unifi-controller](https://www.ubnt.com/enterprise/#unifi) Controller software is a powerful, enterprise wireless software engine ideal for high-density client deployments requiring low latency and high uptime performance. , org.opencontainers.image.documentation=https://docs.linuxserver.io/images/docker-unifi-controller, org.opencontainers.image.licenses=GPL-3.0-only, org.opencontainers.image.ref.name=b6c75286df1d84bd97fb1cc5136eb2e8fb047c84, org.opencontainers.image.revision=b6c75286df1d84bd97fb1cc5136eb2e8fb047c84, org.opencontainers.image.source=https://github.com/linuxserver/docker-unifi-controller, org.opencontainers.image.title=Unifi-controller, org.opencontainers.image.url=https://github.com/linuxserver/docker-unifi-controller/packages, org.opencontainers.image.vendor=linuxserver.io, org.opencontainers.image.version=6.1.71-ls106)

ualex73 commented 3 years ago

I am expecting it is a timeout issue, I made some changes (rename removes the sensors/switch). Can you try the master branch? (it isn't in HACS, I can only do that, when it is verified)

andreasbrett commented 3 years ago

I am expecting it is a timeout issue, I made some changes (rename removes the sensors/switch). Can you try the master branch? (it isn't in HACS, I can only do that, when it is verified)

I sideloaded the 1.10 version and tried it out. Doesn't work either. I switched one of my docker containers to a dev branch to get to update more often and ran the update (docker-compose pull zigbee2mqtt & docker-compose up -d). With the 1.10 version the sensor for that docker container didn't catch the restart and stays in status "exited".

image

Restarting the zigbee2mqtt docker container doesn't change a thing.

Here are some potentially helpful HA log messages:

2021-05-23 11:18:37 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker_zigbee2mqtt_state
2021-05-23 11:18:37 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker_zigbee2mqtt_status
2021-05-23 11:18:37 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker_zigbee2mqtt_1cpu
2021-05-23 11:18:37 ERROR (MainThread) [homeassistant.components.sensor] Entity id already exists - ignoring: sensor.docker_zigbee2mqtt_memory_percent
2021-05-23 11:18:38 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 594, in async_remove
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.docker_zigbee2mqtt_state async_remove called twice
2021-05-23 11:18:38 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 594, in async_remove
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.docker_zigbee2mqtt_status async_remove called twice
2021-05-23 11:18:38 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 594, in async_remove
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.docker_zigbee2mqtt_1cpu async_remove called twice
2021-05-23 11:18:38 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 594, in async_remove
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity sensor.docker_zigbee2mqtt_memory_percent async_remove called twice
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] zigbee2mqtt: Cannot determine CPU usage for container ('system_cpu_usage')
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] Raw 'cpu_stats' {'cpu_usage': {'total_usage': 0, 'usage_in_kernelmode': 0, 'usage_in_usermode': 0}, 'throttling_data': {'periods': 0, 'throttled_periods': 0, 'throttled_time': 0}}
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] zigbee2mqtt: Cannot determine memory usage for container ('usage')
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] zigbee2mqtt: Raw 'memory_stats' {}
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] zigbee2mqtt: Can not determine network usage for container ('networks')
2021-05-23 11:18:38 ERROR (Thread-5) [custom_components.monitor_docker.helpers] zigbee2mqtt: No 'networks' found in raw packet
ualex73 commented 3 years ago

@andreasbrett

Did you also the Entity id already exists when you previously tested? Or did it just start showing up now?

andreasbrett commented 3 years ago

@andreasbrett

Did you also the Entity id already exists when you previously tested? Or did it just start showing up now?

Can't remember unfortunately. Maybe @tarikdenboer is still on 1.9 and can check?

psbankar commented 3 years ago

I'm also facing the same issue

ualex73 commented 3 years ago

@psbankar Can you try the latest version in GitHub?

psbankar commented 3 years ago

I am on the latest version 1.9

IDmedia commented 3 years ago

Enabled debug, reboot, cleared all logs then updated all of my containers using the master-version. Couldn't reproduce the issue with containers disappearing apart from the addon complaining about (what I think are) the auto-generated containers created in the upgrade-process (explains the strange names). So I guess this is normal/expected behaviour? Would still be nice if it wouldn't generate errors regarding those tempoary docker containers....

image

ualex73 commented 3 years ago

@IDmedia Thanks for testing the master/v1.10 and good to hear no sensors are disappearing.

The name of the containers seem to be auto-generated by Docker, normally happens when you build a new image (a lot of temporary containers are created) and during the update of a running container. Not sure I easily can recognize such temporary container name.

IDmedia commented 3 years ago

After updating a lot of containers today I noticed that all "combined" sensors I had are gone and I suddendly have individual sensors for every attribute despite using:

monitored_conditions:
      - allinone

A restart of Home Assistant solves the issue.

My best guess here is that the integration fails and then recreates the sensors individually/per attribute instead of respecting the configuration and creating them "allinone". I didn't have the time to check the code yet, but maybe you only read the variable on setup and not upon recreating containers after a disconnect? Unfortunately I had removed the debug logging since everything seemed to work so the only log entry I have is this for a lot of my containers:

container-name: Container not available anymore (3) (DockerError(900, 'Cannot connect to Docker Engine via tcp://192.168.1.50:2375 [Server disconnected]'))

Regarding ignoring auto-generated containers I don't have any good suggestions either. The only thing I can think of is to add a filter to ignore containers with images starting with sha256:.... for those of us who only use image tags. Or ignore container names such as *_* as the auto-generated containers always seem to include one underscore, but none of mine in production do.

ualex73 commented 1 month ago

This is an old issue, I will close it. If persists, please open a new one.