files_inotify icon indicating copy to clipboard operation
files_inotify copied to clipboard

Error while running self-test, no changes detected

Open adrfantini opened this issue 6 years ago • 6 comments

Hi, I am running this app via systemd on Archlinux. My service looks like this:

cat /etc/systemd/system/[email protected]
# to be enabled specifying the mountID, such as
# systemctl enable --now [email protected]
[Unit]
Description=PHP inotify for Nextcloud for mountID %i

[Service]
User=http #my http user
Type=simple
ExecStart=/usr/share/webapps/nextcloud/occ files_external:notify %i
Nice=19
IOSchedulingClass=idle
IOSchedulingPriority=7
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

The app is correctly installed. I can also manually run it via:

sudo -u http ./occ files_external:notify -vvv 1

But I am immediately getting the following error:

Error while running self-test, no changes detected

After a minute, the app stops with no further info. Any idea why? Is this the correct behaviour?

adrfantini avatar Jan 27 '19 17:01 adrfantini

I found similar behavior. When I start it in the command line, it reports the error during self-test. However, I thought that this might be the normal/expected behavior when I start it without any new files actually being present.

After that, it runs for a while, say minutes. When I create new files in the watched folder, the running app pretty much instantaneously reports the new files (command line output). However, after a few minutes, it exits silently. I suppose this is not the desired behavior, since this should run forever, correct?

schniepp avatar Feb 09 '19 15:02 schniepp

Just noticed that the spontaneous exiting was already reported here: https://github.com/nextcloud/server/issues/10097

schniepp avatar Feb 09 '19 15:02 schniepp

OK, looking through the nc error logs, I found what caused "selftest error". The user running nc (www-data) did not have writing rights to the shared folder. Apparently, it tries writing a file during self-test, and when it does not have proper access rights, it fails. Adding www-data to the group of the shared folder fixed the self-test problem.

However, it does not solve the problem with spontaneously exiting. In some of these spontaneous exits, the nc log does not show anything. In my case, it happens exactly after 60 seconds.

schniepp avatar Feb 09 '19 22:02 schniepp

OK, looking through the nc error logs, I found what caused "selftest error". The user running nc (www-data) did not have writing rights to the shared folder. Apparently, it tries writing a file during self-test, and when it does not have proper access rights, it fails. Adding www-data to the group of the shared folder fixed the self-test problem.

Well, that looks more like a workaround, since you do not necessarily want the NC user (http in my case) to be able to have write access, e.g., personal media files from external mounts.

However, it does not solve the problem with spontaneously exiting. In some of these spontaneous exits, the nc log does not show anything. In my case, it happens exactly after 60 seconds.

I have not tested this again, but I recall I also had exactly 60 seconds beore crashes.

adrfantini avatar Feb 10 '19 09:02 adrfantini

Well, that looks more like a workaround, since you do not necessarily want the NC user (http in my case) to be able to have write access, e.g., personal media files from external mounts.

You are right, that's not ideal. However, nc allows to set external shares as read-only, which would be good enough for me as a protection. But perhaps, the extension's practice of needing write access for a self-test is not a very sound one. Perhaps, the negative self-test is also not a real problem. Maybe, the error message could be changed to be more explanatory and sound less severe? Or perhaps, the self-test could be optional, so that users only do it once when setting everything up? This could be triggered with an additional option, so that people can test once when setting it up, rather than every time it is started.

schniepp avatar Feb 10 '19 13:02 schniepp

I guess that the main issue, whatever happens with the selftest, is that this extension is exiting every minute. Is this normal behaviour, and PHP handles the monitoring in the background somehow? We do not know. Currently I am restarting the occ call every times it ends, with systemd like this:

[Unit]
Description=PHP inotify for Nextcloud for mountID %i

[Service]
User=http
Type=simple
ExecStart=/usr/share/webapps/nextcloud/occ files_external:notify %i
Nice=19
IOSchedulingClass=idle
IOSchedulingPriority=7
Restart=always
#RestartSec=1 #defaults to 100ms
StartLimitIntervalSec=60
StartLimitBurst=4

[Install]
WantedBy=multi-user.target

But I'm not really sure if this is a great idea. EDIT: this seems to work, but it certainly is not elegant and causes a CPU spike every minute (but does not spin up a sleeping monitored drive).

adrfantini avatar Feb 10 '19 13:02 adrfantini