Ubuntu 22.04.1 LTS container and systemd-timesyncd issues

eronlloyd

Member
Sep 23, 2020
10
1
8
Reading, PA
I'm migrating Ubuntu VMs to CTs, but ran into an issue trying to get systemd-timesyncd working. For the CT, I'm using the ubuntu-22.04-standard_22.04-1_amd64.tar.zst LXC available for download within LXC. I'm not sure where to report this issue, as it looks like these are Proxmox-provided LXCs, or if it's an upstream issue, so I figured I'd start here.

The first issue is that a provisioned CT cannot start timesyncd, instead producing an error such as the following:
Bash:
root@ct-test:~$ systemctl status systemd-timesyncd
* systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: inactive (dead)
  Condition: start condition failed at Fri 2023-01-06 13:31:37 UTC; 12h ago
             `- ConditionVirtualization=!container was not met
       Docs: man:systemd-timesyncd.service(8)
root@ct-test:~$

The cause of this is the default value for line 5 in the systemd configuration in /etc/systemd/system/dbus-org.freedesktop.timesync1.service, where ConditionVirtualization=!container (shown below) should instead be ConditionVirtualization=container

Bash:
[Unit]
Description=Network Time Synchronization
Documentation=man:systemd-timesyncd.service(8)
ConditionCapability=CAP_SYS_TIME
ConditionVirtualization=!container
DefaultDependencies=no
After=systemd-sysusers.service
Before=time-set.target sysinit.target shutdown.target
Conflicts=shutdown.target
Wants=time-set.target

[Service]
AmbientCapabilities=CAP_SYS_TIME
BusName=org.freedesktop.timesync1
CapabilityBoundingSet=CAP_SYS_TIME
# Turn off DNSSEC validation for hostname look-ups, since those need the
# correct time to work, but we likely won't acquire that without NTP. Let's
# break this chicken-and-egg cycle here.

Changing that setting does start timesyncd, but then the second issue pops up, in that clock_adjtime() is not permitted to be called, I'm assuming because of a permissions problem within systemd:

Bash:
root@ct-test:~# systemctl status systemd-timesyncd
* systemd-timesyncd.service - Network Time Synchronization
     Loaded: loaded (/lib/systemd/system/systemd-timesyncd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2023-01-06 14:05:35 UTC; 11h ago
       Docs: man:systemd-timesyncd.service(8)
   Main PID: 601 (systemd-timesyn)
     Status: "Initial synchronization to time server 185.125.190.56:123 (ntp.ubuntu.com)."
      Tasks: 2 (limit: 28575)
     Memory: 1.3M
        CPU: 77ms
     CGroup: /system.slice/systemd-timesyncd.service
             `-601 /lib/systemd/systemd-timesyncd

Jan 06 20:20:18 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted
Jan 06 20:54:26 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted
Jan 06 21:28:35 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted
Jan 06 22:02:43 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted
Jan 06 22:36:51 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted
Jan 06 23:10:59 ct-test systemd-timesyncd[601]: Failed to call clock_adjtime(): Operation not permitted

I would like to stick with the default timesyncd instead of ripping it out and trying to get ntp working instead, so any tips would be greatly appreciated!
 
Does this explanation for this "problem" or error message also apply to non-dedicated servers? So in the case of rented virtual servers or does the explanation only apply to containers?
I mean is systemd-timesyncd even necessary on a rented virtual server?
The time synchronization would have to be done by the hoster and passed through to the virtual server with their hardware? Do I understand the logic correctly?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!