systemd: start dockerd after time-set.target#43107
Conversation
Single-Board Computer and embedded systems might have a clock that is extremely out of sync with reality. Adding this target ensures docker is only started after a somewhat realistic clock was set. More information about the time-set.target can be found here: https://www.freedesktop.org/software/systemd/man/systemd.special.html#time-sync.target Signed-off-by: Michael Kuehn <[email protected]>
|
@AkihiroSuda I see you added the cherry-pick label, but the 20.10 release still uses the copy of the systemd units in the docker-ce-packaging repo, so a PR would need to be opened in that repository (against the 20.10 branch); https://github.com/docker/docker-ce-packaging/blob/20.10/systemd/docker.service |
|
I wanted to double-check if this could cause potential issues in startup delays (I recall we had some change at some point that caused startup to be delayed, waiting for a user session to be started). From the systemd docs; https://www.freedesktop.org/software/systemd/man/systemd.special.html#time-set.target The above looks ok to me The last paragraph also describes: I think that's ok, but thought it wouldn't hurt to mention here, in case there's concerns (i.e., could a system have some custom service installed that delays |
|
/cc @tianon ptal (for extra eyes in case I missed something) Also wondering if containerd's unit should have this as well? CI failures are unrelated (I kicked CI again, but don't think we test changes in this file) |
i think thats the point. The target actually needs to be delayed by whatever syncs the local clock - otherwise the target might be reached (and thus dockerd might start) before the time is correct. One thing that just came to my mind: as dockerd already is ordered after Also i'm not sure if I chose |
|
Yes, I'm definitely more wary of using
So (see above) my concern was a bit; does the meaning of |
|
I see - okay so we were actually wondering about the same. :) Here is my research results: Chrony for example bundles two services files: In case chrony-wait.service is used (i guess this is up to distros and end-users), time-sync.target is only reached after the sync happened - as the unit orders itself before. As the unit-file only uses a weak-dependency (Wants= instead of Requires=), the service failing has no impact (i.e. target will be considered reached). In case systemd-timesyncd is used, the same behavior can be accomplished if systemd-time-wait-sync.service is enabled. This is because i guess the binary initially sets the clock (so it implements time-set.target) and i guess after that the daemon forks into background and does NTP sync (hence it's also part of time-sync.target). And the controlling of it's blocking or not is done by systemd-time-wait-sync. Actually an elegant solution.
Kinda. Because systemctl show time-sync.target outputs: So time-set will be reached before that. Or phrases differently: time-sync.target always implies time-set.target. If something in time-set will do a local clock-sync depends on the system configuration. I.e. when using systemd-timesyncd (w/ systemd-time-wait-sync.service)
systemd-timesyncd (w/o systemd-time-wait-sync.service)
chronyd.service
chrony-wait.service
So that means that the meaning of time-sync.target depends on host configuration: on some systems it might be async, on some it might be sync. So that means
However, we could say it's fine to require the user to configure the dockerd.service to manually add As it's easier to add to the dependencies then to remove, i guess the most flexible configuration is to keep the patch as is and then people need to be knowledgable about their setup (or distributions have to take care of that):
However, the best "out of the box" experience would be to order dockerd after However we continue to do it here - both approaches are fine and will be an improvement to having no ordering after any Sorry for the lengthy reply and not doing/stating this research in the initial PR. |
tianon
left a comment
There was a problem hiding this comment.
Given this is just After, it's only an ordering relationship, not a harder requirement, so I'm on board (and given the thorough research already noted here). 👍
Wow, thanks for doing the extra digging, and detailed information; definitely useful! (and it's good to double-check the expected behaviour; these "seemingly small and trivial" changes can sometimes turn out to be "not so trivial" 😅 |
- What I did
Make docker daemon wait for systemd's time-set.target to be reached so runaway hardware-clocks don't cause certificate issues on boot when using docker swarm on embedded or single-board computers.
Detailed information can be found in #34827 (comment)
- How I did it
Added timer-set.target to
After=section of the unit file.- How to verify it
After installation, run
systemctl show time-set.target| grep -i docker.serviceshould output one line (beginning withBefore=)- Description for the changelog
systemd: start dockerd after time-set.target