Re: [chrony-users] Systemd timers and chrony

2022-03-23 Thread Andrei Borzenkov
On Wed, Mar 23, 2022 at 3:22 PM Miroslav Lichvar  wrote:
>
> On Wed, Mar 23, 2022 at 03:15:21PM +0300, Andrei Borzenkov wrote:
> > And systemd-timesyncd.target will pull in time-set.target:
> >
> > Wants=time-set.target
> > Before=time-set.target
>
> An important thing to note is that timesyncd just restores the time
> from a file for the time-set target to be reached. It does not wait
> for the clock to be set by NTP.
>
> The same thing can be done with the chronyd -s option (when there is
> no RTC).
>


Yes, but without proper systemd dependencies other (timer) units will
not wait for it to happen. systemd-timesyncd.service has these
dependencies, while chronyd.service not, even if you use -s option.

-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



Re: [chrony-users] Systemd timers and chrony

2022-03-23 Thread Andrei Borzenkov
On Wed, Mar 23, 2022 at 2:28 PM Krix Rosinski  wrote:
>
> Hello all, thank you for the speedy reply!
>
> @Laura, yes we disable systemd-timesyncd completely and enable chrony instead.
>
> @Kevin, I may ask a separate question there, I thought this will be a common 
> issue for chrony users though.
>
> @Miroslav, timer below, we don't have an RTC, we haven't enabled chrony-wait 
> service yet but we will check if it helps here.
>
> [Unit]
> Description=Daily Timer One Per Day
>
> [Timer]
> OnCalendar=*-*-* 02:10:00
>

Reading systemd.timer man page:

Timer units with at least one OnCalendar= directive acquire a pair of
additional After= [Default] dependencies on time-set.target and
time-sync.target, in order to avoid being started before the system
clock has been correctly set.

And systemd-timesyncd.target will pull in time-set.target:

Wants=time-set.target
Before=time-set.target

chrony-wait.service is also ordered before time-sync.target, so using
it should be equivalent to systemd-timesyncd.service.

> [Install]
> WantedBy=timers.target
>
>
> On Wed, 23 Mar 2022 at 12:18, Miroslav Lichvar  wrote:
>>
>> On Wed, Mar 23, 2022 at 12:09:32PM +0100, Krix Rosinski wrote:
>> > Hello,
>> >
>> > We are trying to set up chrony instead of systemd-timesyncd service,
>> > everything works perfectly except for the systemd timers which fires
>> > straight away when chrony updates time. It seems that systemd-timesyncd
>> > does somethings to temporarily stop timers for time update, and this
>> > doesn't work out of the box with chrony.
>>
>> Can you post an example of the timer which triggers?
>>
>> Does the machine have an RTC?
>>
>> Does it happen when you enable the chrony-wait service?
>>
>> --
>> Miroslav Lichvar
>>
>>
>> --
>> To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org
>> with "unsubscribe" in the subject.
>> For help email chrony-users-requ...@chrony.tuxfamily.org
>> with "help" in the subject.
>> Trouble?  Email listmas...@chrony.tuxfamily.org.
>>

-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



Re: [chrony-users] How to detect internet becoming available

2021-09-11 Thread Andrei Borzenkov
On 11.09.2021 20:39, Uwe Fechner wrote:
> Dear Andrei,
> 
> You wrote:
> "Why? chrony should recover when time sources become reachable."
> 
> Indeed, it seams to work ...
> 
> I used ntp before, and with ntp it did not work without restarting ntp ...
> 
> But what is the command
> chronyc online
> needed for if chronyd discovers the online status automatically?
> 

"offline" means chrony will not poll this source. This is different from
your case which is simply temporary network outage somewhere between
your system and time servers. Your sources are not "offline" so you do
not need to place them "online".

> I currently have it in the scripts /etc/network/if-up.d/01_start_chrony and
> /etc/NetworkManager/dispatcher.d/wwan0 .
> 

Because NM dispatcher script offlines sources when local system
configuration makes it impossible to reach them. Again, it is unrelated
to connectivity status outside your system. In this case chrony simply
continues to poll sources until they start answering again.

