Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@yubiuser
Copy link
Member

Use pihole-FTL wait-for function to wait for a specific log line to appear.

pi-hole/FTL#2631

@yubiuser yubiuser requested a review from a team as a code owner September 24, 2025 08:05
@yubiuser
Copy link
Member Author

Tests are failing because the line ########## FTL terminated is not printed anymore. This also happens on bare metal FTL's development branch.
@DL6ER

@DL6ER
Copy link
Member

DL6ER commented Sep 24, 2025

Yes, this is an interesting bug. We free the location where files.log.ftl is stored and thereafter, no new lines are printed to the file. We obviously need an exception here. This is a regression of my recent fixing-all-memory-leaks PR. Seem we want to actually leak at least this single bit of memory.

@DL6ER
Copy link
Member

DL6ER commented Sep 24, 2025

See pi-hole/FTL#2634

@yubiuser yubiuser closed this Sep 26, 2025
@yubiuser yubiuser reopened this Sep 26, 2025
@yubiuser
Copy link
Member Author

yubiuser commented Sep 27, 2025

I tried to use pihole-FTL wait-for also in the tests at

sleep 5
grep 'terminated' /var/log/pihole/FTL.log

but it did not work. The pihole-FTL wait-for command did not produce any output (which it should even if it did not find the string), I guess it's because start.sh was already killed. It works with the grep version we use so far so I decided not to invest too much time.

@PromoFaux
Copy link
Member

but it did not work. ...[snip]... I guess it's because start.sh was already killed.

This is odd to me, too. start.sh shouldn't come into it here? It's not so important, but it is perplexing!!

I'm also wondering if a "better" test for clean shut down is actually volume mounting the logs directory and then checking the contents of the log file after the container has stopped. But that's for another time.

@yubiuser
Copy link
Member Author

I'm also wondering if a "better" test for clean shut down is actually volume mounting the logs directory and then checking the contents of the log file after the container has stopped. But that's for another time.

I think you're onto something here. We should not try to postpone shutdown just to read logs from inside the container.

@yubiuser yubiuser requested a review from PromoFaux September 27, 2025 09:46
Co-authored-by: Adam Warner <[email protected]>
Signed-off-by: yubiuser <[email protected]>
@yubiuser yubiuser requested a review from PromoFaux September 27, 2025 12:47
@yubiuser
Copy link
Member Author

But that's for another time.

#1899

done
# Wait until the FTL log contains the "FTL started" message before continuing, timeout after 10 seconds
# exit if we do not find it
pihole-FTL wait-for '########## FTL started' /var/log/pihole/FTL.log 10 "0 > /dev/null"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the PR for the shutdown test - you comment that we check for up to 60 secodns to give slow RISCV devices a chance to start up. Perhaps we should wait 60 seconds here.

Copy link
Member Author

@yubiuser yubiuser Sep 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is: Within the start.sh, pihole-FTL wait-for will only wait for the log line to appear, which is triggered by the capsh --user="${DNSMASQ_USER}" --keep=1 -- -c "/usr/bin/pihole-FTL $FTL_CMD >/dev/null" & line just above. Not much time should be in between.

The other PR watches the container from the outside before it kills the container. There are other (maintenance) tasks before FTL will even be invoked, e.g. running gravity. Therefore I gave it more time.

@PromoFaux PromoFaux merged commit 4554d61 into development Sep 30, 2025
11 checks passed
@PromoFaux PromoFaux deleted the wait-for branch September 30, 2025 17:42
@casperklein
Copy link
Contributor

FTL's build-in wait-for command uses inotify, which doesn't support network file systems.

https://man7.org/linux/man-pages/man7/inotify.7%40%40man-pages.html

Limitations and caveats
The inotify API provides no information about the user or process
that triggered the inotify event. In particular, there is no easy
way for a process that is monitoring events via inotify to
distinguish events that it triggers itself from those that are
triggered by other processes.
Inotify reports only events that a user-space program triggers
through the filesystem API. As a result, it does not catch remote
events that occur on network filesystems. (Applications must fall
back to polling the filesystem to catch such events.)

This could introduce potential issues with network mounted file systems like NFS/CIFS/SMB.

I found this alternative:

( tail -f -n0 /var/log/pihole/FTL.log & ) | grep -q "########## FTL started"

See also https://superuser.com/a/900134

@PromoFaux
Copy link
Member

Just did a simple test from Docker Desktop on windows - though can't guarantee I've done this the right way, it appears to work fine?

image

@casperklein
Copy link
Contributor

Thanks for testing. I did a bit more research. I think this works, because the changes are made locally by FTL. So the kernel knows about this and inotify works.
It does not work, if the log file is altered by another client or on the server directly where the mount is on.

But that shouldn't be an issue here. Sorry for the noise.

In another project we run into issues, when we watched a certificate file for changes on a NFS mount with inotify. The certificate was managed and renewed externally. Inotify did not work in that case. That triggered me when I saw this PR.

@yubiuser
Copy link
Member Author

yubiuser commented Oct 5, 2025

@casperklein Thanks for keeping an eye on this. Network share have been causing trouble before already.

@PromoFaux
Copy link
Member

No need to apologise for noise!

It's an angle I never thought to test - and I learned something about creating CIFS volumes in docker :)

I tried with an NFS volume too, but there were also all sorts of other permission errors there, with or without this change set. Either I have no idea what I'm doing with NFS, or it is a tricky beast!

Interestingly, I couldn't use a UNC path or a mapped network drive directly in the compose file.

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

Successfully merging this pull request may close these issues.

5 participants