merofeev / docker-windows-volume-watcher

A tool to notify Docker contianers about changes in mounts on Windows.
MIT License
188 stars 30 forks source link

Duplicate notification - a single change triggers 2 notifications to the container. #13

Closed safizn closed 5 years ago

safizn commented 5 years ago

Hi, all notifications of changes are duplicated, for some reason the container receives double the modification number. A single file modified change, triggers 2 container notify calls.

docker-volume-watcher *node* -v
INFO:root:Notifier c:\Users/<user>/repository -> app_test_nodejs_run_12:/app created.
INFO:root:Container app_test_nodejs_run_12 has 1 watched directories
INFO:root:Notifying container app_test_nodejs_run_12 about change in /app/x.js
INFO:root:
INFO:root:Notifying container app_test_nodejs_run_12 about change in /app/x.js
INFO:root:

Suggested workaround:

Could you add an option for a slight delay like 100 ms, to prevent docker-volume-watcher from triggering false notifications (when it comes to the same container) ? e.g. docker-volume-watcher --delay 100

Versions:

pip list

argh                          0.26.2
certifi                       2018.10.15
chardet                       3.0.4
docker                        3.5.1
docker-pycreds                0.3.0
docker-windows-volume-watcher 1.1.0
idna                          2.7
pathtools                     0.1.2
pip                           18.1
pypiwin32                     223
pywin32                       224
PyYAML                        3.13
requests                      2.20.0
setuptools                    39.0.1
six                           1.11.0
urllib3                       1.24
watchdog                      0.9.0
websocket-client              0.53.0
safizn commented 5 years ago

Maybe can be useful - https://stackoverflow.com/questions/21587415/python-watchdog-modified-and-created-duplicate-events

Sorry I don't deal with python.

merofeev commented 5 years ago

Hi Dr. Safi, Thanks for reporting this. Can you please provide some extra details:

  1. Do you experience this issue during file creation only of during file modification as well?
  2. Does double notification happen with any text editor or with some specific one?
safizn commented 5 years ago

@merofeev

  1. This happens during file modification. Deleting/Creating files don't cause any notification propagation.
  2. Tested with regular notepad.exe and VSCode both cause the same issue. To make sure no I've closed VSCode and kept only notepad running (preventing any Git modification).
merofeev commented 5 years ago

Dear @myuseringithub and @fchastanet,

The version of 1.2.0 docker-windows-volume-watcher has been released. I have added optional debounce support to it.

To try it:

  1. Update docker-windows-volume-watcher: pip install --upgrade docker-windows-volume-watcher
  2. And run it with debounce option: docker-volume-watcher --debounce 0.1

I kindly ask you to test it in your environment and report your results.

If your expireience with this feature is good, I will make it enabled by default in the next release.

safizn commented 5 years ago

Thanks for the effort, I've implemented my own debounce around the issue. Once I will have time to test it, I will write up.

patricknelson commented 4 years ago

Unfortunately I'm still getting I'm getting exactly 2 notifications for every single file change, even with a debounce of 3 seconds. Here's a screncap, you can tell I didn't do anything in between saves (first time was ctrl+s, the second was clicking the save icon, nothing else):

ezgif-4-c16cf52c42fa

Can anyone else reproduce this bug? Here's what I did: In a folder called test I setup docker-compose.yml with the following yaml:

version: '3'
services:
  alpine:
    image: node:6.17-alpine
    entrypoint: tail -f /dev/null
    restart: always
    volumes:
      - .:/var/www/html

Run via docker-compose up -d. Then login to the container via docker exec -it test_alpine_1 sh and install nodemon and start monitoring for changes to text files:

npm install -g nodemon
nodemon -e "*.txt" /tail -f /dev/null

Then be sure you also start docker-volume-watcher. In my case with a --debounce of 3.