> My chrony.conf file:
> 
> pool pool.ntp.org iburst auto_offline
> driftfile /var/lib/chrony/drift
> makestep 1.0 3
> rtcfile /var/lib/chrony/rtc
> rtconutc
> rtcautotrim 30
> 
> You also asked:
> "Is your board shut down when it gets power failure indication or it is 
> simply switched off?"
> 
> It is just switched off, no shut down in case of power failure.
> 
> Uwe
> 
> 
> 
> From: Andrei Borzenkov 
> Sent: Saturday, September 11, 2021 12:10 PM
> To: chrony-users@chrony.tuxfamily.org 
> Subject: Re: [chrony-users] How to detect internet becoming available
> 
> This email originated from outside of your organization. Please do not click 
> on links or open attachments unless you recognize the sender and know the 
> content is safe.
> 
> 
> On 11.09.2021 13:02, Uwe Fechner wrote:
>> Hello,
>>
>> we have an Linux ARM board that can be connected to the internet
>> using a wired connection.
>>
>> Chrony is started at boot time.
>>
>> After a power failure it can happen that our board starts up BEFORE
>> internet becomes available, for example because the router it is
>> connected to has a higher startup-and-sync time than our board.
>>
>> How can I inform chrony that internet is available?
>>
> 
> Why? chrony should recover when time sources become reachable.
> 
>> I know I can use the command "chronyc online", but how can I trigger
>> that without using network manager?
>>
> 
> Do you mean your sources are offline after boot? Is your board shut down
> when it gets power failure indication or it is simply switched off?
> 
> --
> To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org
> with "unsubscribe" in the subject.
> For help email chrony-users-requ...@chrony.tuxfamily.org
> with "help" in the subject.
> Trouble?  Email listmas...@chrony.tuxfamily.org.
> 
> 


-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



Re: [chrony-users] How to detect internet becoming available

2021-09-11 Thread Andrei Borzenkov
On 11.09.2021 13:02, Uwe Fechner wrote:
> Hello,
> 
> we have an Linux ARM board that can be connected to the internet
> using a wired connection.
> 
> Chrony is started at boot time.
> 
> After a power failure it can happen that our board starts up BEFORE
> internet becomes available, for example because the router it is
> connected to has a higher startup-and-sync time than our board.
> 
> How can I inform chrony that internet is available?
> 

Why? chrony should recover when time sources become reachable.

> I know I can use the command "chronyc online", but how can I trigger
> that without using network manager?
> 

Do you mean your sources are offline after boot? Is your board shut down
when it gets power failure indication or it is simply switched off?

-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.



[chrony-users] Chrony IPv6 sources offline after resume - dispatcher script runs before IPv6 is up

2021-08-12 Thread Andrei Borzenkov
Chrony comes with sample NetworkManager dispatcher script that offlines
NTP sources when interface goes down and onlines them when interface
comes up. Technically it runs "chronyc onoffline" which tries to
determine whether each source can be reached. This script is actually
installed by distributions (openSUSE and Ubuntu for sure).

When system goes to suspend NetworkManager offlines interfaces that
causes chrony to offline its sources. On resume chrony is expected to
online them again.

This works well for IPv4 sources but IPv6 sources remain offline. Like

$ chronyc -n sources
210 Number of sources = 8
MS Name/IP address Stratum Poll Reach LastRx Last sample

===
^? 2001:67c:1560:8003::c80   6 0 - +0ns[   +0ns] +/-
   0ns
^? 2001:67c:1560:8003::c70   6 0 - +0ns[   +0ns] +/-
   0ns
^- 91.189.89.199 2   8   377   108  -2030us[-2209us] +/-
  53ms
^- 91.189.94.4   2   8   37749  -2878us[-3067us] +/-
  60ms
^+ 79.111.152.5  1   8   37751  -2960us[-3149us] +/-
  18ms
^* 188.225.9.167 2   8   37749  -1819us[-2008us] +/-
  15ms
^+ 85.21.78.91   2   8   377   116  -3053us[-3230us] +/-
  19ms
^+ 185.209.85.2222   8   37750  +6182us[+5993us] +/-
  23ms
$

The reason is - when ifup dispatcher script runs, IPv6 is not yet
configured. Here are route entries

default via 192.168.1.1 dev wlan0 proto dhcp metric 20600
169.254.0.0/16 dev wlan0 scope link metric 1000
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.6 metric 600
::1 dev lo proto kernel metric 256 pref medium
fe80::/64 dev wlan0 proto kernel metric 600 pref medium

So IPv4 is up and has default route but IPv6 still only link-local
address. Couple of seconds later

::1 dev lo proto kernel metric 256 pref medium
2a00:::::/64 dev wlan0 proto ra metric 600 pref medium
fe80::/64 dev wlan0 proto kernel metric 600 pref medium
default via fe80::1 dev wlan0 proto ra metric 20600 pref medium

Is it possible to run dispatcher script after both IPv4 and IPv6 are
configured on interface? Or only IPv6 for that matter - it does not
matter if "chronyc onoffline" runs multiple times.

Both IPv4 and IPv6 are set to auto.

-- 
To unsubscribe email chrony-users-requ...@chrony.tuxfamily.org 
with "unsubscribe" in the subject.
For help email chrony-users-requ...@chrony.tuxfamily.org 
with "help" in the subject.
Trouble?  Email listmas...@chrony.tuxfamily.org.