containers / qm

QM is a containerized environment for running Functional Safety qm (Quality Management) software
https://github.com/containers/qm
GNU General Public License v2.0
24 stars 26 forks source link

Timezone undefined within qm container #123

Closed sandrobonazzola closed 1 year ago

sandrobonazzola commented 1 year ago

After #117 timezone within the QM container is undefined, not solving #113 .


# timedatectl
               Local time: ven 2023-07-21 13:56:55 CEST
           Universal time: ven 2023-07-21 11:56:55 UTC
                 RTC time: ven 2023-07-21 11:56:55
                Time zone: Europe/Rome (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

# podman exec -ti qm timedatectl
               Local time: Fri 2023-07-21 11:55:24 UTC
           Universal time: Fri 2023-07-21 11:55:24 UTC
                 RTC time: n/a
                Time zone: n/a (UTC, +0000)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no
rhatdan commented 1 year ago

Works for me.

podman exec qm timedatectl
               Local time: Sat 2023-07-22 06:27:14 EDT
           Universal time: Sat 2023-07-22 10:27:14 UTC
                 RTC time: n/a
                Time zone: America/New_York (EDT, -0400)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no

Could you do a quadlet --dryrun and check to see if --tz=local is being passed to your podman command line?

sandrobonazzola commented 1 year ago

Looks like --tz=local is not passed to podman at runtime even if the ExecStart line has it.

# timedatectl 
               Local time: lun 2023-07-24 08:46:39 CEST
           Universal time: lun 2023-07-24 06:46:39 UTC
                 RTC time: lun 2023-07-24 06:46:39
                Time zone: Europe/Rome (CEST, +0200)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

# podman exec -ti qm timedatectl
               Local time: Mon 2023-07-24 06:44:13 UTC
           Universal time: Mon 2023-07-24 06:44:13 UTC
                 RTC time: n/a
                Time zone: n/a (UTC, +0000)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no

# ps aux |grep podman
root         899  0.0  0.0   8308  1972 ?        Ss   08:28   0:00 /usr/bin/conmon --api-version 1 -c ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36 -u ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36 -r /usr/bin/crun -b /var/lib/containers/storage/overlay-containers/ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36/userdata -p /run/containers/storage/overlay-containers/ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36/userdata/pidfile -n qm --exit-dir /run/libpod/exits --full-attach -l journald --log-level warning --runtime-arg --log-format=json --runtime-arg --log --runtime-arg=/run/containers/storage/overlay-containers/ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36/userdata/oci-log --conmon-pidfile /run/containers/storage/overlay-containers/ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36/userdata/conmon.pid --exit-command /usr/bin/podman --exit-command-arg --root --exit-command-arg /var/lib/containers/storage --exit-command-arg --runroot --exit-command-arg /run/containers/storage --exit-command-arg --log-level --exit-command-arg warning --exit-command-arg --cgroup-manager --exit-command-arg systemd --exit-command-arg --tmpdir --exit-command-arg /run/libpod --exit-command-arg --network-config-dir --exit-command-arg  --exit-command-arg --network-backend --exit-command-arg netavark --exit-command-arg --volumepath --exit-command-arg /var/lib/containers/storage/volumes --exit-command-arg --db-backend --exit-command-arg boltdb --exit-command-arg --transient-store=false --exit-command-arg --runtime --exit-command-arg crun --exit-command-arg --storage-driver --exit-command-arg overlay --exit-command-arg --storage-opt --exit-command-arg overlay.mountopt=nodev,metacopy=on --exit-command-arg --events-backend --exit-command-arg journald --exit-command-arg container --exit-command-arg cleanup --exit-command-arg --rm --exit-command-arg ffc71fe61637fd94b5e4fae83ce46c272a0f83a26092b22de988b01c9c1d3e36

# /usr/libexec/podman/quadlet --dryrun
quadlet-generator[13479]: Loading source unit file /etc/containers/systemd/qm.container
---qm.service---
[Install]
WantedBy=default.target

[Service]
AllowedCPUs=2-3
CPUWeight=50
Delegate=true
IOWeight=50
ManagedOOMSwap=kill
MemorySwapMax=0
# Containers within the qm y default set OOMScoreAdj to 750
OOMScoreAdjust=500
Restart=always
Slice=QM.slice
Environment=ROOTFS=/usr/lib/qm/rootfs
ExecStartPre=/usr/share/qm/setup hirte-agent
Environment=PODMAN_SYSTEMD_UNIT=%n
KillMode=mixed
ExecStop=/usr/bin/podman rm -f -i --cidfile=%t/%N.cid
ExecStopPost=-/usr/bin/podman rm -f -i --cidfile=%t/%N.cid
Delegate=yes
Type=notify
NotifyAccess=all
SyslogIdentifier=%N
ExecStart=/usr/bin/podman run --name=qm --cidfile=%t/%N.cid --replace --rm --cgroups=split --tz=local --network=host --sdnotify=conmon -d --security-opt label=type:qm_t --security-opt label=filetype:qm_file_t --security-opt label=level:s0 --device=/dev/fuse --cap-add=all --read-only --read-only-tmpfs=false -v ${ROOTFS}/etc:/etc -v ${ROOTFS}/var:/var --security-opt label=nested --security-opt unmask=all --rootfs ${ROOTFS} /sbin/init

[X-Container]
AddCapability=all
AddDevice=-/dev/kvm
AddDevice=-/dev/fuse
ContainerName=qm
Exec=/sbin/init
Network=host
PodmanArgs=--security-opt label=nested --security-opt unmask=all
ReadOnly=true
Rootfs=${ROOTFS}
SecurityLabelFileType=qm_file_t
SecurityLabelLevel=s0
SecurityLabelType=qm_t
Timezone=local
Volume=${ROOTFS}/etc:/etc
Volume=${ROOTFS}/var:/var

[Unit]
SourcePath=/etc/containers/systemd/qm.container
RequiresMountsFor=%t/containers
sandrobonazzola commented 1 year ago

Perhaps I need a newer podman?

# rpm -qv podman
podman-4.6.0-0.3.el9.x86_64
sandrobonazzola commented 1 year ago

I retried this on a clean setup and now it works as expected:

podman exec -ti qm timedatectl
               Local time: Mon 2023-07-24 10:10:58 CEST
           Universal time: Mon 2023-07-24 08:10:58 UTC
                 RTC time: n/a
                Time zone: Europe/Rome (CEST, +0200)
System clock synchronized: yes
              NTP service: n/a
          RTC in local TZ: no

Closing as not a bug, sorry for the noise.