Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 499492 - net-misc/chrony should provide a chrony-wait.service with USE=systemd
Summary: net-misc/chrony should provide a chrony-wait.service with USE=systemd
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Jeroen Roovers (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-27 20:17 UTC by Stefan G. Weichinger
Modified: 2017-03-13 12:53 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
chrony-wait.service (file_499492.txt,413 bytes, text/plain)
2015-10-20 05:43 UTC, Stefan G. Weichinger
Details
patch against chrony-2.1.1.ebuild (patch,426 bytes, patch)
2015-10-20 05:44 UTC, Stefan G. Weichinger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan G. Weichinger 2014-01-27 20:17:09 UTC
chrony takes some time to sync with NTP servers ... when started via systemd (maybe also with openrc) this takes some time and if we don't define a time-sync.target for other services to rely on, some other services might start with a wrong time (which is corrected soon after and leads to problems).

I noticed this with net-misc/dhcp (in peer-mode) ... dhcpd.service should wait for time-sync.target.

As I didn't find a chrony-wait.service in portage or bgo ... I suggest using the mentioned unit-file.

Reproducible: Always




# cat /etc/systemd/system/chrony-wait.service 
[Unit]
Description=Wait for chrony to synchronize system clock
After=chronyd.service
Requires=chronyd.service
Before=time-sync.target
Wants=time-sync.target

[Service]
Type=oneshot
# Wait up to ~10 minutes for chronyd to synchronize and the remaining
# clock correction to be less than 0.1 seconds
ExecStart=/usr/bin/chronyc waitsync 60 0.1
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Comment 1 Stefan G. Weichinger 2014-01-27 21:51:35 UTC
additional note for another service (should be another bug, yes ...):

net-mail/dovecot is also quite sensitive to big timesteps ... should then also rely on time-sync.target --- thanks.
Comment 2 Stefan G. Weichinger 2014-01-30 09:39:30 UTC
And more slightly off-topic but related to chronyd and systemd as well:

I get

systemd[1]: [/usr/lib64/systemd/system/chronyd.service:8] Unknown lvalue 'ControlGroup' in section 'Service'

As far as I googled the ControlGroup= setting has been removed.

So I suggest removing that line:

# cat chronyd.service 
[Unit]
Description=Chrony Network Time Service
After=ntpdate.service sntp.service network.target
Conflicts=ntpd.service

[Service]
ExecStart=/usr/sbin/chronyd -r -s -d

[Install]
WantedBy=multi-user.target
Comment 3 Pacho Ramos gentoo-dev 2014-02-05 21:29:45 UTC
Not sure how ended the way to check for networking being really connected with systemd, @systemd? :/
Comment 4 Mike Gilbert gentoo-dev 2014-09-14 17:16:19 UTC
What happens if chrony has not synced the clock to within 0.1 seconds by the time the 10 minute timeout has elapsed?

I assume chronyc would exit with non-zero status, and this unit would fail. Would time-sync.target still be reached in that case?

Other than that, this unit seems reasonable, so long as it is optionally enabled by the sysadmin.
Comment 5 Stefan G. Weichinger 2014-09-15 10:12:47 UTC
(In reply to Mike Gilbert from comment #4)
> What happens if chrony has not synced the clock to within 0.1 seconds by the
> time the 10 minute timeout has elapsed?
> 
> I assume chronyc would exit with non-zero status, and this unit would fail.
> Would time-sync.target still be reached in that case?
> 
> Other than that, this unit seems reasonable, so long as it is optionally
> enabled by the sysadmin.

We could use other values, sure.
And yes, only as an option.

I can test if chronyc exits with errorcode (maybe it's even in the manpages) but right now I am too busy with other things.
Comment 6 Stefan G. Weichinger 2015-09-23 19:15:07 UTC
BUMP - how to proceed here?
Comment 7 Mike Gilbert gentoo-dev 2015-09-23 20:28:04 UTC
(In reply to Stefan G. Weichinger from comment #6)
> BUMP - how to proceed here?

I believe you volunteered to do some testing. How did that go?
Comment 8 Stefan G. Weichinger 2015-09-23 20:41:12 UTC
correct pong for my ping ;-)

I will rethink what and how to test exactly (I also haven't looked at this issue for months).

Your corner-case sounds valid ... but maybe much less likely in comparison to not having time-sync.target at all.
Comment 9 Mike Gilbert gentoo-dev 2015-09-23 23:08:54 UTC
I suspect the maintainer here is not interested, so re-assigning to the systemd team. Hopefully we will get to it soonish.
Comment 10 Stefan G. Weichinger 2015-09-24 05:59:39 UTC
additional info:

I seem to have copied the suggested file from a fedora installation.
Both the target and the service are used there.
Comment 11 Stefan G. Weichinger 2015-10-06 19:13:34 UTC
bumping here silently ;-)

no hurry from my side, I just want to show that I care for the bugs I file :-)
Comment 12 Pacho Ramos gentoo-dev 2015-10-18 10:15:36 UTC
Maybe sending pull requests could help a bit to speed things a bit as usual, this kind of modifications are pretty small (add a new revision adding the one or two lines needed to install the relevant unit file) :/
Comment 13 Stefan G. Weichinger 2015-10-19 14:02:46 UTC
(In reply to Pacho Ramos from comment #12)
> Maybe sending pull requests could help a bit to speed things a bit as usual,
> this kind of modifications are pretty small (add a new revision adding the
> one or two lines needed to install the relevant unit file) :/

ok will do. beginners question: where to send the PR?
Comment 14 Stefan G. Weichinger 2015-10-19 14:06:38 UTC
suggested ebuild here:

https://github.com/stefangweichinger/gentoo-overlay/tree/master/net-misc/chrony
Comment 15 Jeroen Roovers (RETIRED) gentoo-dev 2015-10-20 03:34:28 UTC
Please attach patches.
Comment 16 Stefan G. Weichinger 2015-10-20 05:43:24 UTC
Created attachment 414952 [details]
chrony-wait.service
Comment 17 Stefan G. Weichinger 2015-10-20 05:44:20 UTC
Created attachment 414954 [details, diff]
patch against chrony-2.1.1.ebuild
Comment 18 Jeroen Roovers (RETIRED) gentoo-dev 2017-02-02 07:40:44 UTC
(In reply to Mike Gilbert from comment #9)
> I suspect the maintainer here is not interested, so re-assigning to the
> systemd team. Hopefully we will get to it soonish.

Maintainers are assignees of packages, not random people charged to fix issues.
Comment 19 Stefan G. Weichinger 2017-02-02 17:41:03 UTC
PR: https://github.com/gentoo/gentoo/pull/3776
Comment 20 Stefan G. Weichinger 2017-03-13 12:53:24 UTC
I wrote here, I did a PR at github, they closed my PR and pointed me back here.
Sorry, losing interest.